mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 03:28:20 +02:00
Better handling of let/var field failures
This commit is contained in:
parent
624e36b89b
commit
b63b4af6fe
5 changed files with 59 additions and 8 deletions
|
@ -1264,11 +1264,24 @@ void BeIRCodeGen::HandleNextCmd()
|
|||
break;
|
||||
}
|
||||
|
||||
BF_ASSERT(type->mTypeCode == BeTypeCode_Struct);
|
||||
auto structType = (BeStructType*)type;
|
||||
mBeContext->SetStructBody(structType, members, isPacked);
|
||||
structType->mSize = instSize;
|
||||
structType->mAlign = instAlign;
|
||||
bool failed = false;
|
||||
for (auto member : members)
|
||||
{
|
||||
if (member->mSize < 0)
|
||||
{
|
||||
Fail("StructSetBody invalid member type");
|
||||
failed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!failed)
|
||||
{
|
||||
BF_ASSERT(type->mTypeCode == BeTypeCode_Struct);
|
||||
auto structType = (BeStructType*)type;
|
||||
mBeContext->SetStructBody(structType, members, isPacked);
|
||||
structType->mSize = instSize;
|
||||
structType->mAlign = instAlign;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case BfIRCmd_Type:
|
||||
|
@ -3725,6 +3738,18 @@ void BeIRCodeGen::SetConfigConst(int idx, int value)
|
|||
mConfigConsts.Add(value);
|
||||
}
|
||||
|
||||
BeValue* BeIRCodeGen::TryGetBeValue(int id)
|
||||
{
|
||||
auto& result = mResults[id];
|
||||
if (result.mKind != BeIRCodeGenEntryKind_Value)
|
||||
return NULL;
|
||||
#ifdef BE_EXTRA_CHECKS
|
||||
BF_ASSERT(!result.mBeValue->mLifetimeEnded);
|
||||
BF_ASSERT(!result.mBeValue->mWasRemoved);
|
||||
#endif
|
||||
return result.mBeValue;
|
||||
}
|
||||
|
||||
BeValue* BeIRCodeGen::GetBeValue(int id)
|
||||
{
|
||||
auto& result = mResults[id];
|
||||
|
|
|
@ -150,6 +150,7 @@ public:
|
|||
virtual void SetConfigConst(int idx, int value) override;
|
||||
|
||||
BeValue* GetBeValue(int streamId);
|
||||
BeValue* TryGetBeValue(int streamId);
|
||||
BeType* GetBeType(int streamId);
|
||||
BeBlock* GetBeBlock(int streamId);
|
||||
BeMDNode* GetBeMetadata(int streamId);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue