use of kodkod.ast.IntExpression in project org.alloytools.alloy by AlloyTools.
the class AbstractReplacer method visit.
/**
* Calls lookup(intExpr) and returns the cached value, if any. If a replacement
* has not been cached, visits the expression's children. If nothing changes,
* the argument is cached and returned, otherwise a replacement expression is
* cached and returned.
*
* @return { i: IfIntExpression | i.condition =
* intExpr.condition.accept(delegate) && i.thenExpr =
* intExpr.thenExpr.accept(delegate) && i.elseExpr =
* intExpr.elseExpr.accept(delegate) }
*/
@Override
public IntExpression visit(IfIntExpression intExpr) {
IntExpression ret = lookup(intExpr);
if (ret != null)
return ret;
final Formula condition = intExpr.condition().accept(delegate);
final IntExpression thenExpr = intExpr.thenExpr().accept(delegate);
final IntExpression elseExpr = intExpr.elseExpr().accept(delegate);
ret = (condition == intExpr.condition() && thenExpr == intExpr.thenExpr() && elseExpr == intExpr.elseExpr()) ? intExpr : condition.thenElse(thenExpr, elseExpr);
return cache(intExpr, ret);
}
use of kodkod.ast.IntExpression in project org.alloytools.alloy by AlloyTools.
the class AbstractReplacer method visit.
/**
* Calls lookup(intExpr) and returns the cached value, if any. If a replacement
* has not been cached, visits the expression's child. If nothing changes, the
* argument is cached and returned, otherwise a replacement expression is cached
* and returned.
*
* @return { i: ExprToIntCast | i.expression =
* intExpr.expression.accept(delegate) && i.op = intExpr.op}
*/
@Override
public IntExpression visit(ExprToIntCast intExpr) {
IntExpression ret = lookup(intExpr);
if (ret != null)
return ret;
final Expression expr = intExpr.expression().accept(delegate);
ret = expr == intExpr.expression() ? intExpr : expr.apply(intExpr.op());
return cache(intExpr, ret);
}
use of kodkod.ast.IntExpression in project org.alloytools.alloy by AlloyTools.
the class AbstractReplacer method visit.
/**
* Calls lookup(intExpr) and returns the cached value, if any. If a replacement
* has not been cached, visits the expression's children. If nothing changes,
* the argument is cached and returned, otherwise a replacement expression is
* cached and returned.
*
* @return { c: IntExpression | [[c]] = intExpr.left.accept(delegate) op
* intExpr.right.accept(delegate) }
*/
@Override
public IntExpression visit(BinaryIntExpression intExpr) {
IntExpression ret = lookup(intExpr);
if (ret != null)
return ret;
final IntExpression left = intExpr.left().accept(delegate);
final IntExpression right = intExpr.right().accept(delegate);
ret = (left == intExpr.left() && right == intExpr.right()) ? intExpr : left.compose(intExpr.op(), right);
return cache(intExpr, ret);
}
use of kodkod.ast.IntExpression in project org.alloytools.alloy by AlloyTools.
the class AbstractReplacer method visit.
/**
* Calls lookup(intExpr) and returns the cached value, if any. If a replacement
* has not been cached, visits the intExpr's children. If nothing changes, the
* argument is cached and returned, otherwise a replacement intExpr is cached
* and returned.
*
* @return { e: IntExpression | e.op = intExpr.op && #e.children =
* #intExpr.children && all i: [0..intExpr.children) | e.child(i) =
* intExpr.child(i).accept(delegate) }
*/
@Override
public IntExpression visit(NaryIntExpression intExpr) {
IntExpression ret = lookup(intExpr);
if (ret != null)
return ret;
final IntExpression[] visited = new IntExpression[intExpr.size()];
boolean allSame = true;
for (int i = 0; i < visited.length; i++) {
final IntExpression child = intExpr.child(i);
visited[i] = child.accept(delegate);
allSame = allSame && visited[i] == child;
}
ret = allSame ? intExpr : IntExpression.compose(intExpr.op(), visited);
return cache(intExpr, ret);
}
use of kodkod.ast.IntExpression in project org.alloytools.alloy by AlloyTools.
the class AbstractReplacer method visit.
/**
* Calls lookup(intExpr) and returns the cached value, if any. If a replacement
* has not been cached, visits the expression's children. If nothing changes,
* the argument is cached and returned, otherwise a replacement expression is
* cached and returned.
*
* @return { c: IntExpression | [[c]] = sum intExpr.decls.accept(delegate) |
* intExpr.intExpr.accept(delegate) }
*/
@Override
public IntExpression visit(SumExpression intExpr) {
IntExpression ret = lookup(intExpr);
if (ret != null)
return ret;
final Decls decls = intExpr.decls().accept(delegate);
final IntExpression expr = intExpr.intExpr().accept(delegate);
ret = (decls == intExpr.decls() && expr == intExpr.intExpr()) ? intExpr : expr.sum(decls);
return cache(intExpr, ret);
}
Aggregations