MCPcopy Create free account
hub / github.com/beefytech/Beef / NewScopeState

Method NewScopeState

IDEHelper/Compiler/BfModule.cpp:1963–2013  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1961}
1962
1963void BfModule::NewScopeState(bool createLexicalBlock, bool flushValueScope)
1964{
1965 auto curScope = mCurMethodState->mCurScope;
1966 if (curScope->mLabelNode != NULL)
1967 {
1968 curScope->mLabelNode->ToString(curScope->mLabel);
1969
1970 auto rootMethodState = mCurMethodState->GetRootMethodState();
1971 curScope->mScopeLocalId = rootMethodState->mCurLocalVarId++;
1972 auto autoComplete = mCompiler->GetAutoComplete();
1973 if (autoComplete != NULL)
1974 autoComplete->CheckLabel(curScope->mLabelNode, NULL, curScope);
1975 }
1976
1977 if (!mCurMethodState->mCurScope->mLabel.IsEmpty())
1978 {
1979 auto checkScope = mCurMethodState->mCurScope->mPrevScope;
1980 while (checkScope != NULL)
1981 {
1982 if (checkScope->mLabel == mCurMethodState->mCurScope->mLabel)
1983 {
1984 auto errorNode = Warn(0, StrFormat("Duplicate scope label '%s'", checkScope->mLabel.c_str()), curScope->mLabelNode);
1985 if (errorNode != NULL)
1986 mCompiler->mPassInstance->MoreInfo("See previous scope label", checkScope->mLabelNode);
1987 break;
1988 }
1989
1990 checkScope = checkScope->mPrevScope;
1991 }
1992 }
1993
1994 auto prevScope = mCurMethodState->mCurScope->mPrevScope;
1995 if ((flushValueScope) && (prevScope != NULL) && (prevScope->mValueScopeStart))
1996 {
1997 if (prevScope->mHadScopeValueRetain)
1998 mBfIRBuilder->CreateValueScopeSoftEnd(prevScope->mValueScopeStart);
1999 else
2000 mBfIRBuilder->CreateValueScopeHardEnd(prevScope->mValueScopeStart);
2001 }
2002
2003 mCurMethodState->mBlockNestLevel++;
2004 if ((createLexicalBlock) && (mBfIRBuilder->DbgHasInfo()) && (mHasFullDebugInfo))
2005 {
2006 // DIScope could be NULL if we're in an unspecialized method (for example)
2007 if (mCurMethodState->mCurScope->mDIScope)
2008 mCurMethodState->mCurScope->mDIScope = mBfIRBuilder->DbgCreateLexicalBlock(mCurMethodState->mCurScope->mDIScope, mCurFilePosition.mFileInstance->mDIFile, mCurFilePosition.mCurLine, mCurFilePosition.mCurColumn);
2009 }
2010 mCurMethodState->mCurScope->mLocalVarStart = (int)mCurMethodState->mLocals.size();
2011 mCurMethodState->mCurScope->mBlock = mBfIRBuilder->MaybeChainNewBlock((!mCurMethodState->mCurScope->mLabel.empty()) ? mCurMethodState->mCurScope->mLabel : "newScope");
2012 mCurMethodState->mCurScope->mMixinState = mCurMethodState->mMixinState;
2013}
2014
2015void BfModule::RestoreScoreState_LocalVariables(int localVarStart)
2016{

Callers 2

VisitMethod · 0.80
InjectMixinMethod · 0.80

Calls 14

GetRootMethodStateMethod · 0.80
CheckLabelMethod · 0.80
MoreInfoMethod · 0.80
DbgHasInfoMethod · 0.80
DbgCreateLexicalBlockMethod · 0.80
MaybeChainNewBlockMethod · 0.80
ToStringMethod · 0.45
GetAutoCompleteMethod · 0.45
IsEmptyMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected