This commit is contained in:
nub31
2025-07-03 22:46:20 +02:00
parent 80b98f54a9
commit c2adf1e80f

View File

@@ -649,10 +649,10 @@ public static class QBEGenerator
var result = EmitUnwrap(EmitExpression(ifStatement.Condition)); var result = EmitUnwrap(EmitExpression(ifStatement.Condition));
_writer.Code($"jnz {result}, {trueLabel}, {falseLabel}"); _writer.Code($"jnz {result}, {trueLabel}, {falseLabel}");
_writer.Code(trueLabel); _writer.WriteLine(trueLabel);
EmitBlock(ifStatement.Body); EmitBlock(ifStatement.Body);
_writer.Code($"jmp {endLabel}"); _writer.Code($"jmp {endLabel}");
_writer.Code(falseLabel); _writer.WriteLine(falseLabel);
if (ifStatement.Else.HasValue) if (ifStatement.Else.HasValue)
{ {
ifStatement.Else.Value.Match ifStatement.Else.Value.Match
@@ -662,7 +662,7 @@ public static class QBEGenerator
); );
} }
_writer.Code(endLabel); _writer.WriteLine(endLabel);
} }
private static void EmitReturn(BoundReturnNode @return) private static void EmitReturn(BoundReturnNode @return)
@@ -701,12 +701,12 @@ public static class QBEGenerator
_continueLabels.Push(conditionLabel); _continueLabels.Push(conditionLabel);
_writer.Code($"jmp {conditionLabel}"); _writer.Code($"jmp {conditionLabel}");
_writer.Code(iterationLabel); _writer.WriteLine(iterationLabel);
EmitBlock(whileStatement.Body); EmitBlock(whileStatement.Body);
_writer.Code(conditionLabel); _writer.WriteLine(conditionLabel);
var result = EmitUnwrap(EmitExpression(whileStatement.Condition)); var result = EmitUnwrap(EmitExpression(whileStatement.Condition));
_writer.Code($"jnz {result}, {iterationLabel}, {endLabel}"); _writer.Code($"jnz {result}, {iterationLabel}, {endLabel}");
_writer.Code(endLabel); _writer.WriteLine(endLabel);
_continueLabels.Pop(); _continueLabels.Pop();
_breakLabels.Pop(); _breakLabels.Pop();