Compare commits

..

No commits in common. "194ff3fcf78ff9276e9eadaabf7b983113bc031a" and "492bab5477db23e2cc2cc2268db051bfc01b384d" have entirely different histories.

3 changed files with 2 additions and 16 deletions

View File

@ -60,9 +60,6 @@ public class BlockStatement extends AbstractType implements IStatement {
if(statement instanceof LocalVarDecl localVarDecl){
localVarDecl.thisClass = thisClass;
}
if (statement instanceof PrintStatement printStatement) {
printStatement.thisClass = thisClass;
}
TypeCheckResult typeOfCurrentStatement = statement.typeCheck(methodContext, typeContext, localVars);
if(statement instanceof LocalVarDecl localVarDecl){

View File

@ -8,11 +8,9 @@ import org.objectweb.asm.MethodVisitor;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Objects;
public class PrintStatement extends AbstractType implements IStatement {
String variableName;
public String thisClass;
public PrintStatement(String variableName) {
this.variableName = variableName;
@ -20,16 +18,7 @@ public class PrintStatement extends AbstractType implements IStatement {
@Override
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();
String typeOfVar = localVars.get(variableName);
if (typeOfVar == null) {
typeOfVar = typeContext.get(thisClass).get(variableName);
}
if (!Objects.equals(typeOfVar, "int"))
throw new TypeCheckException("The variable to be printed is " + typeOfVar + " but should be int.");
result.type = typeOfVar;
setTypeCheckResult(result);
return result;
return null;
}
@Override

View File

@ -63,7 +63,7 @@ public class MethodCallStatementExpression extends AbstractType implements IExpr
currentType = thisClass;
}
//if classToSearchMethodIn does not contain method, throw exception. go through list and check each
//if classToSearchMethodIn does not conatin method, throw exception. go through list and check each
for (int i = 0; i < receivingMethods.size(); i++) {
currentType = (String) methodContext.get(currentType).get(receivingMethods.get(i).methodName).keySet().toArray()[0];