missing thisclass

This commit is contained in:
Krauß, Josefine 2024-07-04 18:11:02 +02:00
parent 51240806b9
commit 3a8b9ea9cd
3 changed files with 10 additions and 1 deletions

View File

@ -26,6 +26,7 @@
<mainClass>Compiler</mainClass>
</manifest>
</archive>
<finalName>NichtHaskellCompiler</finalName>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>

View File

@ -15,8 +15,9 @@ import java.util.Objects;
public class BinaryExpression extends AbstractType implements IExpression{
public String operator;
public IExpression left; // This needs TypeCheckResult
public IExpression left;
public IExpression right;
public String thisClass;
public BinaryExpression(String operator, IExpression left, IExpression right) {
this.operator = operator;
@ -28,6 +29,10 @@ public class BinaryExpression extends AbstractType implements IExpression{
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();
if(left instanceof LocalVarIdentifier localVarIdentifier)
localVarIdentifier.thisClass = this.thisClass;
if(right instanceof LocalVarIdentifier localVarIdentifier)
localVarIdentifier.thisClass = this.thisClass;
TypeCheckResult leftType = left.typeCheck(methodContext, typeContext, localVars);
TypeCheckResult rightType = right.typeCheck(methodContext, typeContext, localVars);

View File

@ -4,6 +4,7 @@ import TypeCheck.AbstractType;
import TypeCheck.TypeCheckException;
import TypeCheck.TypeCheckHelper;
import TypeCheck.TypeCheckResult;
import abstractSyntaxTree.Expression.BinaryExpression;
import abstractSyntaxTree.Expression.IExpression;
import abstractSyntaxTree.Expression.InstVarExpression;
import abstractSyntaxTree.Expression.LocalVarIdentifier;
@ -54,6 +55,8 @@ public class AssignStatementExpression extends AbstractType implements IExpressi
methodCallStatementExpression.thisClass = this.thisClass;
if(right instanceof LocalVarIdentifier localVarIdentifierRight)
localVarIdentifierRight.thisClass = this.thisClass;
if(right instanceof BinaryExpression binaryExpression)
binaryExpression.thisClass = this.thisClass;
TypeCheckResult rightType = right.typeCheck(methodContext, typeContext, localVars);