diff options
author | geno <gabriele.genovese2@studio.unibo.it> | 2024-07-11 14:30:11 +0200 |
---|---|---|
committer | geno <gabriele.genovese2@studio.unibo.it> | 2024-07-11 14:30:11 +0200 |
commit | 57599a42b863cc48050c137de2ec108aa1d59a44 (patch) | |
tree | 243ae356023fe1c2e749e171a865d1c20a261ab8 /src/ast/nodes/RootNode.java | |
parent | b50c7e99603e9f85d82d700d62c16c4fcef88715 (diff) |
feat: clear stack before halt
Diffstat (limited to 'src/ast/nodes/RootNode.java')
-rw-r--r-- | src/ast/nodes/RootNode.java | 7 |
1 files changed, 5 insertions, 2 deletions
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 |