当前位置: 首页>>代码示例>>Java>>正文


Java Expression.compose方法代码示例

本文整理汇总了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);
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:27,代码来源:AbstractReplacer.java

示例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());
	}

}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:20,代码来源:TranslatorTest.java

示例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);
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:23,代码来源:AbstractReplacer.java


注:本文中的kodkod.ast.Expression.compose方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。