mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-15 06:44:10 +02:00
Fixed early-exit cases in ctor
This commit is contained in:
parent
687dde063f
commit
195a699af4
3 changed files with 33 additions and 3 deletions
|
@ -15635,6 +15635,7 @@ void BfModule::EmitCtorBody(bool& skipBody)
|
||||||
|
|
||||||
bool hadInlineInitBlock = false;
|
bool hadInlineInitBlock = false;
|
||||||
BfScopeData scopeData;
|
BfScopeData scopeData;
|
||||||
|
scopeData.mInInitBlock = true;
|
||||||
|
|
||||||
auto _CheckInitBlock = [&](BfAstNode* node)
|
auto _CheckInitBlock = [&](BfAstNode* node)
|
||||||
{
|
{
|
||||||
|
@ -15686,6 +15687,13 @@ void BfModule::EmitCtorBody(bool& skipBody)
|
||||||
|
|
||||||
hadInlineInitBlock = true;
|
hadInlineInitBlock = true;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Just do a simple one
|
||||||
|
mCurMethodState->AddScope(&scopeData);
|
||||||
|
NewScopeState();
|
||||||
|
hadInlineInitBlock = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateSrcPos(node);
|
UpdateSrcPos(node);
|
||||||
|
@ -15777,10 +15785,19 @@ void BfModule::EmitCtorBody(bool& skipBody)
|
||||||
RestoreScopeState();
|
RestoreScopeState();
|
||||||
// This gets set to false because of AddScope but we actually are still in the head block
|
// This gets set to false because of AddScope but we actually are still in the head block
|
||||||
mCurMethodState->mInHeadScope = true;
|
mCurMethodState->mInHeadScope = true;
|
||||||
|
|
||||||
|
// Make sure we emit a return even if we had a NoReturn call or return inside ourselves
|
||||||
|
mCurMethodState->mHadReturn = false;
|
||||||
|
mCurMethodState->mLeftBlockUncond = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else // Autocomplete case
|
else // Autocomplete case
|
||||||
{
|
{
|
||||||
|
BfScopeData scopeData;
|
||||||
|
scopeData.mInInitBlock = true;
|
||||||
|
mCurMethodState->AddScope(&scopeData);
|
||||||
|
NewScopeState();
|
||||||
|
|
||||||
// The reason we can't just do the 'normal' path for this is that the BfTypeInstance here is NOT the
|
// The reason we can't just do the 'normal' path for this is that the BfTypeInstance here is NOT the
|
||||||
// autocomplete type instance, so FieldInstance initializer values contain expressions from the full
|
// autocomplete type instance, so FieldInstance initializer values contain expressions from the full
|
||||||
// resolve pass, NOT the autocomplete expression
|
// resolve pass, NOT the autocomplete expression
|
||||||
|
@ -15831,6 +15848,8 @@ void BfModule::EmitCtorBody(bool& skipBody)
|
||||||
MarkFieldInitialized(fieldInst);
|
MarkFieldInitialized(fieldInst);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RestoreScopeState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18463,6 +18482,11 @@ void BfModule::ProcessMethod(BfMethodInstance* methodInstance, bool isInlineDup)
|
||||||
if ((methodDef != NULL) && (propertyDeclaration != NULL) && (propertyDeclaration->mExternSpecifier != NULL))
|
if ((methodDef != NULL) && (propertyDeclaration != NULL) && (propertyDeclaration->mExternSpecifier != NULL))
|
||||||
hasExternSpecifier = true;
|
hasExternSpecifier = true;
|
||||||
|
|
||||||
|
if ((methodDef->mMethodType == BfMethodType_CtorNoBody) && (mModuleName == "Atma_Framework_Window"))
|
||||||
|
{
|
||||||
|
NOP;
|
||||||
|
}
|
||||||
|
|
||||||
// Allocate, clear, set classVData
|
// Allocate, clear, set classVData
|
||||||
|
|
||||||
if ((methodDef->mMethodType == BfMethodType_Ctor) && (methodDef->mIsStatic))
|
if ((methodDef->mMethodType == BfMethodType_Ctor) && (methodDef->mIsStatic))
|
||||||
|
|
|
@ -403,6 +403,7 @@ public:
|
||||||
bool mHadScopeValueRetain;
|
bool mHadScopeValueRetain;
|
||||||
bool mIsDeferredBlock;
|
bool mIsDeferredBlock;
|
||||||
bool mAllowVariableDeclarations;
|
bool mAllowVariableDeclarations;
|
||||||
|
bool mInInitBlock;
|
||||||
BfBlock* mAstBlock;
|
BfBlock* mAstBlock;
|
||||||
BfAstNode* mCloseNode;
|
BfAstNode* mCloseNode;
|
||||||
BfExprEvaluator* mExprEvaluator;
|
BfExprEvaluator* mExprEvaluator;
|
||||||
|
@ -438,6 +439,7 @@ public:
|
||||||
mIsDeferredBlock = false;
|
mIsDeferredBlock = false;
|
||||||
mAllowTargeting = true;
|
mAllowTargeting = true;
|
||||||
mAllowVariableDeclarations = true;
|
mAllowVariableDeclarations = true;
|
||||||
|
mInInitBlock = false;
|
||||||
mMixinDepth = 0;
|
mMixinDepth = 0;
|
||||||
mScopeDepth = 0;
|
mScopeDepth = 0;
|
||||||
mScopeLocalId = -1;
|
mScopeLocalId = -1;
|
||||||
|
|
|
@ -4891,6 +4891,10 @@ void BfModule::Visit(BfReturnStatement* returnStmt)
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (checkScope->mInInitBlock)
|
||||||
|
{
|
||||||
|
Fail("Initialization blocks cannot contain 'return' statements", returnStmt);
|
||||||
|
}
|
||||||
checkScope = checkScope->mPrevScope;
|
checkScope = checkScope->mPrevScope;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue