use of edu.mit.csail.sdg.ast.ExprCall in project org.alloytools.alloy by AlloyTools.
the class CompUtil method areIntsUsed.
// =============================================================================================================//
/**
* Whether or not Int appears in the relation types found in these sigs
*/
public static boolean areIntsUsed(Iterable<Sig> sigs, Command cmd) {
/* check for Int-typed relations */
for (Sig s : sigs) {
for (Field f : s.getFields()) {
for (ProductType pt : f.type()) {
for (int k = 0; k < pt.arity(); k++) {
if (pt.get(k) == SIGINT || pt.get(k) == SEQIDX)
return true;
}
}
}
}
if (cmd == null)
return false;
/* check expressions; look for CAST2SIGING (Int[]) */
try {
Object intTriggerNode;
intTriggerNode = cmd.formula.accept(new VisitQueryOnce<Object>() {
@Override
public Object visit(ExprCall x) throws Err {
// Int[]
if (x.fun.label.startsWith("integer/"))
return null;
return super.visit(x);
}
@Override
public Object visit(ExprUnary x) throws Err {
if (x.op == Op.CAST2SIGINT)
return x;
return super.visit(x);
}
});
if (intTriggerNode != null)
return true;
} catch (Err e) {
}
return false;
}
Aggregations