instvar debugging

This commit is contained in:
Krauß, Josefine 2024-07-02 15:21:46 +02:00
parent 10f5dc692d
commit 62060462a9
2 changed files with 5 additions and 1 deletions

View File

@ -100,6 +100,6 @@ public class Compiler {
System.out.println("No TypeCheck errors found."); System.out.println("No TypeCheck errors found.");
abstractSyntaxTree.codeGen(); abstractSyntaxTree.codeGen();
System.out.println("Your input was compiler. You can find the output at ???");// todo wo output? überhaupt hinschreiben? System.out.println("Your input was compiled. You can find the output at ???");// todo wo output? überhaupt hinschreiben?
} }
} }

View File

@ -31,6 +31,10 @@ public class InstVarExpression extends AbstractType implements IExpression{
@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 {
if(this.receivers.get(0).identifier != null){
thisClass = localVars.get(this.receivers.get(0).identifier);
}
String varType = typeContext.get(thisClass).get(fieldName); String varType = typeContext.get(thisClass).get(fieldName);
if (varType == null) { if (varType == null) {
throw new TypeCheckException("Field " + fieldName + " was not found in class " + thisClass + "."); throw new TypeCheckException("Field " + fieldName + " was not found in class " + thisClass + ".");