mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 11:38:21 +02:00
Fixed properties debug evaluation and struct calls
This commit is contained in:
parent
a399e383fa
commit
c28ed988b3
7 changed files with 195 additions and 13 deletions
13
IDE/Tests/Test1/scripts/Properties.txt
Normal file
13
IDE/Tests/Test1/scripts/Properties.txt
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
ShowFile("src/Properties.bf")
|
||||||
|
GotoText("//Test_Break")
|
||||||
|
ToggleBreakpoint()
|
||||||
|
RunWithCompiling()
|
||||||
|
|
||||||
|
AssertEvalEquals("sb_a0", "{ mA=1100 mB=2101 }")
|
||||||
|
AssertEvalEquals("sb_a1", "{ mA=2100 mB=3101 }")
|
||||||
|
AssertEvalEquals("sc_a0", "{ mA=4200 mB=5201 }")
|
||||||
|
AssertEvalEquals("sc_a1", "{ mA=6200 mB=7201 }")
|
||||||
|
AssertEvalEquals("sc_b0", "{ mA=4200 mB=5201 mC=6202 }")
|
||||||
|
AssertEvalEquals("sc_b1", "{ mA=7200 mB=8201 mC=9202 }")
|
||||||
|
AssertEvalEquals("sc_c0", "{ mA=10200 mB=11201 mC=12202 mD=13203 }")
|
||||||
|
AssertEvalEquals("sc_c1", "{ mA=14200 mB=15201 mC=16202 mD=17203 }")
|
|
@ -26,6 +26,7 @@ namespace IDETest
|
||||||
Multithread.Test();
|
Multithread.Test();
|
||||||
Multithread02.Test();
|
Multithread02.Test();
|
||||||
MemoryBreakpointTester.Test();
|
MemoryBreakpointTester.Test();
|
||||||
|
Properties.Test();
|
||||||
SplatTester.Test();
|
SplatTester.Test();
|
||||||
Stepping_Scope.Test();
|
Stepping_Scope.Test();
|
||||||
TypedPrimitives.Test();
|
TypedPrimitives.Test();
|
||||||
|
|
147
IDE/Tests/Test1/src/Properties.bf
Normal file
147
IDE/Tests/Test1/src/Properties.bf
Normal file
|
@ -0,0 +1,147 @@
|
||||||
|
#pragma warning disable 168
|
||||||
|
|
||||||
|
namespace IDETest
|
||||||
|
{
|
||||||
|
class Properties
|
||||||
|
{
|
||||||
|
struct StructA
|
||||||
|
{
|
||||||
|
public float mA;
|
||||||
|
public float mB;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct StructB
|
||||||
|
{
|
||||||
|
public float mA;
|
||||||
|
public float mB;
|
||||||
|
public float mC;
|
||||||
|
|
||||||
|
public StructA A0
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
StructA sa;
|
||||||
|
sa.mA = mA + 1000;
|
||||||
|
sa.mB = mB + 2000;
|
||||||
|
return sa;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public StructA A1
|
||||||
|
{
|
||||||
|
get mut
|
||||||
|
{
|
||||||
|
StructA sa;
|
||||||
|
sa.mA = mA + 2000;
|
||||||
|
sa.mB = mB + 3000;
|
||||||
|
return sa;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct StructC
|
||||||
|
{
|
||||||
|
public float mA;
|
||||||
|
public float mB;
|
||||||
|
public float mC;
|
||||||
|
public float mD;
|
||||||
|
|
||||||
|
public StructA A0
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
StructA sa;
|
||||||
|
sa.mA = mA + 4000;
|
||||||
|
sa.mB = mB + 5000;
|
||||||
|
return sa;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public StructA A1
|
||||||
|
{
|
||||||
|
get mut
|
||||||
|
{
|
||||||
|
StructA sa;
|
||||||
|
sa.mA = mA + 6000;
|
||||||
|
sa.mB = mB + 7000;
|
||||||
|
return sa;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public StructB B0
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
StructB sb;
|
||||||
|
sb.mA = mA + 4000;
|
||||||
|
sb.mB = mB + 5000;
|
||||||
|
sb.mC = mC + 6000;
|
||||||
|
return sb;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public StructB B1
|
||||||
|
{
|
||||||
|
get mut
|
||||||
|
{
|
||||||
|
StructB sb;
|
||||||
|
sb.mA = mA + 7000;
|
||||||
|
sb.mB = mB + 8000;
|
||||||
|
sb.mC = mC + 9000;
|
||||||
|
return sb;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public StructC C0
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
StructC sc;
|
||||||
|
sc.mA = mA + 10000;
|
||||||
|
sc.mB = mB + 11000;
|
||||||
|
sc.mC = mC + 12000;
|
||||||
|
sc.mD = mD + 13000;
|
||||||
|
return sc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public StructC C1
|
||||||
|
{
|
||||||
|
get mut
|
||||||
|
{
|
||||||
|
StructC sc;
|
||||||
|
sc.mA = mA + 14000;
|
||||||
|
sc.mB = mB + 15000;
|
||||||
|
sc.mC = mC + 16000;
|
||||||
|
sc.mD = mD + 17000;
|
||||||
|
return sc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Test()
|
||||||
|
{
|
||||||
|
StructB sb = .();
|
||||||
|
sb.mA = 100;
|
||||||
|
sb.mB = 101;
|
||||||
|
sb.mC = 102;
|
||||||
|
var sb_a0 = sb.A0;
|
||||||
|
var sb_a1 = sb.A1;
|
||||||
|
|
||||||
|
StructC sc = .();
|
||||||
|
sc.mA = 200;
|
||||||
|
sc.mB = 201;
|
||||||
|
sc.mC = 202;
|
||||||
|
sc.mD = 203;
|
||||||
|
var sc_a0 = sc.A0;
|
||||||
|
var sc_a1 = sc.A1;
|
||||||
|
var sc_b0 = sc.B0;
|
||||||
|
var sc_b1 = sc.B1;
|
||||||
|
var sc_c0 = sc.C0;
|
||||||
|
var sc_c1 = sc.C1;
|
||||||
|
|
||||||
|
//Test_Break
|
||||||
|
int a = 123;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -16,7 +16,7 @@ class Bug002
|
||||||
|
|
||||||
public static void Test()
|
public static void Test()
|
||||||
{
|
{
|
||||||
var strs = scope String[] {"aaa", "bbb", "ccc"};
|
var strs = scope String[] ("aaa", "bbb", "ccc");
|
||||||
//Bug002_DoTest
|
//Bug002_DoTest
|
||||||
Parse(strs);
|
Parse(strs);
|
||||||
};
|
};
|
||||||
|
|
|
@ -16291,6 +16291,9 @@ void BfModule::ProcessMethod_SetupParams(BfMethodInstance* methodInstance, BfTyp
|
||||||
auto diType = mBfIRBuilder->DbgGetType(thisPtrType);
|
auto diType = mBfIRBuilder->DbgGetType(thisPtrType);
|
||||||
if (!thisType->IsValueType())
|
if (!thisType->IsValueType())
|
||||||
diType = mBfIRBuilder->DbgCreateArtificialType(diType);
|
diType = mBfIRBuilder->DbgCreateArtificialType(diType);
|
||||||
|
else if (!paramVar->mIsSplat)
|
||||||
|
diType = mBfIRBuilder->DbgCreatePointerType(diType);
|
||||||
|
|
||||||
diParams->push_back(diType);
|
diParams->push_back(diType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -690,10 +690,10 @@ int BfMethodInstance::GetStructRetIdx(bool forceStatic)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if ((!HasThis()) || (forceStatic))
|
if ((!HasThis()) || (forceStatic))
|
||||||
return 0;
|
return 0;
|
||||||
if (!owner->IsValueType())
|
if (!owner->IsValueType())
|
||||||
return 1;
|
return 1;
|
||||||
if ((mMethodDef->mIsMutating) || ((!AllowsSplatting()) && (!owner->GetLoweredType(BfTypeUsage_Parameter))))
|
if ((mMethodDef->mIsMutating) || (!owner->IsSplattable()) || ((!AllowsThisSplatting()) && (!owner->GetLoweredType(BfTypeUsage_Parameter))))
|
||||||
return 1;
|
return 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2766,7 +2766,7 @@ DbgTypedValue DbgExprEvaluator::DoLookupField(BfAstNode* targetSrc, DbgTypedValu
|
||||||
for (int pass = 0; pass < 2; pass++)
|
for (int pass = 0; pass < 2; pass++)
|
||||||
{
|
{
|
||||||
for (auto method : curCheckType->mMethodList)
|
for (auto method : curCheckType->mMethodList)
|
||||||
{
|
{
|
||||||
if (method->mName != NULL)
|
if (method->mName != NULL)
|
||||||
{
|
{
|
||||||
if (((method->mName[0] == 'g') || (method->mName[0] == 's')) &&
|
if (((method->mName[0] == 'g') || (method->mName[0] == 's')) &&
|
||||||
|
@ -2788,15 +2788,17 @@ DbgTypedValue DbgExprEvaluator::DoLookupField(BfAstNode* targetSrc, DbgTypedValu
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (((!method->mHasThis) && (wantsStatic)) ||
|
DbgSubprogram*& subprogramRef = isGetter ? mPropGet : mPropSet;
|
||||||
|
|
||||||
|
if ((subprogramRef == NULL) ||
|
||||||
|
((!method->mHasThis) && (wantsStatic)) ||
|
||||||
((method->mHasThis) && (!wantsStatic || allowImplicitThis)))
|
((method->mHasThis) && (!wantsStatic || allowImplicitThis)))
|
||||||
{
|
{
|
||||||
if ((method->mHasThis) && (allowImplicitThis) && (!target))
|
if ((method->mHasThis) && (allowImplicitThis) && (!target))
|
||||||
{
|
{
|
||||||
target = GetThis();
|
target = GetThis();
|
||||||
}
|
}
|
||||||
|
|
||||||
DbgSubprogram*& subprogramRef = isGetter ? mPropGet : mPropSet;
|
|
||||||
if (subprogramRef == NULL)
|
if (subprogramRef == NULL)
|
||||||
subprogramRef = method;
|
subprogramRef = method;
|
||||||
else if ((method->mVTableLoc != -1) || (subprogramRef->mVTableLoc == -1))
|
else if ((method->mVTableLoc != -1) || (subprogramRef->mVTableLoc == -1))
|
||||||
|
@ -6918,19 +6920,27 @@ DbgTypedValue DbgExprEvaluator::CreateCall(BfAstNode* targetSrc, DbgTypedValue t
|
||||||
argPushQueue.push_back(methodArg);
|
argPushQueue.push_back(methodArg);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool thisByValue = false;
|
||||||
int methodParamCount = method->mParams.Size();
|
int methodParamCount = method->mParams.Size();
|
||||||
|
if (methodParamCount > 0)
|
||||||
|
{
|
||||||
|
method->mParams;
|
||||||
|
}
|
||||||
|
|
||||||
if (method->mHasThis)
|
if (method->mHasThis)
|
||||||
{
|
{
|
||||||
auto param = method->mParams[paramIdx];
|
auto param = method->mParams[paramIdx];
|
||||||
|
if ((param->mType != NULL) && (param->mType->IsValueType()))
|
||||||
|
thisByValue = true;
|
||||||
|
|
||||||
if (!target)
|
if (!target)
|
||||||
{
|
{
|
||||||
Fail(StrFormat("An object reference is required to invoke the non-static method '%s'", method->ToString().c_str()), targetSrc);
|
Fail(StrFormat("An object reference is required to invoke the non-static method '%s'", method->ToString().c_str()), targetSrc);
|
||||||
return DbgTypedValue();
|
return DbgTypedValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
_PushArg(target, param);
|
_PushArg(target, param);
|
||||||
methodParamCount--;
|
methodParamCount--;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -7143,7 +7153,7 @@ DbgTypedValue DbgExprEvaluator::CreateCall(BfAstNode* targetSrc, DbgTypedValue t
|
||||||
paramIdx++;
|
paramIdx++;
|
||||||
}
|
}
|
||||||
argIdx++;
|
argIdx++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return CreateCall(method, argPushQueue, bypassVirtual);
|
return CreateCall(method, argPushQueue, bypassVirtual);
|
||||||
}
|
}
|
||||||
|
@ -7173,6 +7183,14 @@ DbgTypedValue DbgExprEvaluator::CreateCall(DbgSubprogram* method, SizedArrayImpl
|
||||||
if (method->mHasThis)
|
if (method->mHasThis)
|
||||||
paramIdx--;
|
paramIdx--;
|
||||||
|
|
||||||
|
bool thisByValue = false;
|
||||||
|
if ((method->mHasThis) && (!method->mParams.IsEmpty()))
|
||||||
|
{
|
||||||
|
auto param = method->mParams[0];
|
||||||
|
if ((param->mType != NULL) && (param->mType->IsValueType()))
|
||||||
|
thisByValue = true;
|
||||||
|
}
|
||||||
|
|
||||||
DbgTypedValue compositeRetVal;
|
DbgTypedValue compositeRetVal;
|
||||||
if (mDebugger->CheckNeedsSRetArgument(method->mReturnType))
|
if (mDebugger->CheckNeedsSRetArgument(method->mReturnType))
|
||||||
{
|
{
|
||||||
|
@ -7211,7 +7229,7 @@ DbgTypedValue DbgExprEvaluator::CreateCall(DbgSubprogram* method, SizedArrayImpl
|
||||||
|
|
||||||
if (compositeRetVal.mSrcAddress != 0)
|
if (compositeRetVal.mSrcAddress != 0)
|
||||||
{
|
{
|
||||||
mDebugger->AddParamValue(0, method->mHasThis, ®isters, compositeRetVal);
|
mDebugger->AddParamValue(0, method->mHasThis && !thisByValue, ®isters, compositeRetVal);
|
||||||
paramIdx++;
|
paramIdx++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue