Search in sources :

Example 1 with IntMinus

use of org.btrplace.safeplace.spec.term.IntMinus in project scheduler by btrplace.

the class MyCstrSpecVisitor method visitTermOp.

@Override
public Term<?> visitTermOp(@NotNull CstrSpecParser.TermOpContext ctx) {
    Term t1 = (Term<?>) visit(ctx.t1);
    Term t2 = (Term<?>) visit(ctx.t2);
    assertEqualsTypes(ctx.op, t1.type(), t2.type());
    switch(ctx.op.getType()) {
        case CstrSpecParser.PLUS:
            if (t1.type() == IntType.getInstance()) {
                return new IntPlus(t1, t2);
            } else if (t1.type() instanceof SetType) {
                return new SetPlus(t1, t2);
            }
            break;
        case CstrSpecParser.MINUS:
            if (t1.type() == IntType.getInstance()) {
                return new IntMinus(t1, t2);
            } else if (t1.type() instanceof SetType) {
                return new SetMinus(t1, t2);
            }
            break;
        case CstrSpecParser.MULT:
            return new Mult(t1, t2);
        default:
    }
    throw SpecException.unsupportedOperation(filename, t1.type(), ctx.op, t2.type());
}
Also used : IntMinus(org.btrplace.safeplace.spec.term.IntMinus) Mult(org.btrplace.safeplace.spec.term.Mult) SetType(org.btrplace.safeplace.spec.type.SetType) SetMinus(org.btrplace.safeplace.spec.term.SetMinus) Term(org.btrplace.safeplace.spec.term.Term) ProtectedTerm(org.btrplace.safeplace.spec.term.ProtectedTerm) SetPlus(org.btrplace.safeplace.spec.term.SetPlus) IntPlus(org.btrplace.safeplace.spec.term.IntPlus)

Aggregations

IntMinus (org.btrplace.safeplace.spec.term.IntMinus)1 IntPlus (org.btrplace.safeplace.spec.term.IntPlus)1 Mult (org.btrplace.safeplace.spec.term.Mult)1 ProtectedTerm (org.btrplace.safeplace.spec.term.ProtectedTerm)1 SetMinus (org.btrplace.safeplace.spec.term.SetMinus)1 SetPlus (org.btrplace.safeplace.spec.term.SetPlus)1 Term (org.btrplace.safeplace.spec.term.Term)1 SetType (org.btrplace.safeplace.spec.type.SetType)1