Search in sources :

Example 1 with ArrayLiteralExpr

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);
}
Also used : ArrayExpr(jkind.lustre.ArrayExpr) EnumLitExpr(com.rockwellcollins.atc.agree.agree.EnumLitExpr) IndicesExpr(com.rockwellcollins.atc.agree.agree.IndicesExpr) TimeRiseExpr(com.rockwellcollins.atc.agree.agree.TimeRiseExpr) RecordAccessExpr(jkind.lustre.RecordAccessExpr) FlatmapExpr(com.rockwellcollins.atc.agree.agree.FlatmapExpr) TimeFallExpr(com.rockwellcollins.atc.agree.agree.TimeFallExpr) RealLitExpr(com.rockwellcollins.atc.agree.agree.RealLitExpr) GetPropertyExpr(com.rockwellcollins.atc.agree.agree.GetPropertyExpr) Expr(jkind.lustre.Expr) CastExpr(jkind.lustre.CastExpr) NodeCallExpr(jkind.lustre.NodeCallExpr) TimeOfExpr(com.rockwellcollins.atc.agree.agree.TimeOfExpr) BoolExpr(jkind.lustre.BoolExpr) BinaryExpr(jkind.lustre.BinaryExpr) RealExpr(jkind.lustre.RealExpr) ArrayExpr(jkind.lustre.ArrayExpr) PrevExpr(com.rockwellcollins.atc.agree.agree.PrevExpr) IdExpr(jkind.lustre.IdExpr) TimeExpr(com.rockwellcollins.atc.agree.agree.TimeExpr) FoldRightExpr(com.rockwellcollins.atc.agree.agree.FoldRightExpr) TagExpr(com.rockwellcollins.atc.agree.agree.TagExpr) EventExpr(com.rockwellcollins.atc.agree.agree.EventExpr) LatchedExpr(com.rockwellcollins.atc.agree.agree.LatchedExpr) NamedElmExpr(com.rockwellcollins.atc.agree.agree.NamedElmExpr) FunctionCallExpr(jkind.lustre.FunctionCallExpr) SelectionExpr(com.rockwellcollins.atc.agree.agree.SelectionExpr) IfThenElseExpr(jkind.lustre.IfThenElseExpr) TupleExpr(jkind.lustre.TupleExpr) UnaryExpr(jkind.lustre.UnaryExpr) ArraySubExpr(com.rockwellcollins.atc.agree.agree.ArraySubExpr) IntExpr(jkind.lustre.IntExpr) PreExpr(com.rockwellcollins.atc.agree.agree.PreExpr) RecordLitExpr(com.rockwellcollins.atc.agree.agree.RecordLitExpr) ExistsExpr(com.rockwellcollins.atc.agree.agree.ExistsExpr) FoldLeftExpr(com.rockwellcollins.atc.agree.agree.FoldLeftExpr) RecordUpdateExpr(com.rockwellcollins.atc.agree.agree.RecordUpdateExpr) ForallExpr(com.rockwellcollins.atc.agree.agree.ForallExpr) ArrayAccessExpr(jkind.lustre.ArrayAccessExpr) ArrayUpdateExpr(com.rockwellcollins.atc.agree.agree.ArrayUpdateExpr) BoolLitExpr(com.rockwellcollins.atc.agree.agree.BoolLitExpr) NodeBodyExpr(com.rockwellcollins.atc.agree.agree.NodeBodyExpr) IntLitExpr(com.rockwellcollins.atc.agree.agree.IntLitExpr) CallExpr(com.rockwellcollins.atc.agree.agree.CallExpr) ArrayLiteralExpr(com.rockwellcollins.atc.agree.agree.ArrayLiteralExpr) ArrayList(java.util.ArrayList)

