From b50c7e99603e9f85d82d700d62c16c4fcef88715 Mon Sep 17 00:00:00 2001 From: Geno <48206120+gabrielegenovese@users.noreply.github.com> Date: Thu, 11 Jul 2024 12:57:56 +0200 Subject: Code generation (#20) Co-authored-by: geno Co-authored-by: Santo Cariotti --- src/ast/nodes/ArglistNode.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src/ast/nodes/ArglistNode.java') 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 checkSemantics(SymbolTable ST, int _nesting) { + public ArrayList checkSemantics(SymbolTable ST, int _nesting, FunctionType ft) { ArrayList 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 -- cgit v1.2.3-18-g5258