use of com.rockwellcollins.atc.agree.agree.ArrayUpdateExpr in project AGREE by loonwerks.
the class AgreeValidator method checkArrayUpdateExpr.
@Check(CheckType.FAST)
public void checkArrayUpdateExpr(ArrayUpdateExpr arrup) {
List<Expr> exprs = arrup.getValueExprs();
Expr arrExpr = arrup.getArray();
checkTypeExists(arrExpr);
TypeDef arrType = AgreeTypeSystem.infer(arrExpr);
if (arrType instanceof ArrayTypeDef) {
TypeDef t = ((ArrayTypeDef) arrType).stemType;
TypeDef elmType = AgreeTypeSystem.infer(exprs.get(0));
if (!AgreeTypeSystem.typesEqual(elmType, t)) {
error(exprs.get(0), "type of element must be " + nameOfTypeDef(elmType) + ", but has type " + nameOfTypeDef(t));
}
} else {
error(arrExpr, "expression must evaluate to an array");
}
}
use of com.rockwellcollins.atc.agree.agree.ArrayUpdateExpr in project AGREE by loonwerks.
the class AgreeASTBuilder method caseArrayUpdateExpr.
@Override
public Expr caseArrayUpdateExpr(ArrayUpdateExpr expr) {
Expr arrayExpr = doSwitch(expr.getArray());
for (int i = 0; i < expr.getIndices().size(); i++) {
Expr indexExpr = doSwitch(expr.getIndices().get(i));
Expr newExpr = doSwitch(expr.getValueExprs().get(i));
arrayExpr = new jkind.lustre.ArrayUpdateExpr(arrayExpr, indexExpr, newExpr);
}
return arrayExpr;
}
Aggregations