1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-08 19:48:20 +02:00

Fixed local methods in methods with out parameters

This commit is contained in:
Brian Fiete 2020-09-07 06:45:56 -07:00
parent 03c28503c6
commit f868d56abb

View file

@ -2077,7 +2077,7 @@ void BfModule::LocalVariableDone(BfLocalVariable* localVar, bool isMethodExit)
//bool deferFullAnalysis = true; //bool deferFullAnalysis = true;
bool deferUsageWarning = deferFullAnalysis && mCompiler->IsAutocomplete(); bool deferUsageWarning = deferFullAnalysis && mCompiler->IsAutocomplete();
if (!localVar->mIsAssigned) if ((!localVar->mIsAssigned) && (!localVar->mIsImplicitParam))
{ {
if (deferUsageWarning) if (deferUsageWarning)
{ {
@ -19250,7 +19250,7 @@ BfModuleMethodInstance BfModule::GetLocalMethodInstance(BfLocalMethod* localMeth
SetAndRestoreValue<bool> ignoreError(mIgnoreErrors, true); SetAndRestoreValue<bool> ignoreError(mIgnoreErrors, true);
*/ */
SetAndRestoreValue<BfMethodInstance*> prevMethodInstance(mCurMethodInstance, methodInstance); SetAndRestoreValue<BfMethodInstance*> prevMethodInstance(mCurMethodInstance, methodInstance);
//SetAndRestoreValue<bool> wantsIgnoreWrites(mWantsISIgnoreWrites, true); //SetAndRestoreValue<bool> wantsIgnoreWrites(mWantsISIgnoreWrites, true);
mBfIRBuilder->SaveDebugLocation(); mBfIRBuilder->SaveDebugLocation();
closureState.mCaptureVisitingBody = true; closureState.mCaptureVisitingBody = true;
@ -19271,11 +19271,16 @@ BfModuleMethodInstance BfModule::GetLocalMethodInstance(BfLocalMethod* localMeth
localDef->mAddr = CreateAlloca(localDef->mResolvedType); localDef->mAddr = CreateAlloca(localDef->mResolvedType);
} }
} }
// Keep outs for being marked as assigned
auto rootMethodState = mCurMethodState->GetRootMethodState();
BfDeferredLocalAssignData deferredLocalAssignData(rootMethodState->mCurScope);
deferredLocalAssignData.mVarIdBarrier = rootMethodState->mCurLocalVarId;
SetAndRestoreValue<BfDeferredLocalAssignData*> prevDLA(rootMethodState->mDeferredLocalAssignData, &deferredLocalAssignData);
_VisitLambdaBody(); _VisitLambdaBody();
RestoreScopeState(); RestoreScopeState();
//ProcessMethod(methodInstance);
closureState.mCaptureVisitingBody = false; closureState.mCaptureVisitingBody = false;
mBfIRBuilder->RestoreDebugLocation(); mBfIRBuilder->RestoreDebugLocation();
} }
@ -19288,8 +19293,6 @@ BfModuleMethodInstance BfModule::GetLocalMethodInstance(BfLocalMethod* localMeth
prevClosureState->mCaptureStartAccessId = closureState.mCaptureStartAccessId; prevClosureState->mCaptureStartAccessId = closureState.mCaptureStartAccessId;
} }
//RestoreScopeState();
// Actually get the referenced local methods. It's important we wait until after visiting the body, because then our own capture information // Actually get the referenced local methods. It's important we wait until after visiting the body, because then our own capture information
// can be used by these methods (which will be necessary if any of these methods call us directly or indirectly) // can be used by these methods (which will be necessary if any of these methods call us directly or indirectly)
closureState.mClosureMethodDef = NULL; closureState.mClosureMethodDef = NULL;