package abstractSyntaxTree.StatementExpression; import TypeCheck.AbstractType; import TypeCheck.TypeCheckResult; import abstractSyntaxTree.Class.MethodDecl; import abstractSyntaxTree.Datatype.RefType; import abstractSyntaxTree.Expression.IExpression; import abstractSyntaxTree.Statement.IStatement; import java.util.List; public class MethodCallStatementExpression extends AbstractType implements IExpression, IStatement { String methodName; List arguments; RefType classThatHasTheMethodIfNotThis; RefType thisClass; public MethodCallStatementExpression(String methodName, List arguments) { this.methodName = methodName; this.arguments = arguments; } @Override public TypeCheckResult typeCheck() throws Exception { TypeCheckResult result = new TypeCheckResult(); RefType searchMethodHere; if(classThatHasTheMethodIfNotThis == null){ searchMethodHere = thisClass; } else { searchMethodHere = classThatHasTheMethodIfNotThis; } List methods = searchMethodHere.methodDecls; if(!methods.contains(methodName)){ throw new Exception("method not found"); } return result; } }