From ce49d20a5fe3726e1800bc495a25c7617212abf4 Mon Sep 17 00:00:00 2001 From: Emanuele Grasso <96300448+L0P0P@users.noreply.github.com> Date: Sun, 14 Jul 2024 18:48:09 +0200 Subject: Reaching definition analysis (#17) Co-authored-by: Santo Cariotti Co-authored-by: geno Co-authored-by: geno --- src/ast/nodes/RootNode.java | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'src/ast/nodes/RootNode.java') diff --git a/src/ast/nodes/RootNode.java b/src/ast/nodes/RootNode.java index 2c99164..ebb786a 100644 --- a/src/ast/nodes/RootNode.java +++ b/src/ast/nodes/RootNode.java @@ -54,7 +54,7 @@ public class RootNode implements Node { str += child.codeGeneration(); } - for (int i = 0; i < Label.getGlobalVarNum(); i++) { + for (int i = 0; i < Label.getGlobalVarNum() - 1; i++) { str += "pop\n"; } @@ -62,16 +62,32 @@ public class RootNode implements Node { } @Override - public String toPrint(String prefix) { + public String printAST(String prefix) { String str = "Root\n"; prefix += " "; for (Node child : childs) { - str += child.toPrint(prefix); + str += child.printAST(prefix); } return str; } + @Override + public String toPrint(String prefix) { + String str = prefix; + for (Node child : childs) { + str += child.toPrint(""); + } + return str; + } + + public ArrayList getChilds() { + return childs; + } + + public Node getChild(int i) { + return childs.get(i); + } } -- cgit v1.2.3-18-g5258