From 57599a42b863cc48050c137de2ec108aa1d59a44 Mon Sep 17 00:00:00 2001 From: geno Date: Thu, 11 Jul 2024 14:30:11 +0200 Subject: feat: clear stack before halt --- src/ast/nodes/RootNode.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/ast/nodes/RootNode.java') diff --git a/src/ast/nodes/RootNode.java b/src/ast/nodes/RootNode.java index 9cad871..2c99164 100644 --- a/src/ast/nodes/RootNode.java +++ b/src/ast/nodes/RootNode.java @@ -2,7 +2,6 @@ package ast.nodes; import ast.types.*; import codegen.Label; - import java.util.ArrayList; import java.util.HashMap; import semanticanalysis.*; @@ -55,7 +54,11 @@ public class RootNode implements Node { str += child.codeGeneration(); } - return str + "halt\n" + Label.getFunDef(); + for (int i = 0; i < Label.getGlobalVarNum(); i++) { + str += "pop\n"; + } + + return str + "pop\npop\nhalt\n" + Label.getFunDef(); } @Override -- cgit v1.2.3-18-g5258