mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 04:22:20 +02:00
Fixed the lambda hotswap change
This commit is contained in:
parent
1e04bb1b3e
commit
c5dca50e50
6 changed files with 55 additions and 231 deletions
|
@ -260,7 +260,7 @@ namespace BIStubUI
|
|||
mCancelButton.mImageHi = Images.sButtonHi;
|
||||
mCancelButton.mOnMouseClick.Add(new (mouseArgs) =>
|
||||
{
|
||||
//gApp.mCancelling = true;
|
||||
gApp.mCancelling = true;
|
||||
});
|
||||
mCancelButton.mMouseInsets = new Insets(4, 4, 4, 4);
|
||||
AddWidget(mCancelButton);
|
||||
|
|
|
@ -100,6 +100,20 @@ class Blurg
|
|||
delegate void() mFuncA;
|
||||
delegate void() mFuncB;
|
||||
|
||||
int mA = 123;
|
||||
|
||||
public this()
|
||||
{
|
||||
delegate void() dlg = new () =>
|
||||
{
|
||||
//PrintF("Hey! %d\n", mA);
|
||||
};
|
||||
|
||||
dlg();
|
||||
dlg();
|
||||
dlg();
|
||||
dlg();
|
||||
}
|
||||
|
||||
void TestIt(int a, int b, int c)
|
||||
{
|
||||
|
@ -108,28 +122,7 @@ class Blurg
|
|||
|
||||
public static void Hey()
|
||||
{
|
||||
int a = 123;
|
||||
Blurg blurg = scope .();
|
||||
blurg.mFuncA = new () =>
|
||||
{
|
||||
PrintF("YoA!\n");
|
||||
PrintF("A %d!\n", a);
|
||||
PrintF("Blurg: %p\n", blurg);
|
||||
};
|
||||
|
||||
blurg.mFuncB = new () =>
|
||||
{
|
||||
PrintF("YoB!\n");
|
||||
};
|
||||
|
||||
blurg.TestIt(1, 2, 3);
|
||||
blurg.[Friend]TestIt(1, 2, 3);
|
||||
|
||||
while (true)
|
||||
{
|
||||
blurg.mFuncA();
|
||||
blurg.mFuncB();
|
||||
}
|
||||
Blurg bl = scope .();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -10553,6 +10553,14 @@ namespace IDE
|
|||
if (isFirstMsg)
|
||||
{
|
||||
OutputLineSmart(scope String("ERROR: ", errorMsg));
|
||||
if (gApp.mRunningTestScript)
|
||||
{
|
||||
// The 'OutputLineSmart' would already call 'Fail' when running test scripts
|
||||
}
|
||||
else
|
||||
{
|
||||
Fail(errorMsg);
|
||||
}
|
||||
isFirstMsg = false;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -965,117 +965,8 @@ int64 BfIRBuilder::CheckedShl(int64 a, int64 b)
|
|||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
struct TestQ
|
||||
{
|
||||
public:
|
||||
int mId;
|
||||
BfIRValueFlags mFlags;
|
||||
|
||||
TestQ()
|
||||
{
|
||||
mId = -1;
|
||||
mFlags = BfIRValueFlags_None;
|
||||
}
|
||||
|
||||
|
||||
/*TestQ(const TestQ& from)
|
||||
{
|
||||
mFlags = from.mFlags;
|
||||
mId = from.mId;
|
||||
}*/
|
||||
|
||||
/*TestQ(BfIRValueFlags flags, int id)
|
||||
{
|
||||
mFlags = flags;
|
||||
mId = id;
|
||||
}
|
||||
|
||||
operator bool() const
|
||||
{
|
||||
return mFlags != BfIRValueFlags_None;
|
||||
}*/
|
||||
|
||||
/*bool IsFake() const;
|
||||
bool IsConst() const;
|
||||
bool IsArg() const;
|
||||
bool IsFunc() const;
|
||||
bool IsFromLLVM() const;
|
||||
|
||||
bool operator==(const TestQ& rhs) const
|
||||
{
|
||||
if (mFlags != rhs.mFlags)
|
||||
return false;
|
||||
if (mId != rhs.mId)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool operator!=(const TestQ& rhs) const
|
||||
{
|
||||
if (mFlags != rhs.mFlags)
|
||||
return true;
|
||||
if (mId != rhs.mId)
|
||||
return true;
|
||||
return false;
|
||||
}*/
|
||||
};
|
||||
|
||||
class LTest
|
||||
{
|
||||
public:
|
||||
int mA;
|
||||
int mB;
|
||||
|
||||
void Fiff()
|
||||
{
|
||||
int valZ = 234;
|
||||
mA = 123;
|
||||
mB = 345;
|
||||
|
||||
auto lam = [&]()
|
||||
{
|
||||
mA++;
|
||||
valZ++;
|
||||
};
|
||||
|
||||
lam();
|
||||
}
|
||||
|
||||
static void UseIt(LTest lt)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static void DoIt(BfIRValue irVal)
|
||||
{
|
||||
}
|
||||
|
||||
static void DoIt(TestQ irVal)
|
||||
{
|
||||
}
|
||||
|
||||
BfIRValue CreateCall(BfIRValue func)
|
||||
{
|
||||
return func;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
void TestIt()
|
||||
{
|
||||
LTest lt;
|
||||
lt.mA = 0;
|
||||
lt.mB = 0;
|
||||
LTest::UseIt(lt);
|
||||
|
||||
LTest::DoIt(BfIRValue());
|
||||
LTest::DoIt(TestQ());
|
||||
}
|
||||
|
||||
BfIRBuilder::BfIRBuilder(BfModule* module) : BfIRConstHolder(module)
|
||||
{
|
||||
TestIt();
|
||||
|
||||
mBlockCount = 0;
|
||||
mModule = module;
|
||||
mHasDebugLoc = false;
|
||||
|
@ -2165,12 +2056,7 @@ void BfIRBuilder::CreateTypeDeclaration(BfType* type, bool forceDefine)
|
|||
DbgMakePermanent(diForwardDecl, derivedFrom, diFieldTypes);
|
||||
}
|
||||
else if (isPrimEnum)
|
||||
//if (checkType->IsValueType())
|
||||
{
|
||||
/*llvm::SmallVector<BfIRMDNode, 0> diEnumValues;
|
||||
diForwardDecl = DbgCreateEnumerationType(curDIScope, typeName, fileDIScope, mModule->mCurFilePosition.mCurLine,
|
||||
typeInstance->mSize * 8, typeInstance->mAlign * 8, diEnumValues, DbgGetType(typeInstance->GetUnderlyingType()));*/
|
||||
|
||||
BF_ASSERT(type->mSize > 0);
|
||||
|
||||
diForwardDecl = DbgCreateSizedForwardDecl(llvm::dwarf::DW_TAG_enumeration_type,
|
||||
|
@ -2178,44 +2064,12 @@ void BfIRBuilder::CreateTypeDeclaration(BfType* type, bool forceDefine)
|
|||
}
|
||||
else
|
||||
{
|
||||
// diForwardDecl = DbgCreateForwardDecl(llvm::dwarf::DW_TAG_structure_type,
|
||||
// typeName, curDIScope, fileDIScope, 0);
|
||||
|
||||
diForwardDecl = DbgCreateSizedForwardDecl(llvm::dwarf::DW_TAG_structure_type,
|
||||
typeName, curDIScope, fileDIScope, 0, (int64)BF_ALIGN(type->mSize, type->mAlign) * 8, (int64)type->mAlign * 8);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//TODO: We may not have the fields filled in by the time we need the declaration. Why did we have this here instead of in the def?
|
||||
/*if (isPrimEnum)
|
||||
{
|
||||
BF_ASSERT(!typeInstance->IsDataIncomplete());
|
||||
|
||||
llvm::SmallVector<BfIRMDNode, 8> diEnumValues;
|
||||
for (auto& fieldInst : typeInstance->mFieldInstances)
|
||||
{
|
||||
auto fieldDef = fieldInst.GetFieldDef();
|
||||
if ((fieldInst.mConstIdx != -1) && (fieldDef->IsEnumCaseEntry()))
|
||||
{
|
||||
auto constant = typeInstance->mConstHolder->GetConstantById(fieldInst.mConstIdx);
|
||||
auto enumValue = DbgCreateEnumerator(fieldInst.GetFieldDef()->mName, constant->mInt64);
|
||||
diEnumValues.push_back(enumValue);
|
||||
}
|
||||
}
|
||||
|
||||
int flags = 0;
|
||||
diForwardDecl = DbgCreateEnumerationType(curDIScope,
|
||||
typeName, fileDIScope, mModule->mCurFilePosition.mCurLine, (int64)type->mSize * 8, (int64)type->mAlign * 8, diEnumValues, DbgGetType(typeInstance->GetUnderlyingType()));
|
||||
|
||||
DbgSetType(type, diType);
|
||||
DbgSetInstType(type, diType);
|
||||
}
|
||||
else*/
|
||||
{
|
||||
|
||||
//int align = typeInstance->mIsPacked ? 0 : typeInstance->mAlign;
|
||||
|
||||
// Will fill in later (during definition phase)
|
||||
int flags = 0;
|
||||
diForwardDecl = DbgCreateReplaceableCompositeType(isPrimEnum ? llvm::dwarf::DW_TAG_enumeration_type : llvm::dwarf::DW_TAG_structure_type,
|
||||
|
@ -2225,7 +2079,6 @@ void BfIRBuilder::CreateTypeDeclaration(BfType* type, bool forceDefine)
|
|||
|
||||
mDITemporaryTypes.push_back(typeInstance);
|
||||
}
|
||||
}
|
||||
|
||||
DbgSetInstType(type, diForwardDecl);
|
||||
|
||||
|
@ -2235,13 +2088,11 @@ void BfIRBuilder::CreateTypeDeclaration(BfType* type, bool forceDefine)
|
|||
else
|
||||
diType = DbgCreatePointerType(diForwardDecl);
|
||||
DbgSetType(type, diType);
|
||||
//DbgTrackDITypes(type);
|
||||
}
|
||||
|
||||
if (type->IsTypedPrimitive())
|
||||
{
|
||||
auto underlyingType = type->GetUnderlyingType();
|
||||
//mModule->PopulateType(underlyingType, BfPopulateType_Declaration);
|
||||
irType = MapType(underlyingType);
|
||||
SetType(type, irType);
|
||||
SetInstType(type, irType);
|
||||
|
@ -2320,11 +2171,6 @@ void BfIRBuilder::CreateDbgTypeDefinition(BfType* type)
|
|||
bool isUnion = false;
|
||||
bool isCRepr = false;
|
||||
|
||||
if ((typeDef->mFullName.ToString() == "IDETest.Virtuals.ClassA") || (typeDef->mFullName.ToString() == "IDETest.Virtuals.ClassB"))
|
||||
{
|
||||
NOP;
|
||||
}
|
||||
|
||||
if (typeInstance->IsBoxed())
|
||||
{
|
||||
|
||||
|
@ -2674,11 +2520,6 @@ void BfIRBuilder::CreateDbgTypeDefinition(BfType* type)
|
|||
flags |= llvm::DINode::FlagArtificial;
|
||||
}
|
||||
|
||||
if (methodDef->mMethodType == BfMethodType_Dtor)
|
||||
{
|
||||
NOP;
|
||||
}
|
||||
|
||||
String methodName = methodDef->mName;
|
||||
llvm::SmallVector<BfIRMDNode, 1> genericArgs;
|
||||
llvm::SmallVector<BfIRValue, 1> genericConstValueArgs;
|
||||
|
@ -3206,10 +3047,6 @@ BfIRType BfIRBuilder::MapType(BfType* type, BfIRPopulateType populateType)
|
|||
{
|
||||
if (!mIgnoreWrites)
|
||||
{
|
||||
/*if (populateType == BfIRPopulateType_Declaration)
|
||||
mModule->PopulateType(type, BfPopulateType_Declaration);
|
||||
else if (populateType == BfIRPopulateType_Full)
|
||||
mModule->PopulateType(type, BfPopulateType_Data);*/
|
||||
PopulateType(type, populateType);
|
||||
}
|
||||
BfIRType retType;
|
||||
|
@ -3222,10 +3059,6 @@ BfIRType BfIRBuilder::MapTypeInst(BfTypeInstance* typeInst, BfIRPopulateType pop
|
|||
{
|
||||
if (!mIgnoreWrites)
|
||||
{
|
||||
/*if (populateType == BfIRPopulateType_Declaration)
|
||||
mModule->PopulateType(typeInst, BfPopulateType_Declaration);
|
||||
else if (populateType == BfIRPopulateType_Full)
|
||||
mModule->PopulateType(typeInst, BfPopulateType_Data);*/
|
||||
PopulateType(typeInst, populateType);
|
||||
}
|
||||
|
||||
|
@ -3651,12 +3484,6 @@ BfIRValue BfIRBuilder::CreateShl(BfIRValue lhs, BfIRValue rhs)
|
|||
mOpFailed = false;
|
||||
if ((lhs.IsConst()) && (rhs.IsConst()))
|
||||
{
|
||||
/*auto constLHS = GetConstantById(lhs.mId);
|
||||
auto constRHS = GetConstantById(rhs.mId);
|
||||
|
||||
uint64 val = constLHS->mUInt64 << constRHS->mInt32;
|
||||
return CreateConst(constLHS->mTypeCode, val);*/
|
||||
|
||||
INT_BINOPFUNC_APPLY(lhs, rhs, CheckedShl);
|
||||
}
|
||||
|
||||
|
@ -3931,11 +3758,6 @@ BfIRValue BfIRBuilder::CreateLifetimeStart(BfIRValue val)
|
|||
|
||||
BfIRValue BfIRBuilder::CreateLifetimeEnd(BfIRValue val)
|
||||
{
|
||||
if (mModule->mCurMethodInstance->mMethodDef->mName == "Fart")
|
||||
{
|
||||
NOP;
|
||||
}
|
||||
|
||||
BfIRValue retVal = WriteCmd(BfIRCmd_LifetimeEnd, val);
|
||||
NEW_CMD_INSERTED;
|
||||
return retVal;
|
||||
|
@ -4307,11 +4129,6 @@ BfIRFunction BfIRBuilder::CreateFunction(BfIRFunctionType funcType, BfIRLinkageT
|
|||
NEW_CMD_INSERTED_IRVALUE;
|
||||
mFunctionMap[name] = retVal;
|
||||
|
||||
if (name == "??B?$Result@PEAX@System@bf@@SAPEAXU012@@Z")
|
||||
{
|
||||
NOP;
|
||||
}
|
||||
|
||||
//BfLogSys(mModule->mSystem, "BfIRBuilder::CreateFunction: %d %s Module:%p\n", retVal.mId, name.c_str(), mModule);
|
||||
|
||||
return retVal;
|
||||
|
@ -4849,11 +4666,6 @@ BfIRMDNode BfIRBuilder::DbgCreateMethod(BfIRMDNode context, const StringImpl& na
|
|||
BfIRMDNode retVal = WriteCmd(BfIRCmd_DbgCreateMethod, context, name, linkageName, file, lineNum, type, isLocalToUnit, isDefinition, vk, vIndex, vTableHolder, flags, isOptimized, fn, genericArgs, genericConstValueArgs);
|
||||
NEW_CMD_INSERTED_IRMD;
|
||||
|
||||
if (linkageName == "?Unwrap@?$Result@PEAX@System@bf@@AEAAPEAXXZ")
|
||||
{
|
||||
NOP;
|
||||
}
|
||||
|
||||
// if (mDbgVerifyCodeGen && gDebugDbgLoc)
|
||||
// {
|
||||
// OutputDebugStrF("DbgCreateFunction Context:%d name:%s = %d\n", context.mId, name.c_str(), retVal.mId);
|
||||
|
|
|
@ -714,7 +714,7 @@ DbgLanguage DbgSubprogram::GetLanguage()
|
|||
return DbgLanguage_C; // Parent type would have been set for Beef, so it must be C
|
||||
}
|
||||
|
||||
bool DbgSubprogram::Equals(DbgSubprogram* checkMethod)
|
||||
bool DbgSubprogram::Equals(DbgSubprogram* checkMethod, bool allowThisMismatch)
|
||||
{
|
||||
if ((mLinkName != NULL) && (checkMethod->mLinkName != NULL))
|
||||
{
|
||||
|
@ -724,14 +724,23 @@ bool DbgSubprogram::Equals(DbgSubprogram* checkMethod)
|
|||
if (strcmp(mName, checkMethod->mName) != 0)
|
||||
return false;
|
||||
|
||||
if (mHasThis != checkMethod->mHasThis)
|
||||
return false;
|
||||
|
||||
int paramIdx = 0;
|
||||
auto param = mParams.mHead;
|
||||
auto checkParam = checkMethod->mParams.mHead;
|
||||
while ((param != NULL) && (checkParam != NULL))
|
||||
{
|
||||
if ((param->mType != checkParam->mType) && (!param->mType->Equals(checkParam->mType)))
|
||||
if ((paramIdx == 0) && (allowThisMismatch))
|
||||
{
|
||||
// Allow
|
||||
}
|
||||
else if ((param->mType != checkParam->mType) && (!param->mType->Equals(checkParam->mType)))
|
||||
return false;
|
||||
param = param->mNext;
|
||||
checkParam = checkParam->mNext;
|
||||
paramIdx++;
|
||||
}
|
||||
|
||||
if ((param != NULL) || (checkParam != NULL))
|
||||
|
@ -5111,7 +5120,7 @@ void DbgModule::HotReplaceType(DbgType* newType)
|
|||
|
||||
// If we removed captures then we can still do the hot jump. Otherwise we have to fail...
|
||||
doHotJump = false;
|
||||
if ((oldMethod->IsLambda()) && (oldMethod->GetParamCount() == 0) && (newMethod->GetParamCount() == 0) &&
|
||||
if ((oldMethod->IsLambda()) && (oldMethod->Equals(newMethod, true)) &&
|
||||
(oldMethod->mHasThis) && (newMethod->mHasThis))
|
||||
{
|
||||
auto oldParam = oldMethod->mParams.front();
|
||||
|
@ -5120,7 +5129,9 @@ void DbgModule::HotReplaceType(DbgType* newType)
|
|||
if ((oldParam->mType->IsPointer()) && (newParam->mType->IsPointer()))
|
||||
{
|
||||
auto oldType = oldParam->mType->mTypeParam->GetPrimaryType();
|
||||
oldType->PopulateType();
|
||||
auto newType = newParam->mType->mTypeParam->GetPrimaryType();
|
||||
newType->PopulateType();
|
||||
if ((oldType->IsStruct()) && (newType->IsStruct()))
|
||||
{
|
||||
bool wasMatch = true;
|
||||
|
|
|
@ -428,7 +428,7 @@ public:
|
|||
DbgType* GetParent();
|
||||
DbgType* GetTargetType(); // usually mParentType except for closures
|
||||
DbgLanguage GetLanguage();
|
||||
bool Equals(DbgSubprogram* checkMethod);
|
||||
bool Equals(DbgSubprogram* checkMethod, bool allowThisMismatch = false);
|
||||
int GetParamCount();
|
||||
String GetParamName(int paramIdx);
|
||||
bool IsGenericMethod();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue