1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-08 11:38:21 +02:00

Handle zero-sized enums (<= 1 member)

This commit is contained in:
Brian Fiete 2024-11-08 09:16:27 -05:00
parent 7b69509b7b
commit 14a3dd8e7d
21 changed files with 461 additions and 135 deletions

View file

@ -21841,10 +21841,10 @@ void BfModule::ProcessMethod(BfMethodInstance* methodInstance, bool isInlineDup,
mBfIRBuilder->SaveDebugLocation();
mBfIRBuilder->ClearDebugLocation();
BfIRValue fromBool;
if (!mCurTypeInstance->IsTypedPrimitive())
if ((!mCurTypeInstance->IsTypedPrimitive()) || (mCurTypeInstance->IsValuelessType()))
{
fromBool = GetDefaultValue(methodInstance->mReturnType);
}
}
else
{
auto andResult = mBfIRBuilder->CreateAnd(mCurMethodState->mLocals[0]->mValue, mCurMethodState->mLocals[1]->mValue);
@ -21872,7 +21872,10 @@ void BfModule::ProcessMethod(BfMethodInstance* methodInstance, bool isInlineDup,
mBfIRBuilder->ClearDebugLocation();
BfIRValue fromBool;
mBfIRBuilder->RestoreDebugLocation();
ret = mBfIRBuilder->CreateRet(GetThis().mValue);
if (!mCurTypeInstance->IsValuelessType())
ret = mBfIRBuilder->CreateRet(GetThis().mValue);
else
mBfIRBuilder->CreateRetVoid();
//ExtendLocalLifetimes(0);
EmitLifetimeEnds(&mCurMethodState->mHeadScope);