NonCalculation Type added
Some checks are pending
Gitea Actions Demo / Explore-Gitea-Actions (push) Waiting to run
Some checks are pending
Gitea Actions Demo / Explore-Gitea-Actions (push) Waiting to run
This commit is contained in:
parent
0a9cc7655a
commit
4ff6854094
@ -533,7 +533,9 @@ public class SemanticAnalyzer implements SemanticVisitor {
|
|||||||
case LESS, LESS_EQUAL, GREATER, GREATER_EQUAL:
|
case LESS, LESS_EQUAL, GREATER, GREATER_EQUAL:
|
||||||
if (expResult.getType() instanceof BaseType expResultType && expResultType.getTypeEnum().equals(TypeEnum.INT) &&
|
if (expResult.getType() instanceof BaseType expResultType && expResultType.getTypeEnum().equals(TypeEnum.INT) &&
|
||||||
unaryResult.getType() instanceof BaseType unaryResultType && unaryResultType.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 {
|
} else {
|
||||||
errors.add(new TypeMismatchException("Both types must be Integer"));
|
errors.add(new TypeMismatchException("Both types must be Integer"));
|
||||||
}
|
}
|
||||||
@ -541,7 +543,9 @@ public class SemanticAnalyzer implements SemanticVisitor {
|
|||||||
case OR, AND:
|
case OR, AND:
|
||||||
if (expResult.getType() instanceof BaseType expResultType && expResultType.getTypeEnum().equals(TypeEnum.BOOL) &&
|
if (expResult.getType() instanceof BaseType expResultType && expResultType.getTypeEnum().equals(TypeEnum.BOOL) &&
|
||||||
unaryResult.getType() instanceof BaseType unaryResultType && unaryResultType.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 {
|
} else {
|
||||||
errors.add(new TypeMismatchException("Both types must be Boolean"));
|
errors.add(new TypeMismatchException("Both types must be Boolean"));
|
||||||
}
|
}
|
||||||
@ -549,7 +553,9 @@ public class SemanticAnalyzer implements SemanticVisitor {
|
|||||||
case EQUAL, NOT_EQUAL:
|
case EQUAL, NOT_EQUAL:
|
||||||
if (expResult.getType() instanceof BaseType expResultType && unaryResult.getType() instanceof BaseType unaryResultType
|
if (expResult.getType() instanceof BaseType expResultType && unaryResult.getType() instanceof BaseType unaryResultType
|
||||||
&& Objects.equals(expResultType, 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 {
|
} else {
|
||||||
errors.add(new TypeMismatchException("Both types must be the same"));
|
errors.add(new TypeMismatchException("Both types must be the same"));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user