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


Java BinaryExpression.op方法代码示例

本文整理汇总了Java中kodkod.ast.BinaryExpression.op方法的典型用法代码示例。如果您正苦于以下问题:Java BinaryExpression.op方法的具体用法?Java BinaryExpression.op怎么用?Java BinaryExpression.op使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在kodkod.ast.BinaryExpression的用法示例。


在下文中一共展示了BinaryExpression.op方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: visit

import kodkod.ast.BinaryExpression; //导入方法依赖的package包/类
/**
 * Calls lookup(binExpr) 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(binExpr) | some t => t, 
 *      let op = (binExpr.op).(UNION->or + INTERSECTION->and + DIFFERENCE->difference + OVERRIDE->override + JOIN->dot + PRODUCT->cross) | 
 *       cache(binExpr, op(binExpr.left.accept(this), binExpr.right.accept(this)))
 */
public BooleanMatrix visit(BinaryExpression binExpr) {
	BooleanMatrix ret = lookup(binExpr);
	if (ret!=null) return ret;

	final BooleanMatrix left = binExpr.left().accept(this);
	final BooleanMatrix right = binExpr.right().accept(this);
	final ExprOperator op = binExpr.op();

	switch(op) {
	case UNION        	: ret = left.or(right); break;
	case INTERSECTION	: ret = left.and(right); break;
	case DIFFERENCE 	: ret = left.difference(right); break;
	case OVERRIDE 		: ret = left.override(right); break;
	case JOIN 			: ret = left.dot(right); break;
	case PRODUCT		: ret = left.cross(right); break;
	default : 
		throw new IllegalArgumentException("Unknown operator: " + op);
	}

	return cache(binExpr, ret);
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:30,代码来源:FOL2BoolTranslator.java

示例2: visit

import kodkod.ast.BinaryExpression; //导入方法依赖的package包/类
/** @effects appends the tokenization of the given node to this.tokens */
public void visit(BinaryExpression node) {
	if (displayed(node)) return;
	final boolean oldTop = notTop();
	final ExprOperator op = node.op();
	final Expression left = node.left(), right = node.right();
	if (op==ExprOperator.JOIN && left.arity()==1 && right.arity()==2 && right instanceof Relation) { 
		append(right);
		append("[");
		visitChild(left, false);
		append("]");
	} else {
		visitChild(left, parenthesize(op, left));
		infix(op);
		visitChild(right, parenthesize(op, right));
	}
	top = oldTop;
}
 
开发者ID:wala,项目名称:MemSAT,代码行数:19,代码来源:PrettyPrinter.java

示例3: isEmpty

import kodkod.ast.BinaryExpression; //导入方法依赖的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

示例4: visit

import kodkod.ast.BinaryExpression; //导入方法依赖的package包/类
/**
 * Calls lookup(binExpr) 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(binExpr) | some t => t, let op =
 *         (binExpr.op).(UNION->or + INTERSECTION->and +
 *         DIFFERENCE->difference + OVERRIDE->override + JOIN->dot +
 *         PRODUCT->cross) | cache(binExpr, op(binExpr.left.accept(this),
 *         binExpr.right.accept(this)))
 */
public BooleanMatrix visit(BinaryExpression binExpr) {
	BooleanMatrix ret = lookup(binExpr);
	if (ret != null)
		return ret;

	final BooleanMatrix left = binExpr.left().accept(this);
	final BooleanMatrix right = binExpr.right().accept(this);
	final ExprOperator op = binExpr.op();

	switch (op) {
		case UNION :
			ret = left.or(right);
			break;
		case INTERSECTION :
			ret = left.and(right);
			break;
		case DIFFERENCE :
			ret = left.difference(right);
			break;
		case OVERRIDE :
			ret = left.override(right);
			break;
		case JOIN :
			ret = left.dot(right);
			break;
		case PRODUCT :
			ret = left.cross(right);
			break;
		default :
			throw new IllegalArgumentException("Unknown operator: " + op);
	}

	return cache(binExpr, ret);
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:46,代码来源:FOL2BoolTranslator.java

示例5: visit

import kodkod.ast.BinaryExpression; //导入方法依赖的package包/类
/**
 * @ensures appends the tokenization of the given node to this.tokens
 */
public void visit(BinaryExpression node) {
	final ExprOperator op = node.op();
	visitChild(node.left(), parenthesize(op, node.left()));
	infix(op);
	visitChild(node.right(), parenthesize(op, node.right()));
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:10,代码来源:PrettyPrinter.java

示例6: visit

import kodkod.ast.BinaryExpression; //导入方法依赖的package包/类
/** {@inheritDoc} */
public void visit(BinaryExpression x) {
	String newname = makename(x);
	if (newname == null)
		return;
	String left = make(x.left());
	String right = make(x.right());
	switch (x.op()) {
		case DIFFERENCE :
			file.printf("Expression %s=%s.difference(%s);%n", newname, left, right);
			break;
		case INTERSECTION :
			file.printf("Expression %s=%s.intersection(%s);%n", newname, left, right);
			break;
		case JOIN :
			file.printf("Expression %s=%s.join(%s);%n", newname, left, right);
			break;
		case OVERRIDE :
			file.printf("Expression %s=%s.override(%s);%n", newname, left, right);
			break;
		case PRODUCT :
			file.printf("Expression %s=%s.product(%s);%n", newname, left, right);
			break;
		case UNION :
			file.printf("Expression %s=%s.union(%s);%n", newname, left, right);
			break;
		default :
			throw new RuntimeException("Unknown kodkod operator \"" + x.op() + "\" encountered");
	}
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:31,代码来源:TranslateKodkodToJava.java

示例7: right

import kodkod.ast.BinaryExpression; //导入方法依赖的package包/类
/**
 * If x = SOMETHING->RELATION where SOMETHING.arity==1, then return the
 * RELATION, else return null.
 */
private static Relation right(Expression x) {
	if (!(x instanceof BinaryExpression))
		return null;
	BinaryExpression bin = (BinaryExpression) x;
	if (bin.op() != ExprOperator.PRODUCT)
		return null;
	if (bin.left().arity() == 1 && bin.right() instanceof Relation)
		return (Relation) (bin.right());
	else
		return null;
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:16,代码来源:TranslateAlloyToKodkod.java

示例8: visit

import kodkod.ast.BinaryExpression; //导入方法依赖的package包/类
/** {@inheritDoc} */
public void visit(BinaryExpression x) {
    String newname=makename(x); if (newname==null) return;
    String left=make(x.left());
    String right=make(x.right());
    switch(x.op()) {
       case DIFFERENCE: file.printf("Expression %s=%s.difference(%s);%n", newname, left, right); break;
       case INTERSECTION: file.printf("Expression %s=%s.intersection(%s);%n", newname, left, right); break;
       case JOIN: file.printf("Expression %s=%s.join(%s);%n", newname, left, right); break;
       case OVERRIDE: file.printf("Expression %s=%s.override(%s);%n", newname, left, right); break;
       case PRODUCT: file.printf("Expression %s=%s.product(%s);%n", newname, left, right); break;
       case UNION: file.printf("Expression %s=%s.union(%s);%n", newname, left, right); break;
       default: throw new RuntimeException("Unknown kodkod operator \""+x.op()+"\" encountered");
    }
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:16,代码来源:TranslateKodkodToJava.java

示例9: right

import kodkod.ast.BinaryExpression; //导入方法依赖的package包/类
/** If x = SOMETHING->RELATION where SOMETHING.arity==1, then return the RELATION, else return null. */
private static Relation right(Expression x) {
    if (!(x instanceof BinaryExpression)) return null;
    BinaryExpression bin = (BinaryExpression)x;
    if (bin.op() != ExprOperator.PRODUCT) return null;
    if (bin.left().arity()==1 && bin.right() instanceof Relation) return (Relation)(bin.right()); else return null;
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:8,代码来源:TranslateAlloyToKodkod.java

示例10: visit

import kodkod.ast.BinaryExpression; //导入方法依赖的package包/类
/** @ensures appends the tokenization of the given node to this.tokens */
public void visit(BinaryExpression node) {
	final ExprOperator op = node.op();
	visitChild(node.left(), parenthesize(op, node.left()));
	infix(op);
	visitChild(node.right(), parenthesize(op, node.right()));
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:8,代码来源:PrettyPrinter.java

示例11: visit

import kodkod.ast.BinaryExpression; //导入方法依赖的package包/类
public Expression visit(BinaryExpression expr) { 
	Expression ret = lookup(expr);
	if (ret!=null) return ret;
	final ExprOperator op = expr.op();
	final Expression left = expr.left().accept(this);
	final Expression right = expr.right().accept(this);
	
	ret = simplify(op, left, right);
	
	if (ret==null) {
	
		final int hash = hash(op, left, right);
		for(Iterator<PartialCannonicalizer.Holder<Expression>> itr = exprs.get(hash); itr.hasNext(); ) {
			final Expression next = itr.next().obj;
			if (next instanceof BinaryExpression) { 
				final BinaryExpression hit = (BinaryExpression) next;
				if (hit.op()==op && hit.left()==left && hit.right()==right) { 
					return cache(expr, hit);
				}
			}
		}

		ret = left==expr.left()&&right==expr.right() ? expr : left.compose(op, right);
		exprs.add(new PartialCannonicalizer.Holder<Expression>(ret, hash));
	}
	
	return cache(expr,ret);
}
 
开发者ID:wala,项目名称:MemSAT,代码行数:29,代码来源:PartialCannonicalizer.java

示例12: visit

import kodkod.ast.BinaryExpression; //导入方法依赖的package包/类
public Expression visit(BinaryExpression expr) { 
	Expression ret = lookup(expr);
	if (ret!=null) return ret;
	final ExprOperator op = expr.op();
	final Expression left = expr.left().accept(this);
	final Expression right = expr.right().accept(this);
	
	ret = simplify(op, left, right);
	
	if (ret==null) {
		ret = left==expr.left()&&right==expr.right() ? expr : left.compose(op, right);
	}
	
	return cache(expr,ret);
}
 
开发者ID:wala,项目名称:MemSAT,代码行数:16,代码来源:Simplifier.java

示例13: makeReadable

import kodkod.ast.BinaryExpression; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private Formula makeReadable(Formula formula) { 
	final List<Formula> replacements = new ArrayList<Formula>();
	final Map<Expression, Integer> levels = new LinkedHashMap<Expression, Integer>();
	final AbstractReplacer replacer = new AbstractReplacer(Collections.EMPTY_SET) { 
		protected <N extends Node> N cache(N node, N replacement) {
			cache.put(node, replacement);
			return replacement;
		}
		public Expression visit(BinaryExpression expr) { 
			Expression ret = lookup(expr);
			if (ret!=null) return ret;
			final Expression left = expr.left().accept(this);
			final Expression right = expr.right().accept(this);
			if (expr.op()==ExprOperator.OVERRIDE && left instanceof Relation) { 
				final int level = levels.containsKey(left) ? levels.get(left) : 0;
				final Relation r = Relation.nary(((Relation)left).name()+"'", expr.arity());
				replacements.add(r.eq(left.compose(expr.op(), right)));
				levels.put(left, level+1);
				return cache(expr, r);
			}
			return cache(expr, left.compose(expr.op(), right));
		}
	};
	
	int size;
	do {
		size = replacements.size();
		formula = formula.accept(replacer);
	} while (size < replacements.size());
	
	return formula.and(Formula.and(replacements));
}
 
开发者ID:wala,项目名称:MemSAT,代码行数:34,代码来源:AngelicTests.java


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