use of edu.uah.rsesc.aadlsimulator.xtext.util.InputConstraintTypeDeterminer in project AGREE by loonwerks.
the class InputConstraintValidator method checkBinaryExpressionTypes.
@Check
public void checkBinaryExpressionTypes(final BinaryExpression binaryExpr) {
final InputConstraintTypeDeterminer typeDeterminer = getTypeDeterminer();
final ResultType leftType = typeDeterminer.determineType(binaryExpr.getLeft());
final ResultType rightType = typeDeterminer.determineType(binaryExpr.getRight());
if (leftType != rightType) {
error("Both sides of a binary expression must be of the same type. Left: " + leftType + ". Right: " + rightType + ".", InputConstraintPackage.Literals.BINARY_EXPRESSION__LEFT);
} else if (leftType == ResultType.INTEGER && binaryExpr.getOp() == Operator.DIVISION) {
error("Integer division is not supported.", InputConstraintPackage.Literals.BINARY_EXPRESSION__LEFT);
}
}
use of edu.uah.rsesc.aadlsimulator.xtext.util.InputConstraintTypeDeterminer in project AGREE by loonwerks.
the class InputConstraintValidator method checkIntervalTypes.
@Check
public void checkIntervalTypes(final IntervalExpression intervalExpr) {
if (intervalExpr != null && intervalExpr != null) {
final InputConstraintTypeDeterminer typeDeterminer = getTypeDeterminer();
final ResultType leftType = typeDeterminer.determineType(intervalExpr.getLeft());
final ResultType rightType = typeDeterminer.determineType(intervalExpr.getRight());
if (leftType != rightType) {
error("Both sides of an interval must be of the same type. Left: " + leftType + ". Right: " + rightType + ".", InputConstraintPackage.Literals.INTERVAL_EXPRESSION__LEFT);
}
if (!(leftType == null || leftType == ResultType.INTEGER || leftType == ResultType.REAL)) {
error("Interval bounds must be of type integer or real. Type: " + leftType + ".", InputConstraintPackage.Literals.INTERVAL_EXPRESSION__LEFT);
}
}
}
Aggregations