This commit is contained in:
nub31
2025-09-20 19:59:48 +02:00
parent f6c686a635
commit 511f0d27ee
3 changed files with 25 additions and 63 deletions

View File

@@ -498,6 +498,9 @@ public class QBEGenerator
EmitScopeCleanup();
_writer.Indented($"jmp {_continueLabels.Peek()}");
break;
case DeferNode defer:
Scope.Defers.Push(defer);
break;
case IfNode ifStatement:
EmitIf(ifStatement);
break;
@@ -523,6 +526,11 @@ public class QBEGenerator
private void EmitScopeCleanup()
{
while (Scope.Defers.TryPop(out var defer))
{
EmitStatement(defer.Statement);
}
while (Scope.Variables.TryPop(out var variable))
{
if (variable.Type is NubStructType structType)
@@ -1283,6 +1291,7 @@ public class QBEGenerator
public class Scope
{
public readonly Stack<Variable> Variables = [];
public readonly Stack<DeferNode> Defers = [];
}
public record Variable(string Name, NubType Type);