diff options
author | Geno <48206120+gabrielegenovese@users.noreply.github.com> | 2024-07-11 12:57:56 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-11 12:57:56 +0200 |
commit | b50c7e99603e9f85d82d700d62c16c4fcef88715 (patch) | |
tree | 5052206f06e0426a43599cb236652614db04d22e /src/ast/nodes/ArglistNode.java | |
parent | f0692ff5f9e39cbd1c203e9d5abebf55a3d0f6fc (diff) |
Code generation (#20)
Co-authored-by: geno <gabrigeno@gmail>
Co-authored-by: Santo Cariotti <santo@dcariotti.me>
Diffstat (limited to 'src/ast/nodes/ArglistNode.java')
-rw-r--r-- | src/ast/nodes/ArglistNode.java | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/ast/nodes/ArglistNode.java b/src/ast/nodes/ArglistNode.java index a0ea25b..5da7e2c 100644 --- a/src/ast/nodes/ArglistNode.java +++ b/src/ast/nodes/ArglistNode.java @@ -18,16 +18,16 @@ public class ArglistNode implements Node { } @Override - public ArrayList<SemanticError> checkSemantics(SymbolTable ST, int _nesting) { + public ArrayList<SemanticError> checkSemantics(SymbolTable ST, int _nesting, FunctionType ft) { ArrayList<SemanticError> errors = new ArrayList<>(); for (var arg : arguments) { if (arg instanceof ExprNode) { ExprNode argExpr = (ExprNode) arg; String argName = argExpr.getId(); + errors.addAll(arg.checkSemantics(ST, _nesting, ft)); - // TODO: check fucking IntType for params - // TODO: remove fucking comments + // TODO: check IntType for params if (argName != null) { if (Arrays.asList(bif).contains(argName)) { continue; @@ -40,8 +40,6 @@ public class ArglistNode implements Node { if (ST.nslookup(argName) < 0 && argExpr.typeCheck() instanceof AtomType) { errors.add(new SemanticError("name '" + argName + "' is not defined.")); } - } else { - errors.addAll(arg.checkSemantics(ST, _nesting)); } } } @@ -58,10 +56,13 @@ public class ArglistNode implements Node { return new VoidType(); } - // TODO: add code generation for arglist node @Override public String codeGeneration() { - return ""; + String str = ""; + for (Node arg : arguments) { + str += arg.codeGeneration() + "pushr A0\n"; + } + return str; } @Override |