Endabgabe #20
@ -533,7 +533,9 @@ public class SemanticAnalyzer implements SemanticVisitor {
|
||||
case LESS, LESS_EQUAL, GREATER, GREATER_EQUAL:
|
||||
if (expResult.getType() instanceof BaseType expResultType && expResultType.getTypeEnum().equals(TypeEnum.INT) &&
|
||||
unaryResult.getType() instanceof BaseType unaryResultType && unaryResultType.getTypeEnum().equals(TypeEnum.INT)) {
|
||||
return new TypeCheckResult(true, new BaseType(TypeEnum.BOOL));
|
||||
ITypeNode type = new BaseType(TypeEnum.BOOL);
|
||||
nonCalculationNode.setType(type);
|
||||
return new TypeCheckResult(true, type);
|
||||
} else {
|
||||
errors.add(new TypeMismatchException("Both types must be Integer"));
|
||||
}
|
||||
@ -541,7 +543,9 @@ public class SemanticAnalyzer implements SemanticVisitor {
|
||||
case OR, AND:
|
||||
if (expResult.getType() instanceof BaseType expResultType && expResultType.getTypeEnum().equals(TypeEnum.BOOL) &&
|
||||
unaryResult.getType() instanceof BaseType unaryResultType && unaryResultType.getTypeEnum().equals(TypeEnum.BOOL)) {
|
||||
return new TypeCheckResult(true, new BaseType(TypeEnum.BOOL));
|
||||
ITypeNode type = new BaseType(TypeEnum.BOOL);
|
||||
nonCalculationNode.setType(type);
|
||||
return new TypeCheckResult(true, type);
|
||||
} else {
|
||||
errors.add(new TypeMismatchException("Both types must be Boolean"));
|
||||
}
|
||||
@ -549,7 +553,9 @@ public class SemanticAnalyzer implements SemanticVisitor {
|
||||
case EQUAL, NOT_EQUAL:
|
||||
if (expResult.getType() instanceof BaseType expResultType && unaryResult.getType() instanceof BaseType unaryResultType
|
||||
&& Objects.equals(expResultType, unaryResultType)) {
|
||||
return new TypeCheckResult(true, new BaseType(TypeEnum.BOOL));
|
||||
ITypeNode type = new BaseType(TypeEnum.BOOL);
|
||||
nonCalculationNode.setType(type);
|
||||
return new TypeCheckResult(true, type);
|
||||
} else {
|
||||
errors.add(new TypeMismatchException("Both types must be the same"));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user