Просмотр исходного кода

Issue 634 (#724)

changed assertion for time events
Andreas Mülder 9 лет назад
Родитель
Сommit
8cef0ea9ee

+ 18 - 18
plugins/org.yakindu.base.expressions/src/org/yakindu/base/expressions/inferrer/ExpressionsTypeInferrer.java

@@ -72,61 +72,61 @@ public class ExpressionsTypeInferrer extends AbstractTypeSystemInferrer implemen
 		Type type1 = inferTypeDispatch(e.getTrueCase());
 		Type type2 = inferTypeDispatch(e.getFalseCase());
 		assertCompatible(type1, type2, String.format(COMMON_TYPE, type1, type2));
-		assertIsSupertype(inferTypeDispatch(e.getCondition()), getType(BOOLEAN), CONDITIONAL_BOOLEAN);
+		assertIsSubType(inferTypeDispatch(e.getCondition()), getType(BOOLEAN), CONDITIONAL_BOOLEAN);
 		return getCommonType(type1, type2);
 	}
 
 	public Type infer(LogicalOrExpression e) {
 		Type type1 = inferTypeDispatch(e.getLeftOperand());
 		Type type2 = inferTypeDispatch(e.getRightOperand());
-		assertIsSupertype(type1, getType(BOOLEAN), String.format(LOGICAL_OPERATORS, "||", type1, type2));
-		assertIsSupertype(type2, getType(BOOLEAN), String.format(LOGICAL_OPERATORS, "||", type1, type2));
+		assertIsSubType(type1, getType(BOOLEAN), String.format(LOGICAL_OPERATORS, "||", type1, type2));
+		assertIsSubType(type2, getType(BOOLEAN), String.format(LOGICAL_OPERATORS, "||", type1, type2));
 		return getType(BOOLEAN);
 	}
 
 	public Type infer(LogicalAndExpression e) {
 		Type type1 = inferTypeDispatch(e.getLeftOperand());
 		Type type2 = inferTypeDispatch(e.getRightOperand());
-		assertIsSupertype(type1, getType(BOOLEAN), String.format(LOGICAL_OPERATORS, "&&", type1, type2));
-		assertIsSupertype(type2, getType(BOOLEAN), String.format(LOGICAL_OPERATORS, "&&", type1, type2));
+		assertIsSubType(type1, getType(BOOLEAN), String.format(LOGICAL_OPERATORS, "&&", type1, type2));
+		assertIsSubType(type2, getType(BOOLEAN), String.format(LOGICAL_OPERATORS, "&&", type1, type2));
 		return getType(BOOLEAN);
 	}
 
 	public Type infer(LogicalNotExpression e) {
 		Type type = inferTypeDispatch(e.getOperand());
-		assertIsSupertype(type, getType(BOOLEAN), String.format(LOGICAL_OPERATOR, "!", type));
+		assertIsSubType(type, getType(BOOLEAN), String.format(LOGICAL_OPERATOR, "!", type));
 		return getType(BOOLEAN);
 	}
 
 	public Type infer(BitwiseXorExpression e) {
 		Type type1 = inferTypeDispatch(e.getLeftOperand());
 		Type type2 = inferTypeDispatch(e.getRightOperand());
-		assertIsSupertype(type1, getType(INTEGER), String.format(BITWISE_OPERATORS, "^", type1, type2));
-		assertIsSupertype(type2, getType(INTEGER), String.format(BITWISE_OPERATORS, "^", type1, type2));
+		assertIsSubType(type1, getType(INTEGER), String.format(BITWISE_OPERATORS, "^", type1, type2));
+		assertIsSubType(type2, getType(INTEGER), String.format(BITWISE_OPERATORS, "^", type1, type2));
 		return getType(INTEGER);
 	}
 
 	public Type infer(BitwiseOrExpression e) {
 		Type type1 = inferTypeDispatch(e.getLeftOperand());
 		Type type2 = inferTypeDispatch(e.getRightOperand());
-		assertIsSupertype(type1, getType(INTEGER), String.format(BITWISE_OPERATORS, "|", type1, type2));
-		assertIsSupertype(type2, getType(INTEGER), String.format(BITWISE_OPERATORS, "|", type1, type2));
+		assertIsSubType(type1, getType(INTEGER), String.format(BITWISE_OPERATORS, "|", type1, type2));
+		assertIsSubType(type2, getType(INTEGER), String.format(BITWISE_OPERATORS, "|", type1, type2));
 		return getType(INTEGER);
 	}
 
 	public Type infer(BitwiseAndExpression e) {
 		Type type1 = inferTypeDispatch(e.getLeftOperand());
 		Type type2 = inferTypeDispatch(e.getRightOperand());
-		assertIsSupertype(type1, getType(INTEGER), String.format(BITWISE_OPERATORS, "&", type1, type2));
-		assertIsSupertype(type2, getType(INTEGER), String.format(BITWISE_OPERATORS, "&", type1, type2));
+		assertIsSubType(type1, getType(INTEGER), String.format(BITWISE_OPERATORS, "&", type1, type2));
+		assertIsSubType(type2, getType(INTEGER), String.format(BITWISE_OPERATORS, "&", type1, type2));
 		return getType(INTEGER);
 	}
 
 	public Type infer(ShiftExpression e) {
 		Type type1 = inferTypeDispatch(e.getLeftOperand());
 		Type type2 = inferTypeDispatch(e.getRightOperand());
-		assertIsSupertype(type1, getType(INTEGER), String.format(BITWISE_OPERATORS, e.getOperator(), type1, type2));
-		assertIsSupertype(type2, getType(INTEGER), String.format(BITWISE_OPERATORS, e.getOperator(), type1, type2));
+		assertIsSubType(type1, getType(INTEGER), String.format(BITWISE_OPERATORS, e.getOperator(), type1, type2));
+		assertIsSubType(type2, getType(INTEGER), String.format(BITWISE_OPERATORS, e.getOperator(), type1, type2));
 		return getType(INTEGER);
 	}
 
