本文整理汇总了Java中kodkod.ast.IntToExprCast类的典型用法代码示例。如果您正苦于以下问题:Java IntToExprCast类的具体用法?Java IntToExprCast怎么用?Java IntToExprCast使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IntToExprCast类属于kodkod.ast包,在下文中一共展示了IntToExprCast类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visit
import kodkod.ast.IntToExprCast; //导入依赖的package包/类
/** {@inheritDoc} */
public void visit(IntToExprCast x) {
String newname = makename(x);
if (newname == null)
return;
String sub = make(x.intExpr());
switch (x.op()) {
case INTCAST :
file.printf("Expression %s=%s.toExpression();%n", newname, sub);
break;
case BITSETCAST :
file.printf("Expression %s=%s.toBitset();%n", newname, sub);
break;
default :
throw new RuntimeException("Unknown kodkod operator \"" + x.op() + "\" encountered");
}
}
示例2: toInt
import kodkod.ast.IntToExprCast; //导入依赖的package包/类
private IntExpression toInt(Expr x, Object y) throws Err, ErrorFatal {
// simplify: if y is int[Int[sth]] then return sth
if (y instanceof ExprToIntCast) {
ExprToIntCast y2 = (ExprToIntCast) y;
if (y2.expression() instanceof IntToExprCast)
return ((IntToExprCast) y2.expression()).intExpr();
}
// simplify: if y is Int[sth], then return sth
if (y instanceof IntToExprCast)
return ((IntToExprCast) y).intExpr();
if (y instanceof IntExpression)
return (IntExpression) y;
// [AM]: maybe this conversion should be removed
if (y instanceof Expression)
return ((Expression) y).sum();
throw new ErrorFatal(x.span(), "This should have been an integer expression.\nInstead it is " + y);
}
示例3: toInt
import kodkod.ast.IntToExprCast; //导入依赖的package包/类
private IntExpression toInt(Expr x, Object y) throws Err, ErrorFatal {
// simplify: if y is int[Int[sth]] then return sth
if (y instanceof ExprToIntCast) {
ExprToIntCast y2 = (ExprToIntCast) y;
if (y2.expression() instanceof IntToExprCast)
return ((IntToExprCast)y2.expression()).intExpr();
}
// simplify: if y is Int[sth], then return sth
if (y instanceof IntToExprCast)
return ((IntToExprCast) y).intExpr();
if (y instanceof IntExpression)
return (IntExpression)y;
//[AM]: maybe this conversion should be removed
if (y instanceof Expression) return ((Expression) y).sum();
throw new ErrorFatal(x.span(), "This should have been an integer expression.\nInstead it is "+y);
}
示例4: visit
import kodkod.ast.IntToExprCast; //导入依赖的package包/类
public Expression visit(IntToExprCast expr) {
Expression ret = lookup(expr);
if (ret!=null) return ret;
final IntCastOperator op = expr.op();
final IntExpression child = expr.intExpr().accept(this);
final int hash = hash(op, child);
for(Iterator<PartialCannonicalizer.Holder<Expression>> itr = exprs.get(hash); itr.hasNext(); ) {
final Expression next = itr.next().obj;
if (next.getClass()==IntToExprCast.class) {
if (((IntToExprCast)next).intExpr()==child)
return cache(expr, next);
}
}
ret = child==expr.intExpr() ? expr : child.cast(op);
exprs.add(new PartialCannonicalizer.Holder<Expression>(ret, hash));
return cache(expr,ret);
}
示例5: visit
import kodkod.ast.IntToExprCast; //导入依赖的package包/类
/**
* Calls lookup(castExpr) 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 { e: Expression | e =
* castExpr.intExpr.accept(delegate).toExpression() }
*/
public Expression visit(IntToExprCast castExpr) {
Expression ret = lookup(castExpr);
if (ret != null)
return ret;
final IntExpression intExpr = castExpr.intExpr().accept(delegate);
ret = (intExpr == castExpr.intExpr()) ? castExpr : intExpr.cast(castExpr.op());
return cache(castExpr, ret);
}
示例6: visit
import kodkod.ast.IntToExprCast; //导入依赖的package包/类
/**
* Calls lookup(castExpr) and returns the cached value, if any. If no cached
* value exists, visits the child, caches its return value and returns it.
*
* @return let x = lookup(castExpr) | x != null => x, cache(intExpr,
* castExpr.intExpr.accept(this))
*/
public Set<T> visit(IntToExprCast castExpr) {
Set<T> ret = lookup(castExpr);
if (ret != null)
return ret;
ret = newSet();
ret.addAll(castExpr.intExpr().accept(this));
return cache(castExpr, ret);
}
示例7: visit
import kodkod.ast.IntToExprCast; //导入依赖的package包/类
/**
* @ensures this.tokens' = concat[ this.tokens, "Int","[",
* tokenize[node.intExpr], "]" ]
**/
public void visit(IntToExprCast node) {
append("Int");
append("[");
node.intExpr().accept(this);
append("]");
}
示例8: sum
import kodkod.ast.IntToExprCast; //导入依赖的package包/类
/**
* Performs int[x]; contains an efficiency shortcut that simplifies
* int[Int[x]] to x.
*/
private IntExpression sum(Expression x) {
if (x instanceof IntToExprCast)
return ((IntToExprCast) x).intExpr();
else
return x.sum();
}
示例9: visit
import kodkod.ast.IntToExprCast; //导入依赖的package包/类
/** {@inheritDoc} */
public void visit(IntToExprCast x) {
String newname=makename(x); if (newname==null) return;
String sub=make(x.intExpr());
switch(x.op()) {
case INTCAST: file.printf("Expression %s=%s.toExpression();%n", newname, sub); break;
case BITSETCAST: file.printf("Expression %s=%s.toBitset();%n", newname, sub); break;
default: throw new RuntimeException("Unknown kodkod operator \""+x.op()+"\" encountered");
}
}
示例10: visit
import kodkod.ast.IntToExprCast; //导入依赖的package包/类
/**
* Calls lookup(castExpr) 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 { e: Expression | e = castExpr.intExpr.accept(this).toExpression() }
*/
public Expression visit(IntToExprCast castExpr) {
Expression ret = lookup(castExpr);
if (ret!=null) return ret;
final IntExpression intExpr = castExpr.intExpr().accept(this);
ret = (intExpr==castExpr.intExpr()) ? castExpr : intExpr.cast(castExpr.op());
return cache(castExpr, ret);
}
示例11: visit
import kodkod.ast.IntToExprCast; //导入依赖的package包/类
/**
* Calls lookup(castExpr) and returns the cached value, if any.
* If no cached value exists, visits the child, caches its return value and returns it.
* @return let x = lookup(castExpr) |
* x != null => x,
* cache(intExpr, castExpr.intExpr.accept(this))
*/
public Set<T> visit(IntToExprCast castExpr) {
Set<T> ret = lookup(castExpr);
if (ret!=null) return ret;
ret = newSet();
ret.addAll(castExpr.intExpr().accept(this));
return cache(castExpr,ret);
}
示例12: visit
import kodkod.ast.IntToExprCast; //导入依赖的package包/类
/** @ensures this.tokens' = concat[ this.tokens, "Int","[",
* tokenize[node.intExpr], "]" ] **/
public void visit(IntToExprCast node) {
append("Int");
append("[");
node.intExpr().accept(this);
append("]");
}
示例13: visit
import kodkod.ast.IntToExprCast; //导入依赖的package包/类
/**
* Calls lookup(castExpr) 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(castExpr) | some t => t,
* cache(castExpr, translate(castExpr))
*/
public BooleanMatrix visit(IntToExprCast castExpr) {
BooleanMatrix ret = lookup(castExpr);
if (ret!=null) return ret;
final Int child = castExpr.intExpr().accept(this);
final BooleanFactory factory = interpreter.factory();
final IntSet ints = interpreter.ints();
ret = factory.matrix(Dimensions.square(interpreter.universe().size(), 1));
switch(castExpr.op()) {
case INTCAST :
for(IntIterator iter = ints.iterator(); iter.hasNext(); ) {
int i = iter.next();
int atomIndex = interpreter.interpret(i);
ret.set(atomIndex, factory.or(ret.get(atomIndex), child.eq(factory.integer(i))));
}
break;
case BITSETCAST :
final List<BooleanValue> twosComplement = child.twosComplementBits();
final int msb = twosComplement.size()-1;
// handle all bits but the sign bit
for(int i = 0; i < msb; i++) {
int pow2 = 1<<i;
if (ints.contains(pow2)) {
ret.set(interpreter.interpret(pow2), twosComplement.get(i));
}
}
// handle the sign bit
if (ints.contains(-1<<msb)) {
ret.set(interpreter.interpret(-1<<msb), twosComplement.get(msb));
}
break;
default :
throw new IllegalArgumentException("Unknown cast operator: " + castExpr.op());
}
return cache(castExpr, ret);
}
示例14: node2int
import kodkod.ast.IntToExprCast; //导入依赖的package包/类
/** converts a Kodkod expression to a Kodkod integer. */
protected IntExpression node2int(Node node) {
if (node instanceof Expression)
return ((Expression) node).sum();
if (node instanceof IntExpression)
return (IntExpression) node;
if (node instanceof IntToExprCast)
return ((IntToExprCast) node).intExpr();
throw new RuntimeException("don't know how to convert " + node.getClass().getSimpleName() + " to int");
}
示例15: visit
import kodkod.ast.IntToExprCast; //导入依赖的package包/类
/** @effects this.tokens' = concat[ this.tokens, "Int","[",
* tokenize[node.intExpr], "]" ] **/
public void visit(IntToExprCast node) {
if (displayed(node)) return;
final boolean oldTop = notTop();
append(node.op()==IntCastOperator.INTCAST ? "Int" : "Bits");
append("[");
node.intExpr().accept(this);
append("]");
top = oldTop;
}