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/SimpleStmtNode.java | 48 +++++++++++++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 10 deletions(-) (limited to 'src/ast/nodes/SimpleStmtNode.java') diff --git a/src/ast/nodes/SimpleStmtNode.java b/src/ast/nodes/SimpleStmtNode.java index 31a935f..3952242 100644 --- a/src/ast/nodes/SimpleStmtNode.java +++ b/src/ast/nodes/SimpleStmtNode.java @@ -73,28 +73,56 @@ public class SimpleStmtNode implements Node { } @Override - public String toPrint(String prefix) { + public String printAST(String prefix) { String str = prefix + "SimpleStmt\n"; prefix += " "; if (assignment != null) { - str += assignment.toPrint(prefix); + str += assignment.printAST(prefix); + } else if (expr != null) { + str += expr.printAST(prefix); + } else if (returnStmt != null) { + str += returnStmt.printAST(prefix); + } else if (importStmt != null) { + str += importStmt.printAST(prefix); } - if (expr != null) { - str += expr.toPrint(prefix); - } + return str; + } - if (returnStmt != null) { - str += returnStmt.toPrint(prefix); - } + @Override + public String toPrint(String prefix) { + + String str = prefix; - if (importStmt != null) { - str += importStmt.toPrint(prefix); + if (assignment != null) { + str += assignment.toPrint(""); + } else if (expr != null) { + str += expr.toPrint(""); + } else if (returnStmt != null) { + str += returnStmt.toPrint(""); + } else if (importStmt != null) { + str += importStmt.toPrint(""); } return str; } + public Node getImportStmt() { + return importStmt; + } + + public Node getReturnStmt() { + return returnStmt; + } + + public Node getAssignment() { + return assignment; + } + + public Node getExpr() { + return expr; + } + } -- cgit v1.2.3-18-g5258