summaryrefslogtreecommitdiff
path: root/src/ast/nodes/RootNode.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/ast/nodes/RootNode.java')
-rw-r--r--src/ast/nodes/RootNode.java22
1 files changed, 19 insertions, 3 deletions
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<Node> getChilds() {
+ return childs;
+ }
+
+ public Node getChild(int i) {
+ return childs.get(i);
+ }
}