mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-15 06:44:10 +02:00
Merge pull request #1016 from EinBurgbauer/compiler-fix
fix thiscall crash for real
This commit is contained in:
commit
d251ea0e3e
2 changed files with 20 additions and 15 deletions
|
@ -1209,7 +1209,6 @@ void BfMethodInstance::GetIRFunctionInfo(BfModule* module, BfIRType& returnType,
|
||||||
returnType = module->mBfIRBuilder->MapType(mReturnType);
|
returnType = module->mBfIRBuilder->MapType(mReturnType);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hasExplicitThis = false;
|
|
||||||
for (int paramIdx = -1; paramIdx < GetParamCount(); paramIdx++)
|
for (int paramIdx = -1; paramIdx < GetParamCount(); paramIdx++)
|
||||||
{
|
{
|
||||||
BfType* checkType = NULL;
|
BfType* checkType = NULL;
|
||||||
|
@ -1224,24 +1223,15 @@ void BfMethodInstance::GetIRFunctionInfo(BfModule* module, BfIRType& returnType,
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (HasExplicitThis())
|
if (HasExplicitThis())
|
||||||
{
|
|
||||||
checkType = GetParamType(0);
|
checkType = GetParamType(0);
|
||||||
|
|
||||||
//TODO(BCF): Breaks tests
|
|
||||||
//hasExplicitThis = true;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
checkType = GetOwner();
|
checkType = GetOwner();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (hasExplicitThis)
|
if ((paramIdx == 0) && (mMethodDef->mHasExplicitThis))
|
||||||
{
|
continue; // Skip over the explicit 'this'
|
||||||
// We already looked at this
|
|
||||||
hasExplicitThis = false;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
checkType = GetParamType(paramIdx);
|
checkType = GetParamType(paramIdx);
|
||||||
}
|
}
|
||||||
|
@ -1355,9 +1345,6 @@ void BfMethodInstance::GetIRFunctionInfo(BfModule* module, BfIRType& returnType,
|
||||||
|
|
||||||
if (checkType2 != NULL)
|
if (checkType2 != NULL)
|
||||||
_AddType(checkType2);
|
_AddType(checkType2);
|
||||||
|
|
||||||
if ((paramIdx == -1) && (mMethodDef->mHasExplicitThis))
|
|
||||||
paramIdx++; // Skip over the explicit 'this'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((!module->mIsComptimeModule) && (GetStructRetIdx(forceStatic) == 1))
|
if ((!module->mIsComptimeModule) && (GetStructRetIdx(forceStatic) == 1))
|
||||||
|
|
|
@ -130,6 +130,22 @@ namespace Tests
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[CRepr]
|
||||||
|
struct StructCRepr
|
||||||
|
{
|
||||||
|
public int32 something = 1;
|
||||||
|
|
||||||
|
bool Run() => something == 1;
|
||||||
|
|
||||||
|
public static void Test()
|
||||||
|
{
|
||||||
|
StructCRepr sc = .();
|
||||||
|
function bool(StructCRepr this) func = => Run;
|
||||||
|
|
||||||
|
Test.Assert(func(sc));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static int UseFunc0<T>(function int (T this, float f) func, T a, float b)
|
public static int UseFunc0<T>(function int (T this, float f) func, T a, float b)
|
||||||
{
|
{
|
||||||
return func(a, b);
|
return func(a, b);
|
||||||
|
@ -182,6 +198,8 @@ namespace Tests
|
||||||
UseFunc0(func2, sa, 100.0f);
|
UseFunc0(func2, sa, 100.0f);
|
||||||
true
|
true
|
||||||
});
|
});
|
||||||
|
|
||||||
|
StructCRepr.Test();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue