use of edu.mit.csail.sdg.ast.ExprQt in project org.alloytools.alloy by AlloyTools.
the class TranslateAlloyToKodkod method visit.
/**
* {@inheritDoc}
*/
@Override
public Object visit(ExprQt x) throws Err {
Expr xx = x.desugar();
if (xx instanceof ExprQt)
x = (ExprQt) xx;
else
return visitThis(xx);
Object ans = visit_qt(x.op, x.decls, x.sub);
if (ans instanceof Formula)
k2pos((Formula) ans, x);
return ans;
}
use of edu.mit.csail.sdg.ast.ExprQt in project org.alloytools.alloy by AlloyTools.
the class SimInstance method visit.
/**
* {@inheritDoc}
*/
@Override
public Object visit(ExprQt x) throws Err {
Expr xx = x.desugar();
if (xx instanceof ExprQt)
x = (ExprQt) xx;
else
return visitThis(xx);
if (x.op == ExprQt.Op.COMPREHENSION) {
TempList<SimTuple> ans = new TempList<SimTuple>();
enumerate(ans, 0, x, x.sub, 0);
return SimTupleset.make(ans.makeConst());
}
if (x.op == ExprQt.Op.ALL)
return enumerate(null, 0, x, x.sub.not(), 0) == 0;
if (x.op == ExprQt.Op.NO)
return enumerate(null, 0, x, x.sub, 0) == 0;
if (x.op == ExprQt.Op.SOME)
return enumerate(null, 0, x, x.sub, 0) >= 1;
if (x.op == ExprQt.Op.LONE)
return enumerate(null, 0, x, x.sub, 0) <= 1;
if (x.op == ExprQt.Op.ONE)
return enumerate(null, 0, x, x.sub, 0) == 1;
if (x.op == ExprQt.Op.SUM)
return trunc(enumerate(null, 0, x, x.sub, 0));
throw new ErrorFatal(x.pos, "Unsupported operator (" + x.op + ") encountered during ExprQt.accept()");
}
Aggregations