Search in sources :

Example 1 with ExprCompOperator

use of kodkod.ast.operator.ExprCompOperator in project org.alloytools.alloy by AlloyTools.

the class FOL2BoolTranslator method visit.

/**
 * Calls lookup(compFormula) and returns the cached value, if any. If a
 * translation has not been cached, translates the formula, calls cache(...) on
 * it and returns it.
 *
 * @return let t = lookup(compFormula) | some t => t, let op =
 *         (binExpr.op).(SUBSET->subset + EQUALS->eq) | cache(compFormula,
 *         op(compFormula.left.accept(this), compFormula.right.accept(this)))
 */
@Override
public final BooleanValue visit(ComparisonFormula compFormula) {
    BooleanValue ret = lookup(compFormula);
    if (ret != null)
        return ret;
    final BooleanMatrix left = compFormula.left().accept(this);
    final BooleanMatrix right = compFormula.right().accept(this);
    final ExprCompOperator op = compFormula.op();
    switch(op) {
        case SUBSET:
            ret = left.subset(right, env);
            break;
        case EQUALS:
            ret = left.eq(right, env);
            break;
        default:
            throw new IllegalArgumentException("Unknown operator: " + compFormula.op());
    }
    return cache(compFormula, ret);
}
Also used : ExprCompOperator(kodkod.ast.operator.ExprCompOperator) BooleanValue(kodkod.engine.bool.BooleanValue) BooleanMatrix(kodkod.engine.bool.BooleanMatrix)

Aggregations

ExprCompOperator (kodkod.ast.operator.ExprCompOperator)1 BooleanMatrix (kodkod.engine.bool.BooleanMatrix)1 BooleanValue (kodkod.engine.bool.BooleanValue)1