本文整理汇总了Java中kodkod.ast.NaryExpression类的典型用法代码示例。如果您正苦于以下问题:Java NaryExpression类的具体用法?Java NaryExpression怎么用?Java NaryExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NaryExpression类属于kodkod.ast包,在下文中一共展示了NaryExpression类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: visit
import kodkod.ast.NaryExpression; //导入依赖的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: visit
import kodkod.ast.NaryExpression; //导入依赖的package包/类
/** {@inheritDoc} */
public void visit(NaryExpression x) {
String newname = makename(x); if (newname==null) return;
String[] list = new String[x.size()];
for(int i=0; i<list.length; i++) list[i] = make(x.child(i));
file.printf("Expression %s=Expression.compose(ExprOperator.", newname);
switch(x.op()) {
case INTERSECTION: file.print("INTERSECTION"); break;
case OVERRIDE: file.print("OVERRIDE"); break;
case PRODUCT: file.print("PRODUCT"); break;
case UNION: file.print("UNION"); break;
default: throw new RuntimeException("Unknown kodkod operator \""+x.op()+"\" encountered");
}
for(int i=0; i<list.length; i++) file.printf(", %s", list[i]);
file.printf(");%n");
}
开发者ID:ModelWriter,项目名称:Tarski,代码行数:17,代码来源:TranslateKodkodToJava.java
示例3: visit
import kodkod.ast.NaryExpression; //导入依赖的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
示例4: visit
import kodkod.ast.NaryExpression; //导入依赖的package包/类
/**
* Calls lookup(expr) and returns the cached value, if any.
* If a translation has not been cached, translates the expression,
* calls cache(...) on it and returns it.
* @return let t = lookup(expr) | some t => t,
* let op = (expr.op).(UNION->or + INTERSECTION->and + DIFFERENCE->difference + OVERRIDE->override + JOIN->dot + PRODUCT->cross) |
* cache(expr, op(expr.left.accept(this), expr.right.accept(this)))
*/
public BooleanMatrix visit(NaryExpression expr) {
BooleanMatrix ret = lookup(expr);
if (ret!=null) return ret;
final ExprOperator op = expr.op();
final BooleanMatrix first = expr.child(0).accept(this);
final BooleanMatrix[] rest = new BooleanMatrix[expr.size()-1];
for(int i = 0; i < rest.length; i++) { rest[i] = expr.child(i+1).accept(this); }
switch(op) {
case UNION : ret = first.or(rest); break;
case INTERSECTION : ret = first.and(rest); break;
case OVERRIDE : ret = first.override(rest); break;
case PRODUCT : ret = first.cross(rest); break;
default :
throw new IllegalArgumentException("Unknown associative operator: " + op);
}
return cache(expr, ret);
}
开发者ID:ModelWriter,项目名称:Tarski,代码行数:29,代码来源:FOL2BoolTranslator.java
示例5: isEmpty
import kodkod.ast.NaryExpression; //导入依赖的package包/类
/** @return true if e is (a product of) Expression.NONE*/
private boolean isEmpty(Expression e) {
if (e==Expression.NONE) return true;
else if (e instanceof BinaryExpression) {
final BinaryExpression b = (BinaryExpression) e;
return b.op()==ExprOperator.PRODUCT && isEmpty(b.left()) && isEmpty(b.right());
} else if (e instanceof NaryExpression) {
final NaryExpression n = (NaryExpression) e;
if (n.op()==ExprOperator.PRODUCT) {
for(int i = 0, max = n.size(); i < max; i++) {
if (!isEmpty(n.child(i))) return false;
}
return true;
}
}
return false;
}
开发者ID:wala,项目名称:MemSAT,代码行数:18,代码来源:PrettyPrinter.java
示例6: visit
import kodkod.ast.NaryExpression; //导入依赖的package包/类
public Expression visit(NaryExpression expr) {
Expression ret = lookup(expr);
if (ret!=null) return ret;
final ExprOperator op = expr.op();
final List<Expression> children = simplify(op, visitAll(expr));
final int size = children.size();
switch(size) {
case 0 : return cache(expr, empty(expr.arity()));
case 1 : return cache(expr, children.get(0));
default :
ret = expr.size()==size && allSame(expr,children) ? expr : Expression.compose(op, children);
return cache(expr,ret);
}
}
开发者ID:wala,项目名称:MemSAT,代码行数:17,代码来源:Simplifier.java
示例7: visit
import kodkod.ast.NaryExpression; //导入依赖的package包/类
/**
* Visits the children if this.visited(expr) returns false. Otherwise does
* nothing.
*
* @ensures all i: [0..#expr.children) | expr.child(i).accept(this)
*/
public void visit(NaryExpression expr) {
if (visited(expr))
return;
for (Expression child : expr) {
child.accept(this);
}
}
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:14,代码来源:AbstractVoidVisitor.java
示例8: visit
import kodkod.ast.NaryExpression; //导入依赖的package包/类
/**
* Calls lookup(expr) and returns the cached value, if any. If no cached
* value exists, visits each child, caches the union of the children's
* return values and returns it.
*
* @return let x = lookup(expr) | x != null => x, cache(expr,
* expr.child(0).accept(this) + .. +
* expr.child(expr.size()-1).accept(this))
*/
public Set<T> visit(NaryExpression expr) {
Set<T> ret = lookup(expr);
if (ret != null)
return ret;
ret = newSet();
for (Expression child : expr) {
ret.addAll(child.accept(this));
}
return cache(expr, ret);
}
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:20,代码来源:AbstractCollector.java
示例9: visit
import kodkod.ast.NaryExpression; //导入依赖的package包/类
/**
* Calls lookup(expr) and returns the cached value, if any. If no cached
* value exists, visits each child, caches the disjunction of the children's
* return values and returns it.
*
* @return let x = lookup(expr) | x != null => x, cache(expr,
* expr.child(0).accept(this) || ... ||
* expr.child(expr.size()-1).accept(this))
*/
public Boolean visit(NaryExpression expr) {
final Boolean ret = lookup(expr);
if (ret != null)
return ret;
for (Expression child : expr) {
if (child.accept(this))
return cache(expr, true);
}
return cache(expr, false);
}
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:20,代码来源:AbstractDetector.java
示例10: visit
import kodkod.ast.NaryExpression; //导入依赖的package包/类
/**
* Calls lookup(expr) and returns the cached value, if any. If a translation
* has not been cached, translates the expression, calls cache(...) on it
* and returns it.
*
* @return let t = lookup(expr) | some t => t, let op = (expr.op).(UNION->or
* + INTERSECTION->and + DIFFERENCE->difference + OVERRIDE->override
* + JOIN->dot + PRODUCT->cross) | cache(expr,
* op(expr.left.accept(this), expr.right.accept(this)))
*/
public BooleanMatrix visit(NaryExpression expr) {
BooleanMatrix ret = lookup(expr);
if (ret != null)
return ret;
final ExprOperator op = expr.op();
final BooleanMatrix first = expr.child(0).accept(this);
final BooleanMatrix[] rest = new BooleanMatrix[expr.size() - 1];
for (int i = 0; i < rest.length; i++) {
rest[i] = expr.child(i + 1).accept(this);
}
switch (op) {
case UNION :
ret = first.or(rest);
break;
case INTERSECTION :
ret = first.and(rest);
break;
case OVERRIDE :
ret = first.override(rest);
break;
case PRODUCT :
ret = first.cross(rest);
break;
default :
throw new IllegalArgumentException("Unknown associative operator: " + op);
}
return cache(expr, ret);
}
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:42,代码来源:FOL2BoolTranslator.java
示例11: visit
import kodkod.ast.NaryExpression; //导入依赖的package包/类
/**
* @ensures appends the tokenization of the given node to this.tokens
*/
public void visit(NaryExpression node) {
final ExprOperator op = node.op();
visitChild(node.child(0), parenthesize(op, node.child(0)));
for (int i = 1, size = node.size(); i < size; i++) {
infix(op);
visitChild(node.child(i), parenthesize(op, node.child(i)));
}
}
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:12,代码来源:PrettyPrinter.java
示例12: visit
import kodkod.ast.NaryExpression; //导入依赖的package包/类
/** {@inheritDoc} */
public void visit(NaryExpression x) {
String newname = makename(x);
if (newname == null)
return;
String[] list = new String[x.size()];
for (int i = 0; i < list.length; i++)
list[i] = make(x.child(i));
file.printf("Expression %s=Expression.compose(ExprOperator.", newname);
switch (x.op()) {
case INTERSECTION :
file.print("INTERSECTION");
break;
case OVERRIDE :
file.print("OVERRIDE");
break;
case PRODUCT :
file.print("PRODUCT");
break;
case UNION :
file.print("UNION");
break;
default :
throw new RuntimeException("Unknown kodkod operator \"" + x.op() + "\" encountered");
}
for (int i = 0; i < list.length; i++)
file.printf(", %s", list[i]);
file.printf(");%n");
}
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:30,代码来源:TranslateKodkodToJava.java
示例13: visit
import kodkod.ast.NaryExpression; //导入依赖的package包/类
/**
* Visits the children if this.visited(expr) returns false. Otherwise does nothing.
* @ensures all i: [0..#expr.children) | expr.child(i).accept(this)
*/
public void visit(NaryExpression expr) {
if (visited(expr)) return;
for(Expression child : expr) {
child.accept(this);
}
}
开发者ID:ModelWriter,项目名称:Tarski,代码行数:11,代码来源:AbstractVoidVisitor.java
示例14: visit
import kodkod.ast.NaryExpression; //导入依赖的package包/类
/**
* Calls lookup(expr) and returns the cached value, if any.
* If no cached value exists, visits each child, caches the
* union of the children's return values and returns it.
* @return let x = lookup(expr) |
* x != null => x,
* cache(expr, expr.child(0).accept(this) + .. + expr.child(expr.size()-1).accept(this))
*/
public Set<T> visit(NaryExpression expr) {
Set<T> ret = lookup(expr);
if (ret!=null) return ret;
ret = newSet();
for(Expression child : expr) {
ret.addAll(child.accept(this));
}
return cache(expr, ret);
}
开发者ID:ModelWriter,项目名称:Tarski,代码行数:18,代码来源:AbstractCollector.java
示例15: visit
import kodkod.ast.NaryExpression; //导入依赖的package包/类
/**
* Calls lookup(expr) and returns the cached value, if any.
* If no cached value exists, visits each child, caches the
* disjunction of the children's return values and returns it.
* @return let x = lookup(expr) |
* x != null => x,
* cache(expr, expr.child(0).accept(this) || ... || expr.child(expr.size()-1).accept(this))
*/
public Boolean visit(NaryExpression expr) {
final Boolean ret = lookup(expr);
if (ret!=null) return ret;
for(Expression child : expr) {
if (child.accept(this))
return cache(expr, true);
}
return cache(expr, false);
}
开发者ID:ModelWriter,项目名称:Tarski,代码行数:18,代码来源:AbstractDetector.java
示例16: parenthesize
import kodkod.ast.NaryExpression; //导入依赖的package包/类
/** @return true if the given expression needs to be parenthesized if a
* child of a binary expression with the given operator */
private boolean parenthesize(ExprOperator op, Expression child) {
return child instanceof IfExpression ||
child instanceof NaryExpression ||
(child instanceof BinaryExpression &&
(op==ExprOperator.JOIN ||
((BinaryExpression)child).op()!=op));
}
开发者ID:ModelWriter,项目名称:Tarski,代码行数:10,代码来源:PrettyPrinter.java
示例17: visit
import kodkod.ast.NaryExpression; //导入依赖的package包/类
/** @ensures appends the tokenization of the given node to this.tokens */
public void visit(NaryExpression node) {
final ExprOperator op = node.op();
visitChild(node.child(0), parenthesize(op, node.child(0)));
for(int i = 1, size = node.size(); i < size; i++) {
infix(op);
visitChild(node.child(i), parenthesize(op, node.child(i)));
}
}
开发者ID:ModelWriter,项目名称:Tarski,代码行数:10,代码来源:PrettyPrinter.java
示例18: parenthesize
import kodkod.ast.NaryExpression; //导入依赖的package包/类
/** @return true if the given expression needs to be parenthesized if a
* child of a binary expression with the given operator */
private boolean parenthesize(ExprOperator op, Expression child) {
return display.containsKey(child.toString()) ? false :
child instanceof IfExpression ||
(child instanceof NaryExpression && ((NaryExpression)child).op()!=op) ||
(child instanceof BinaryExpression &&
(/*op!=ExprOperator.JOIN && */
((BinaryExpression)child).op()!=op));
}
开发者ID:wala,项目名称:MemSAT,代码行数:11,代码来源:PrettyPrinter.java
示例19: visit
import kodkod.ast.NaryExpression; //导入依赖的package包/类
/** @effects appends the tokenization of the given node to this.tokens */
public void visit(NaryExpression node) {
if (displayed(node)) return;
final boolean oldTop = notTop();
final ExprOperator op = node.op();
visitChild(node.child(0), parenthesize(op, node.child(0)));
for(int i = 1, size = node.size(); i < size; i++) {
infix(op);
visitChild(node.child(i), parenthesize(op, node.child(i)));
}
top = oldTop;
}
开发者ID:wala,项目名称:MemSAT,代码行数:13,代码来源:PrettyPrinter.java
示例20: visit
import kodkod.ast.NaryExpression; //导入依赖的package包/类
@Override
public E visit(NaryExpression expr) {
start(expr);
return end(expr, visitor.visit(expr));
}
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:6,代码来源:AspectReturnVisitor.java
注:本文中的kodkod.ast.NaryExpression类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论