Example 2 with ArrayLiteralExpr

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));
        }
    }
}
Also used : EnumLitExpr(com.rockwellcollins.atc.agree.agree.EnumLitExpr) IndicesExpr(com.rockwellcollins.atc.agree.agree.IndicesExpr) TimeRiseExpr(com.rockwellcollins.atc.agree.agree.TimeRiseExpr) FlatmapExpr(com.rockwellcollins.atc.agree.agree.FlatmapExpr) TimeFallExpr(com.rockwellcollins.atc.agree.agree.TimeFallExpr) RealLitExpr(com.rockwellcollins.atc.agree.agree.RealLitExpr) GetPropertyExpr(com.rockwellcollins.atc.agree.agree.GetPropertyExpr) TimeOfExpr(com.rockwellcollins.atc.agree.agree.TimeOfExpr) PrevExpr(com.rockwellcollins.atc.agree.agree.PrevExpr) FoldRightExpr(com.rockwellcollins.atc.agree.agree.FoldRightExpr) TagExpr(com.rockwellcollins.atc.agree.agree.TagExpr) EventExpr(com.rockwellcollins.atc.agree.agree.EventExpr) LatchedExpr(com.rockwellcollins.atc.agree.agree.LatchedExpr) NamedElmExpr(com.rockwellcollins.atc.agree.agree.NamedElmExpr) SelectionExpr(com.rockwellcollins.atc.agree.agree.SelectionExpr) IfThenElseExpr(com.rockwellcollins.atc.agree.agree.IfThenElseExpr) ArraySubExpr(com.rockwellcollins.atc.agree.agree.ArraySubExpr) PreExpr(com.rockwellcollins.atc.agree.agree.PreExpr) RecordLitExpr(com.rockwellcollins.atc.agree.agree.RecordLitExpr) BinaryExpr(com.rockwellcollins.atc.agree.agree.BinaryExpr) UnaryExpr(com.rockwellcollins.atc.agree.agree.UnaryExpr) ExistsExpr(com.rockwellcollins.atc.agree.agree.ExistsExpr) FoldLeftExpr(com.rockwellcollins.atc.agree.agree.FoldLeftExpr) RecordUpdateExpr(com.rockwellcollins.atc.agree.agree.RecordUpdateExpr) ForallExpr(com.rockwellcollins.atc.agree.agree.ForallExpr) Expr(com.rockwellcollins.atc.agree.agree.Expr) ArrayUpdateExpr(com.rockwellcollins.atc.agree.agree.ArrayUpdateExpr) BoolLitExpr(com.rockwellcollins.atc.agree.agree.BoolLitExpr) NodeBodyExpr(com.rockwellcollins.atc.agree.agree.NodeBodyExpr) IntLitExpr(com.rockwellcollins.atc.agree.agree.IntLitExpr) CallExpr(com.rockwellcollins.atc.agree.agree.CallExpr) ArrayLiteralExpr(com.rockwellcollins.atc.agree.agree.ArrayLiteralExpr) AgreeTypeSystem.nameOfTypeDef(com.rockwellcollins.atc.agree.AgreeTypeSystem.nameOfTypeDef) ArrayTypeDef(com.rockwellcollins.atc.agree.AgreeTypeSystem.ArrayTypeDef) RecordTypeDef(com.rockwellcollins.atc.agree.AgreeTypeSystem.RecordTypeDef) TypeDef(com.rockwellcollins.atc.agree.AgreeTypeSystem.TypeDef) Check(org.eclipse.xtext.validation.Check)

Aggregations

ArrayLiteralExpr (com.rockwellcollins.atc.agree.agree.ArrayLiteralExpr)2 ArraySubExpr (com.rockwellcollins.atc.agree.agree.ArraySubExpr)2 ArrayUpdateExpr (com.rockwellcollins.atc.agree.agree.ArrayUpdateExpr)2 BoolLitExpr (com.rockwellcollins.atc.agree.agree.BoolLitExpr)2 CallExpr (com.rockwellcollins.atc.agree.agree.CallExpr)2 EnumLitExpr (com.rockwellcollins.atc.agree.agree.EnumLitExpr)2 EventExpr (com.rockwellcollins.atc.agree.agree.EventExpr)2 ExistsExpr (com.rockwellcollins.atc.agree.agree.ExistsExpr)2 FlatmapExpr (com.rockwellcollins.atc.agree.agree.FlatmapExpr)2 FoldLeftExpr (com.rockwellcollins.atc.agree.agree.FoldLeftExpr)2 FoldRightExpr (com.rockwellcollins.atc.agree.agree.FoldRightExpr)2 ForallExpr (com.rockwellcollins.atc.agree.agree.ForallExpr)2 GetPropertyExpr (com.rockwellcollins.atc.agree.agree.GetPropertyExpr)2 IndicesExpr (com.rockwellcollins.atc.agree.agree.IndicesExpr)2 IntLitExpr (com.rockwellcollins.atc.agree.agree.IntLitExpr)2 LatchedExpr (com.rockwellcollins.atc.agree.agree.LatchedExpr)2 NamedElmExpr (com.rockwellcollins.atc.agree.agree.NamedElmExpr)2 NodeBodyExpr (com.rockwellcollins.atc.agree.agree.NodeBodyExpr)2 PreExpr (com.rockwellcollins.atc.agree.agree.PreExpr)2 PrevExpr (com.rockwellcollins.atc.agree.agree.PrevExpr)2