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


Java IntToExprCast类代码示例

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

示例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);
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:18,代码来源:TranslateAlloyToKodkod.java

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

示例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);
}
 
开发者ID:wala,项目名称:MemSAT,代码行数:20,代码来源:PartialCannonicalizer.java

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

示例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);
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:16,代码来源:AbstractCollector.java

示例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("]");
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:11,代码来源:PrettyPrinter.java

示例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();
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:11,代码来源:TranslateAlloyToKodkod.java

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

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

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

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

示例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);
}
 
开发者ID:emina,项目名称:kodkod,代码行数:47,代码来源:FOL2BoolTranslator.java

示例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");
}
 
开发者ID:aleksandarmilicevic,项目名称:squander,代码行数:11,代码来源:SquanderKodkodImpl.java

示例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;
}
 
开发者ID:wala,项目名称:MemSAT,代码行数:12,代码来源:PrettyPrinter.java


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