本文整理汇总了Java中kodkod.ast.Expression.compose方法的典型用法代码示例。如果您正苦于以下问题:Java Expression.compose方法的具体用法?Java Expression.compose怎么用?Java Expression.compose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kodkod.ast.Expression
的用法示例。
在下文中一共展示了Expression.compose方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visit
import kodkod.ast.Expression; //导入方法依赖的package包/类
/**
* Calls lookup(expr) and returns the cached value, if any. If a replacement
* has not been cached, visits the expr's children. If nothing changes, the
* argument is cached and returned, otherwise a replacement expr is cached
* and returned.
*
* @return { e: Expression | e.op = expr.op && #e.children = #expr.children
* && all i: [0..expr.children) | e.child(i) =
* expr.child(i).accept(delegate) }
*/
public Expression visit(NaryExpression expr) {
Expression ret = lookup(expr);
if (ret != null)
return ret;
final Expression[] visited = new Expression[expr.size()];
boolean allSame = true;
for (int i = 0; i < visited.length; i++) {
final Expression child = expr.child(i);
visited[i] = child.accept(delegate);
allSame = allSame && visited[i] == child;
}
ret = allSame ? expr : Expression.compose(expr.op(), visited);
return cache(expr, ret);
}
示例2: testNary
import kodkod.ast.Expression; //导入方法依赖的package包/类
private final void testNary(ExprOperator op) {
bounds.bound(r1[0], factory.range(factory.tuple(1, 0), factory.tuple(1, 3)));
bounds.bound(r1[1], factory.range(factory.tuple(1, 2), factory.tuple(1, 5)));
bounds.bound(r1[3], factory.range(factory.tuple(1, 3), factory.tuple(1, 6)));
for (int i = 2; i <= 5; i++) {
final Expression[] exprs = new Expression[i];
exprs[0] = r1[0];
Expression binExpr = r1[0];
for (int j = 1; j < i; j++) {
binExpr = binExpr.compose(op, r1[j % 4]);
exprs[j] = r1[j % 4];
}
Expression nExpr = Expression.compose(op, exprs);
final Solution sol = solver.solve(binExpr.eq(nExpr).not(), bounds);
assertNull(sol.instance());
}
}
示例3: visit
import kodkod.ast.Expression; //导入方法依赖的package包/类
/**
* Calls lookup(expr) and returns the cached value, if any.
* If a replacement has not been cached, visits the expr's
* children. If nothing changes, the argument is cached and
* returned, otherwise a replacement expr is cached and returned.
* @return { e: Expression | e.op = expr.op && #e.children = #expr.children && all i: [0..expr.children) | e.child(i) = expr.child(i).accept(this) }
*/
public Expression visit(NaryExpression expr) {
Expression ret = lookup(expr);
if (ret!=null) return ret;
final Expression[] visited = new Expression[expr.size()];
boolean allSame = true;
for(int i = 0 ; i < visited.length; i++) {
final Expression child = expr.child(i);
visited[i] = child.accept(this);
allSame = allSame && visited[i]==child;
}
ret = allSame ? expr : Expression.compose(expr.op(), visited);
return cache(expr,ret);
}