methodcall not implemented, current input not working on ast or typechek or codegen

This commit is contained in:
Krauß, Josefine 2024-06-20 12:47:03 +02:00
parent 5a66ce97ca
commit 8a26f700b5
2 changed files with 30 additions and 23 deletions

View File

@ -1,10 +1,12 @@
class Example1 { class Example1 {
int i; int i;
boolean b; Example e;
char c;
int m(int n){ int m(int n){
Example e = new Example(); Example e = new Example();
e.m(1); e.m(1);
this.e = new Example();
this.e.m(2);
this.m(2);
return 0; return 0;
} }
} }
@ -14,11 +16,6 @@ class Example {
boolean b; boolean b;
char c; char c;
int m(int a){ int m(int a){
int localA = 0; return 0;
boolean localB = true;
if(localB){
localA = 7;
}else{}
return localA;
} }
} }

View File

@ -32,22 +32,32 @@ public class MethodCallStatementExpression extends AbstractType implements IExpr
@Override @Override
public TypeCheckResult typeCheck(HashMap<String, HashMap<String, HashMap<String, ParameterList>>> methodContext, HashMap<String, HashMap<String, String>> typeContext, HashMap<String, String> localVars) throws TypeCheckException { public TypeCheckResult typeCheck(HashMap<String, HashMap<String, HashMap<String, ParameterList>>> methodContext, HashMap<String, HashMap<String, String>> typeContext, HashMap<String, String> localVars) throws TypeCheckException {
TypeCheckResult result = new TypeCheckResult(); //todo i really dont get this. waiting for tuesday meeting
throw new TypeCheckException("NOT IMPLEMENTED");
RefType searchMethodHere; // TypeCheckResult result = new TypeCheckResult();
if(classThatHasTheMethodIfNotThis == null){ // String receivingField;
searchMethodHere = thisClass; // String classContainingMethod;
} else { //
searchMethodHere = classThatHasTheMethodIfNotThis; // if(receiver.instVarExpression != null){
} // receivingField = receiver.instVarExpression.fieldName;
// }else if(receiver.thisExpression) {
List<MethodDecl> methods = searchMethodHere.methodDecls; //
// }
if(!methods.contains(methodName)){ // RefType searchMethodHere;
throw new TypeCheckException("The method " + methodName + " is called, but does not exist."); // if(classThatHasTheMethodIfNotThis == null){
} // searchMethodHere = thisClass;
// } else {
return result; // searchMethodHere = classThatHasTheMethodIfNotThis;
// }
//
// List<MethodDecl> methods = searchMethodHere.methodDecls;
//
// if(!methods.contains(methodName)){
// throw new TypeCheckException("The method " + methodName + " is called, but does not exist.");
// }
//
// return result;
} }
//Errors occur due to the change in parameter in the RefType class //Errors occur due to the change in parameter in the RefType class