use of org.btrplace.safeplace.spec.term.UserVar in project scheduler by btrplace.
the class MyCstrSpecVisitor method visitSetInComprehension.
@Override
public SetBuilder<?> visitSetInComprehension(@NotNull CstrSpecParser.SetInComprehensionContext ctx) {
// Get the binder
List<UserVar<?>> v = visitTypedef(ctx.typedef());
Proposition p = Proposition.True;
if (ctx.COMMA() != null) {
p = (Proposition) visit(ctx.formula());
}
Term<?> t = (Term<?>) visit(ctx.term());
return new SetBuilder<>(t, v.get(0), p);
}
use of org.btrplace.safeplace.spec.term.UserVar in project scheduler by btrplace.
the class SpecScanner method makeArgs.
/**
* @throws SpecException
*/
private List<UserVar<?>> makeArgs(String cl, String[] strings) throws IOException {
List<UserVar<?>> args = new ArrayList<>();
for (String arg : strings) {
CstrSpecParser parser = new CstrSpecParser(getTokens(arg));
ParseTree tree = parser.typedef();
MyCstrSpecVisitor v = new MyCstrSpecVisitor().library(functions);
args.add(v.getUserVar(cl, tree));
}
return args;
}
use of org.btrplace.safeplace.spec.term.UserVar in project scheduler by btrplace.
the class SpecScanner method parseSide.
/**
* @throws SpecException
*/
private Constraint parseSide(Side s, List<Constraint> known) throws IOException {
List<UserVar<?>> args = makeArgs(s.impl.getSimpleName(), s.s.args());
CstrSpecParser parser = new CstrSpecParser(getTokens(s.s.inv()));
ParseTree tree = parser.formula();
MyCstrSpecVisitor v = new MyCstrSpecVisitor().library(functions).args(args).constraints(known);
Proposition p = v.getProposition(s.impl.getSimpleName(), tree);
return new Constraint(s.impl.getSimpleName(), p).args(args).impl(s.impl);
}
use of org.btrplace.safeplace.spec.term.UserVar in project scheduler by btrplace.
the class Constraint method eval.
@Override
public Boolean eval(Context mo, Object... values) {
for (int i = 0; i < this.args.size(); i++) {
UserVar v = this.args.get(i);
mo.setValue(v.label(), values[i]);
}
return proposition().eval(mo);
}
Aggregations