@@ -143,7 +143,7 @@ public class ExpressionsTypeInferrer extends AbstractTypeSystemInferrer implemen
 		Type type1 = inferTypeDispatch(e.getLeftOperand());
 		Type type2 = inferTypeDispatch(e.getRightOperand());
 		assertCompatible(type1, type2, String.format(ARITHMETIC_OPERATORS, e.getOperator(), type1, type2));
-		assertIsSupertype(type1, getType(REAL), String.format(ARITHMETIC_OPERATORS, e.getOperator(), type1, type2));
+		assertIsSubType(type1, getType(REAL), String.format(ARITHMETIC_OPERATORS, e.getOperator(), type1, type2));
 		return getCommonType(e.getLeftOperand(), e.getRightOperand());
 	}
 
@@ -151,16 +151,16 @@ public class ExpressionsTypeInferrer extends AbstractTypeSystemInferrer implemen
 		Type type1 = inferTypeDispatch(e.getLeftOperand());
 		Type type2 = inferTypeDispatch(e.getRightOperand());
 		assertCompatible(type1, type2, String.format(ARITHMETIC_OPERATORS, e.getOperator(), type1, type2));
-		assertIsSupertype(type1, getType(REAL), String.format(ARITHMETIC_OPERATORS, e.getOperator(), type1, type2));
+		assertIsSubType(type1, getType(REAL), String.format(ARITHMETIC_OPERATORS, e.getOperator(), type1, type2));
 		return getCommonType(type1, type2);
 	}
 
 	public Type infer(NumericalUnaryExpression e) {
 		Type type1 = inferTypeDispatch(e.getOperand());
 		if (e.getOperator() == UnaryOperator.COMPLEMENT)
-			assertIsSupertype(type1, getType(INTEGER), String.format(BITWISE_OPERATOR, '~', type1));
+			assertIsSubType(type1, getType(INTEGER), String.format(BITWISE_OPERATOR, '~', type1));
 		else {
-			assertIsSupertype(type1, getType(REAL), String.format(ARITHMETIC_OPERATOR, e.getOperator(), type1));
+			assertIsSubType(type1, getType(REAL), String.format(ARITHMETIC_OPERATOR, e.getOperator(), type1));
 		}
 		return type1;
 	}

+ 1 - 1
plugins/org.yakindu.base.types/src/org/yakindu/base/types/inferrer/AbstractTypeSystemInferrer.java

@@ -159,7 +159,7 @@ public abstract class AbstractTypeSystemInferrer implements ITypeSystemInferrer
 		}
 	}
 	
-	protected void assertIsSupertype(Type subtype, Type supertype, String msg) {
+	protected void assertIsSubType(Type subtype, Type supertype, String msg) {
 		if (subtype == null || supertype == null)
 			return;
 		if (!registry.isSuperType(subtype, supertype)) {

+ 2 - 2
plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/inferrer/STextTypeInferrer.java

@@ -59,13 +59,13 @@ public class STextTypeInferrer extends ExpressionsTypeInferrer {
 
 	public Object infer(Guard e) {
 		Type type = inferTypeDispatch(e.getExpression());
-		assertIsSupertype(type, getType(BOOLEAN), GUARD);
+		assertIsSubType(type, getType(BOOLEAN), GUARD);
 		return inferTypeDispatch(type);
 	}
 
 	public Object infer(TimeEventSpec e) {
 		Type type = inferTypeDispatch(e.getValue());
-		assertSame(type, getType(INTEGER), TIME_SPEC);
+		assertIsSubType(type, getType(INTEGER), TIME_SPEC);
 		return inferTypeDispatch(type);
 	}