use of com.rockwellcollins.atc.agree.agree.ArrayLiteralExpr in project AGREE by loonwerks.
the class AgreeASTBuilder method caseArrayLiteralExpr.
@Override
public Expr caseArrayLiteralExpr(ArrayLiteralExpr agreeExpr) {
List<Expr> elems = new ArrayList<>();
for (com.rockwellcollins.atc.agree.agree.Expr agreeElem : agreeExpr.getElems()) {
Expr elem = doSwitch(agreeElem);
elems.add(elem);
}
return new ArrayExpr(elems);
}
use of com.rockwellcollins.atc.agree.agree.ArrayLiteralExpr in project AGREE by loonwerks.
the class AgreeValidator method checkArrayLiteralExpr.
@Check(CheckType.FAST)
public void checkArrayLiteralExpr(ArrayLiteralExpr alit) {
// =======
// public void checkRecordType(RecordType recType) {
// DoubleDotRef recId = recType.getRecord();
// NamedElement finalId = recId.getElm();
// >>>>>>> origin/develop
List<Expr> exprs = alit.getElems();
if (exprs.size() == 0) {
error(alit, "Array literal must have at least one element");
}
Expr target = exprs.get(0);
checkTypeExists(target);
TypeDef t1 = AgreeTypeSystem.infer(target);
for (Expr e : exprs) {
checkTypeExists(e);
TypeDef t2 = AgreeTypeSystem.infer(e);
if (!AgreeTypeSystem.typesEqual(t1, t2)) {
error(e, "type of element must be " + nameOfTypeDef(t1) + ", but has type " + nameOfTypeDef(t2));
}
}
}
Aggregations