mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 19:48:20 +02:00
Added ability to rename labels and goto definition on labels
This commit is contained in:
parent
a7e9182d4b
commit
c9da45715b
6 changed files with 86 additions and 29 deletions
|
@ -4950,13 +4950,7 @@ void BfModule::Visit(BfYieldStatement* yieldStmt)
|
|||
void BfModule::Visit(BfBreakStatement* breakStmt)
|
||||
{
|
||||
bool inMixinDecl = (mCurMethodInstance != NULL) && (mCurMethodInstance->IsMixin());
|
||||
|
||||
if ((mCompiler->mResolvePassData != NULL) && (mCompiler->mResolvePassData->mAutoComplete != NULL))
|
||||
{
|
||||
if (auto identifer = BfNodeDynCast<BfIdentifierNode>(breakStmt->mLabel))
|
||||
mCompiler->mResolvePassData->mAutoComplete->CheckLabel(identifer, breakStmt->mBreakNode);
|
||||
}
|
||||
|
||||
|
||||
UpdateSrcPos(breakStmt);
|
||||
mBfIRBuilder->CreateEnsureInstructionAt();
|
||||
|
||||
|
@ -4975,6 +4969,15 @@ void BfModule::Visit(BfBreakStatement* breakStmt)
|
|||
}
|
||||
}
|
||||
|
||||
if ((mCompiler->mResolvePassData != NULL) && (mCompiler->mResolvePassData->mAutoComplete != NULL))
|
||||
{
|
||||
BfScopeData* scope = NULL;
|
||||
if (breakData != NULL)
|
||||
scope = breakData->mScope;
|
||||
if (auto identifer = BfNodeDynCast<BfIdentifierNode>(breakStmt->mLabel))
|
||||
mCompiler->mResolvePassData->mAutoComplete->CheckLabel(identifer, breakStmt->mBreakNode, scope);
|
||||
}
|
||||
|
||||
if ((breakData == NULL) || (!breakData->mIRBreakBlock))
|
||||
{
|
||||
if (inMixinDecl)
|
||||
|
@ -5038,13 +5041,7 @@ void BfModule::Visit(BfBreakStatement* breakStmt)
|
|||
void BfModule::Visit(BfContinueStatement* continueStmt)
|
||||
{
|
||||
bool inMixinDecl = (mCurMethodInstance != NULL) && (mCurMethodInstance->IsMixin());
|
||||
|
||||
if ((mCompiler->mResolvePassData != NULL) && (mCompiler->mResolvePassData->mAutoComplete != NULL))
|
||||
{
|
||||
if (auto identifer = BfNodeDynCast<BfIdentifierNode>(continueStmt->mLabel))
|
||||
mCompiler->mResolvePassData->mAutoComplete->CheckLabel(identifer, continueStmt->mContinueNode);
|
||||
}
|
||||
|
||||
|
||||
UpdateSrcPos(continueStmt);
|
||||
mBfIRBuilder->CreateEnsureInstructionAt();
|
||||
|
||||
|
@ -5069,6 +5066,15 @@ void BfModule::Visit(BfContinueStatement* continueStmt)
|
|||
}
|
||||
}
|
||||
|
||||
if ((mCompiler->mResolvePassData != NULL) && (mCompiler->mResolvePassData->mAutoComplete != NULL))
|
||||
{
|
||||
BfScopeData* scope = NULL;
|
||||
if (breakData != NULL)
|
||||
scope = breakData->mScope;
|
||||
if (auto identifer = BfNodeDynCast<BfIdentifierNode>(continueStmt->mLabel))
|
||||
mCompiler->mResolvePassData->mAutoComplete->CheckLabel(identifer, continueStmt->mContinueNode, scope);
|
||||
}
|
||||
|
||||
if ((breakData == NULL) || (!breakData->mIRContinueBlock))
|
||||
{
|
||||
if (inMixinDecl)
|
||||
|
@ -6489,14 +6495,7 @@ void BfModule::Visit(BfDeferStatement* deferStmt)
|
|||
|
||||
UpdateSrcPos(deferStmt);
|
||||
EmitEnsureInstructionAt();
|
||||
|
||||
if ((mCompiler->mResolvePassData != NULL) && (mCompiler->mResolvePassData->mAutoComplete != NULL))
|
||||
{
|
||||
auto targetIdentifier = BfNodeDynCast<BfIdentifierNode>(deferStmt->mScopeName);
|
||||
if ((deferStmt->mScopeName == NULL) || (targetIdentifier != NULL))
|
||||
mCompiler->mResolvePassData->mAutoComplete->CheckLabel(targetIdentifier, deferStmt->mColonToken);
|
||||
}
|
||||
|
||||
|
||||
BfScopeData* scope = NULL;
|
||||
|
||||
if (deferStmt->mScopeToken != NULL)
|
||||
|
@ -6511,6 +6510,13 @@ void BfModule::Visit(BfDeferStatement* deferStmt)
|
|||
else
|
||||
scope = mCurMethodState->mCurScope;
|
||||
|
||||
if ((mCompiler->mResolvePassData != NULL) && (mCompiler->mResolvePassData->mAutoComplete != NULL))
|
||||
{
|
||||
auto targetIdentifier = BfNodeDynCast<BfIdentifierNode>(deferStmt->mScopeName);
|
||||
if ((deferStmt->mScopeName == NULL) || (targetIdentifier != NULL))
|
||||
mCompiler->mResolvePassData->mAutoComplete->CheckLabel(targetIdentifier, deferStmt->mColonToken, scope);
|
||||
}
|
||||
|
||||
if ((scope == mCurMethodState->mCurScope) && (scope->mCloseNode == NULL))
|
||||
{
|
||||
Warn(0, "This defer will immediately execute. Consider specifying a wider scope target such as 'defer::'", deferStmt->mDeferToken);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue