use of com.rockwellcollins.atc.agree.AgreeTypeSystem.TypeDef in project AGREE by loonwerks.
the class AgreeValidator method checkLinearizationInterval.
@Check(CheckType.FAST)
public void checkLinearizationInterval(LinearizationInterval linInterval) {
final String message = "Linearization interval endpoints must be constant expressions of real type";
Expr startExpr = linInterval.getStart();
Expr endExpr = linInterval.getEnd();
TypeDef startExprType = AgreeTypeSystem.infer(startExpr);
TypeDef endExprType = AgreeTypeSystem.infer(endExpr);
// The type of the interval start and end must be of real type
if (!AgreeTypeSystem.typesEqual(AgreeTypeSystem.Prim.RealTypeDef, startExprType)) {
error(startExpr, message + ", found type " + startExprType + ".");
}
if (!AgreeTypeSystem.typesEqual(AgreeTypeSystem.Prim.RealTypeDef, endExprType)) {
error(endExpr, message + ", found type " + endExprType + ".");
}
// The interval start and end expressions must be constant
if (!exprIsConst(startExpr)) {
error(endExpr, message + ", found non-constant expression.");
}
if (!exprIsConst(startExpr)) {
error(endExpr, message + ", found non-constant expression.");
}
}
use of com.rockwellcollins.atc.agree.AgreeTypeSystem.TypeDef in project AGREE by loonwerks.
the class AgreeValidator method checkInitialStatement.
@Check(CheckType.FAST)
public void checkInitialStatement(InitialStatement statement) {
Classifier comp = statement.getContainingClassifier();
if (!(comp instanceof ComponentType)) {
error(statement, "Initial statements are allowed only in component types");
}
TypeDef exprType = AgreeTypeSystem.infer(statement.getExpr());
if (!AgreeTypeSystem.typesEqual(AgreeTypeSystem.Prim.BoolTypeDef, exprType)) {
error(statement, "Expression for 'initially' statement is of type '" + nameOfTypeDef(exprType) + "' but must be of type 'bool'");
}
}
use of com.rockwellcollins.atc.agree.AgreeTypeSystem.TypeDef in project AGREE by loonwerks.
the class AgreeValidator method checkWheneverBecomesTrueStatement.
@Check(CheckType.FAST)
public void checkWheneverBecomesTrueStatement(WheneverBecomesTrueStatement whenever) {
Expr cause = whenever.getCause();
Expr effect = whenever.getEffect();
checkExprIsIdentifier(cause);
checkExprIsIdentifier(effect);
TypeDef type = AgreeTypeSystem.infer(cause);
if (!AgreeTypeSystem.typesEqual(AgreeTypeSystem.Prim.BoolTypeDef, type)) {
error(cause, "The cause of the 'whenever' statement is of type '" + type + "' " + "but must be of type 'bool'");
}
type = AgreeTypeSystem.infer(effect);
if (!AgreeTypeSystem.typesEqual(AgreeTypeSystem.Prim.BoolTypeDef, type)) {
error(effect, "The effect of the 'whenever' statement is of type '" + type + "' " + "but must be of type 'bool'");
}
}
use of com.rockwellcollins.atc.agree.AgreeTypeSystem.TypeDef in project AGREE by loonwerks.
the class AgreeValidator method checkWheneverHoldsStatement.
@Check(CheckType.FAST)
public void checkWheneverHoldsStatement(WheneverHoldsStatement whenever) {
Expr cause = whenever.getCause();
Expr effect = whenever.getEffect();
checkExprIsIdentifier(cause);
checkExprIsIdentifier(effect);
TypeDef type = AgreeTypeSystem.infer(cause);
if (!AgreeTypeSystem.typesEqual(AgreeTypeSystem.Prim.BoolTypeDef, type)) {
error(cause, "The cause of the 'whenever' statement is of type '" + type + "' " + "but must be of type 'bool'");
}
type = AgreeTypeSystem.infer(effect);
if (!AgreeTypeSystem.typesEqual(AgreeTypeSystem.Prim.BoolTypeDef, type)) {
error(effect, "The effect of the 'whenever' statement is of type '" + type + "' " + "but must be of type 'bool'");
}
}
use of com.rockwellcollins.atc.agree.AgreeTypeSystem.TypeDef in project AGREE by loonwerks.
the class AgreeValidator method checkWhenHoldsStatement.
@Check(CheckType.FAST)
public void checkWhenHoldsStatement(WhenHoldsStatement when) {
Expr condition = when.getCondition();
Expr event = when.getEvent();
TimeInterval condInterval = when.getConditionInterval();
checkExprIsIdentifier(condition);
checkExprIsIdentifier(event);
if (condInterval != null) {
Expr lowExpr = condInterval.getLow();
if (lowExpr instanceof RealLitExpr) {
RealLitExpr realExpr = (RealLitExpr) lowExpr;
if (!realExpr.getVal().equals("0.0")) {
error(lowExpr, "The lower bound of this interval must be zero");
}
}
} else {
error(when, "Statement most of a cause interval");
}
TypeDef type = AgreeTypeSystem.infer(condition);
if (!AgreeTypeSystem.typesEqual(AgreeTypeSystem.Prim.BoolTypeDef, type)) {
error(condition, "The condition of a when statement is of type '" + type + "'" + " but must be of type 'bool'");
}
type = AgreeTypeSystem.infer(event);
if (!AgreeTypeSystem.typesEqual(AgreeTypeSystem.Prim.BoolTypeDef, type)) {
error(event, "The effect of a when statement is of type '" + type + "'" + " but must be of type 'bool'");
}
}
Aggregations