use of com.rockwellcollins.atc.agree.agree.Expr in project AGREE by loonwerks.
the class ArraySubExprImpl method basicSetIndex.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetIndex(Expr newIndex, NotificationChain msgs) {
Expr oldIndex = index;
index = newIndex;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, AgreePackage.ARRAY_SUB_EXPR__INDEX, oldIndex, newIndex);
if (msgs == null)
msgs = notification;
else
msgs.add(notification);
}
return msgs;
}
use of com.rockwellcollins.atc.agree.agree.Expr in project AGREE by loonwerks.
the class AssignStatementImpl method basicSetExpr.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetExpr(Expr newExpr, NotificationChain msgs) {
Expr oldExpr = expr;
expr = newExpr;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, AgreePackage.ASSIGN_STATEMENT__EXPR, oldExpr, newExpr);
if (msgs == null)
msgs = notification;
else
msgs.add(notification);
}
return msgs;
}
use of com.rockwellcollins.atc.agree.agree.Expr in project AGREE by loonwerks.
the class AgreeValidator method checkSporadicStatement.
@Check(CheckType.FAST)
public void checkSporadicStatement(SporadicStatement statement) {
Expr event = statement.getEvent();
Expr jitter = statement.getJitter();
Expr iat = statement.getIat();
checkExprIsIdentifier(event);
TypeDef eventType = AgreeTypeSystem.infer(event);
if (!AgreeTypeSystem.typesEqual(AgreeTypeSystem.Prim.BoolTypeDef, eventType)) {
error(event, "Expression is of type '" + eventType + "' but must be of type 'bool'");
}
if (jitter != null) {
if (!(jitter instanceof RealLitExpr || isTimingConst(jitter))) {
error(jitter, "The specified jitter must be a real literal");
} else {
Double val = getRealConstVal(jitter);
if (val < 0) {
error(jitter, "The specified jitter must be positive");
}
}
}
if (!(iat instanceof RealLitExpr || isTimingConst(iat))) {
error(iat, "The specified interarrival time must be a real literal");
} else {
Double val = getRealConstVal(iat);
if (val < 0) {
error(iat, "The specified interarrival time must be positive");
}
}
}
use of com.rockwellcollins.atc.agree.agree.Expr in project AGREE by loonwerks.
the class AgreeValidator method checkArraySubExpr.
@Check(CheckType.FAST)
public void checkArraySubExpr(ArraySubExpr asub) {
Expr arrExp = asub.getExpr();
checkTypeExists(arrExp);
TypeDef arrType = AgreeTypeSystem.infer(arrExp);
Expr index = asub.getIndex();
checkTypeExists(index);
TypeDef indexType = AgreeTypeSystem.infer(index);
if (!AgreeTypeSystem.typesEqual(indexType, AgreeTypeSystem.Prim.IntTypeDef)) {
error(index, "index must be an int");
}
if (arrType instanceof ArrayTypeDef) {
ArrayTypeDef arrayTypeDef = (ArrayTypeDef) arrType;
int arraySize = arrayTypeDef.size;
BigInteger indexValue = evaluateIndexExpr(index);
if (indexValue != null) {
if (!(indexValue.compareTo(BigInteger.ONE) >= 0 && indexValue.compareTo(BigInteger.valueOf(arraySize)) <= 0)) {
error(index, "Index value " + indexValue + " is out of array bounds [1 .. " + arraySize + "]");
}
} else {
warning(index, "Could not statically compute array index value");
}
} else {
error(arrExp, "expression must evaluate to an array");
}
}
use of com.rockwellcollins.atc.agree.agree.Expr in project AGREE by loonwerks.
the class AgreeValidator method checkWheneverImpliesStatement.
@Check(CheckType.FAST)
public void checkWheneverImpliesStatement(WheneverImpliesStatement whenever) {
Expr cause = whenever.getCause();
Expr lhs = whenever.getLhs();
Expr rhs = whenever.getRhs();
checkExprIsIdentifier(cause);
checkExprIsIdentifier(lhs);
checkExprIsIdentifier(rhs);
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(lhs);
if (!AgreeTypeSystem.typesEqual(AgreeTypeSystem.Prim.BoolTypeDef, type)) {
error(lhs, "The left hand side of the 'implies' of the 'whenever' statement is of type '" + type + "' " + "but must be of type 'bool'");
}
type = AgreeTypeSystem.infer(rhs);
if (!AgreeTypeSystem.typesEqual(AgreeTypeSystem.Prim.BoolTypeDef, type)) {
error(lhs, "The rhs hand side of the 'implies' of the 'whenever' statement is of type '" + type + "' " + "but must be of type 'bool'");
}
}
Aggregations