Search in sources :

Example 1 with ListType

use of org.btrplace.safeplace.spec.type.ListType in project scheduler by btrplace.

the class MyCstrSpecVisitor method visitArrayTerm.

@Override
public Term<?> visitArrayTerm(@NotNull CstrSpecParser.ArrayTermContext ctx) {
    String lbl = ctx.ID().getText();
    Var v = symbols.getVar(lbl);
    if (v == null) {
        throw SpecException.unknownSymbol(filename, ctx.ID().getSymbol());
    }
    // Type check
    if (!(v.type() instanceof ListType)) {
        throw new SpecException(filename, ctx.ID().getSymbol().getCharPositionInLine(), "List expected. Got '" + v.type() + "')");
    }
    Term idx = (Term<?>) visit(ctx.term());
    assertEqualsTypes(ctx.term().getStart(), IntType.getInstance(), idx.type());
    return new ValueAt(v, idx);
}
Also used : ValueAt(org.btrplace.safeplace.spec.term.func.ValueAt) Var(org.btrplace.safeplace.spec.term.Var) UserVar(org.btrplace.safeplace.spec.term.UserVar) ListType(org.btrplace.safeplace.spec.type.ListType) Term(org.btrplace.safeplace.spec.term.Term) ProtectedTerm(org.btrplace.safeplace.spec.term.ProtectedTerm)

Aggregations

ProtectedTerm (org.btrplace.safeplace.spec.term.ProtectedTerm)1 Term (org.btrplace.safeplace.spec.term.Term)1 UserVar (org.btrplace.safeplace.spec.term.UserVar)1 Var (org.btrplace.safeplace.spec.term.Var)1 ValueAt (org.btrplace.safeplace.spec.term.func.ValueAt)1 ListType (org.btrplace.safeplace.spec.type.ListType)1