...
This commit is contained in:
@@ -168,7 +168,7 @@ public class LlvmSharpGenerator
|
||||
EmitContinue();
|
||||
break;
|
||||
case DeferNode deferNode:
|
||||
CurrentScope.Defer(() => EmitStatement(deferNode.Statement));
|
||||
CurrentScope.DeferredActions.Push(() => EmitStatement(deferNode.Statement));
|
||||
break;
|
||||
case ForConstArrayNode forConstArrayNode:
|
||||
throw new NotImplementedException();
|
||||
@@ -201,12 +201,14 @@ public class LlvmSharpGenerator
|
||||
_builder.BuildStore(value, targetPtr);
|
||||
}
|
||||
|
||||
// todo(nub31): Needs to call EmitScopeExit. However, the jump might span multiple scopes, so we must handle that
|
||||
private void EmitBreak()
|
||||
{
|
||||
var (breakBlock, _) = _loopStack.Peek();
|
||||
_builder.BuildBr(breakBlock);
|
||||
}
|
||||
|
||||
// todo(nub31): Needs to call EmitScopeExit. However, the jump might span multiple scopes, so we must handle that
|
||||
private void EmitContinue()
|
||||
{
|
||||
var (_, continueBlock) = _loopStack.Peek();
|
||||
@@ -766,8 +768,7 @@ public class LlvmSharpGenerator
|
||||
|
||||
private void EmitScopeExit()
|
||||
{
|
||||
var deferredActions = CurrentScope.GetDeferredActions();
|
||||
while (deferredActions.TryPop(out var action))
|
||||
while (CurrentScope.DeferredActions.TryPop(out var action))
|
||||
{
|
||||
action.Invoke();
|
||||
}
|
||||
@@ -775,16 +776,6 @@ public class LlvmSharpGenerator
|
||||
|
||||
private class Scope
|
||||
{
|
||||
private readonly Stack<Action> _deferredActions = [];
|
||||
|
||||
public Stack<Action> GetDeferredActions()
|
||||
{
|
||||
return _deferredActions;
|
||||
}
|
||||
|
||||
public void Defer(Action action)
|
||||
{
|
||||
_deferredActions.Push(action);
|
||||
}
|
||||
public readonly Stack<Action> DeferredActions = [];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user