use of org.btrplace.safeplace.spec.type.Type in project scheduler by btrplace.
the class MyCstrSpecVisitor method resolveFunction.
private Function resolveFunction(Token t, List<Term> args) {
Function f = symbols.getFunction(t.getText());
if (f == null) {
throw SpecException.unknownSymbol(filename, t);
}
Type[] expected = f.signature();
if (expected.length != args.size()) {
throw SpecException.badFunctionCall(filename, t, f, args);
}
for (int i = 0; i < expected.length; i++) {
if (!expected[i].equals(args.get(i).type())) {
throw SpecException.badFunctionCall(filename, t, f, args);
}
}
return f;
}
use of org.btrplace.safeplace.spec.type.Type in project scheduler by btrplace.
the class MyCstrSpecVisitor method visitSetInExtension.
@Override
public ExplodedSet visitSetInExtension(@NotNull CstrSpecParser.SetInExtensionContext ctx) {
List<Term> s = new ArrayList<>();
Type ty = null;
for (CstrSpecParser.TermContext t : ctx.term()) {
Term<?> tr = (Term<?>) visit(t);
if (ty == null) {
ty = tr.type();
}
assertEqualsTypes(t.getStart(), ty, tr.type());
s.add(tr);
}
return new ExplodedSet(s, ty);
}
use of org.btrplace.safeplace.spec.type.Type in project scheduler by btrplace.
the class SpecVerifier method fillArguments.
public void fillArguments(Context mo, TestCase tc) {
Constraint c = tc.constraint();
List<Constant> values = tc.args();
// Check signature
if (values.size() != c.args().size()) {
throw new IllegalArgumentException(c.toString(values) + " cannot match " + c.signatureToString());
}
for (int i = 0; i < values.size(); i++) {
UserVar<?> var = c.args().get(i);
Type t = values.get(i).type();
if (!var.type().equals(t)) {
throw new IllegalArgumentException(c.toString(values) + " cannot match " + c.signatureToString());
}
mo.setValue(var.label(), values.get(i).eval(mo));
}
}
use of org.btrplace.safeplace.spec.type.Type in project scheduler by btrplace.
the class Constant method fromJSON.
public static Constant fromJSON(JSONObject o) {
Type t = Type.decode(o.getAsString("type"));
Object r = t.fromJSON(o.get("value"));
return new Constant(r, t);
}
use of org.btrplace.safeplace.spec.type.Type in project scheduler by btrplace.
the class MyCstrSpecVisitor method assertIn.
private void assertIn(Token to, Term<?> t1, Term<?> t2) {
Type t = t2.type();
if (!(t instanceof SetType)) {
throw new SpecException(filename, to.getCharPositionInLine(), "The right-hand side must be a collection. Got '" + t2.type() + "'");
}
SetType st = (SetType) t;
if (!st.enclosingType().equals(t1.type())) {
throw new SpecException(filename, to.getCharPositionInLine(), "Type mismatch. Expected '" + st.enclosingType() + "' for left-hand side. Got '" + t1.type() + "'");
}
}
Aggregations