summaryrefslogtreecommitdiff
path: root/src/ast/nodes/ArglistNode.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/ast/nodes/ArglistNode.java')
-rw-r--r--src/ast/nodes/ArglistNode.java29
1 files changed, 27 insertions, 2 deletions
diff --git a/src/ast/nodes/ArglistNode.java b/src/ast/nodes/ArglistNode.java
index f0c33e1..78b4ca7 100644
--- a/src/ast/nodes/ArglistNode.java
+++ b/src/ast/nodes/ArglistNode.java
@@ -1,15 +1,17 @@
package ast.nodes;
+import ast.types.*;
import java.util.ArrayList;
+import java.util.Arrays;
import semanticanalysis.SemanticError;
import semanticanalysis.SymbolTable;
-import ast.types.*;
/**
* Node for the `arglist` statement of the grammar.
*/
public class ArglistNode implements Node {
+
protected ArrayList<Node> arguments;
public ArglistNode(ArrayList<Node> arguments) {
@@ -21,12 +23,35 @@ public class ArglistNode implements Node {
ArrayList<SemanticError> errors = new ArrayList<SemanticError>();
for (var arg : arguments) {
- errors.addAll(arg.checkSemantics(ST, _nesting));
+ ExprNode argExpr = (ExprNode) arg;
+ String argName = argExpr.getId();
+
+ // TODO: check fucking IntType for params
+ // TODO: remove fucking comments
+ if (argName != null) {
+ if (Arrays.asList(bif).contains(argName)) {
+ continue;
+ }
+
+ if (ST.lookup(argName) != null && ST.lookup(argName).getType() instanceof ImportType) {
+ continue;
+ }
+
+ if (!ST.top_lookup(argName) && argExpr.typeCheck() instanceof AtomType) {
+ errors.add(new SemanticError("'" + argName + "' is not defined."));
+ }
+ } else {
+ errors.addAll(arg.checkSemantics(ST, _nesting));
+ }
}
return errors;
}
+ public int getArgumentNumber() {
+ return arguments.size();
+ }
+
@Override
public Type typeCheck() {
return new VoidType();