mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 04:22:20 +02:00
Fixed scope issue for scope-allocated value as switch value
This commit is contained in:
parent
c5380ddb5e
commit
97fd278e07
1 changed files with 18 additions and 9 deletions
|
@ -4078,16 +4078,16 @@ void BfModule::Visit(BfDeleteStatement* deleteStmt)
|
|||
}
|
||||
|
||||
void BfModule::Visit(BfSwitchStatement* switchStmt)
|
||||
{
|
||||
BfScopeData newScope;
|
||||
newScope.mInnerIsConditional = false;
|
||||
newScope.mCloseNode = switchStmt;
|
||||
{
|
||||
BfScopeData outerScope;
|
||||
outerScope.mInnerIsConditional = false;
|
||||
outerScope.mCloseNode = switchStmt;
|
||||
if (switchStmt->mCloseBrace != NULL)
|
||||
newScope.mCloseNode = switchStmt->mCloseBrace;
|
||||
outerScope.mCloseNode = switchStmt->mCloseBrace;
|
||||
if (switchStmt->mLabelNode != NULL)
|
||||
newScope.mLabelNode = switchStmt->mLabelNode->mLabel;
|
||||
mCurMethodState->AddScope(&newScope);
|
||||
NewScopeState();
|
||||
outerScope.mLabelNode = switchStmt->mLabelNode->mLabel;
|
||||
mCurMethodState->AddScope(&outerScope);
|
||||
NewScopeState();
|
||||
|
||||
auto valueScopeStartOuter = ValueScopeStart();
|
||||
|
||||
|
@ -4124,7 +4124,15 @@ void BfModule::Visit(BfSwitchStatement* switchStmt)
|
|||
}
|
||||
|
||||
// We make the switch value conditional, but all other uses of this scope is conditional since it's conditional on cases
|
||||
BfScopeData newScope;
|
||||
newScope.mInnerIsConditional = true;
|
||||
newScope.mCloseNode = switchStmt;
|
||||
if (switchStmt->mCloseBrace != NULL)
|
||||
newScope.mCloseNode = switchStmt->mCloseBrace;
|
||||
if (switchStmt->mLabelNode != NULL)
|
||||
newScope.mLabelNode = switchStmt->mLabelNode->mLabel;
|
||||
mCurMethodState->AddScope(&newScope);
|
||||
NewScopeState();
|
||||
|
||||
BfTypedValue switchValueAddr = switchValue;
|
||||
|
||||
|
@ -4869,7 +4877,8 @@ void BfModule::Visit(BfSwitchStatement* switchStmt)
|
|||
lifetimeExtendVal = localDef->mValue;
|
||||
}
|
||||
|
||||
RestoreScopeState();
|
||||
RestoreScopeState(); // newScope
|
||||
RestoreScopeState(); // outerScope
|
||||
|
||||
if (lifetimeExtendVal)
|
||||
mBfIRBuilder->CreateLifetimeExtend(lifetimeExtendVal);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue