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