Java Code Examples for kodkod.ast.UnaryExpression#op()
The following examples show how to use
kodkod.ast.UnaryExpression#op() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FOL2BoolTranslator.java From org.alloytools.alloy with Apache License 2.0 | 6 votes |
/** * Calls lookup(unaryExpr) 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(unaryExpr) | some t => t, let op = * (unaryExpr.op).(TRANSPOSE->transpose + CLOSURE->closure + * REFLEXIVE_CLOSURE->(lambda(m)(m.closure().or(iden))) | * cache(unaryExpr, op(unaryExpr.child)) */ @Override public final BooleanMatrix visit(UnaryExpression unaryExpr) { BooleanMatrix ret = lookup(unaryExpr); if (ret != null) return ret; final BooleanMatrix child = unaryExpr.expression().accept(this); final ExprOperator op = unaryExpr.op(); switch (op) { case TRANSPOSE : ret = child.transpose(); break; case CLOSURE : ret = child.closure(); break; case REFLEXIVE_CLOSURE : ret = child.closure().or(visit((ConstantExpression) Expression.IDEN)); break; default : throw new IllegalArgumentException("Unknown operator: " + op); } return cache(unaryExpr, ret); }
Example 2
Source File: TranslateKodkodToJava.java From org.alloytools.alloy with Apache License 2.0 | 6 votes |
/** {@inheritDoc} */ @Override public void visit(UnaryExpression x) { String newname = makename(x); if (newname == null) return; String sub = make(x.expression()); switch (x.op()) { case CLOSURE : file.printf("Expression %s=%s.closure();%n", newname, sub); break; case REFLEXIVE_CLOSURE : file.printf("Expression %s=%s.reflexiveClosure();%n", newname, sub); break; case TRANSPOSE : file.printf("Expression %s=%s.transpose();%n", newname, sub); break; default : throw new RuntimeException("Unknown kodkod operator \"" + x.op() + "\" encountered"); } }
Example 3
Source File: FOL2BoolTranslator.java From kodkod with MIT License | 6 votes |
/** * Calls lookup(unaryExpr) 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(unaryExpr) | some t => t, * let op = (unaryExpr.op).(TRANSPOSE->transpose + CLOSURE->closure + REFLEXIVE_CLOSURE->(lambda(m)(m.closure().or(iden))) | * cache(unaryExpr, op(unaryExpr.child)) */ public final BooleanMatrix visit(UnaryExpression unaryExpr) { BooleanMatrix ret = lookup(unaryExpr); if (ret!=null) return ret; final BooleanMatrix child = unaryExpr.expression().accept(this); final ExprOperator op = unaryExpr.op(); switch(op) { case TRANSPOSE : ret = child.transpose(); break; case CLOSURE : ret = child.closure(); break; case REFLEXIVE_CLOSURE : ret = child.closure().or(visit((ConstantExpression)Expression.IDEN)); break; default : throw new IllegalArgumentException("Unknown operator: " + op); } return cache(unaryExpr,ret); }
Example 4
Source File: PartialCannonicalizer.java From quetzal with Eclipse Public License 2.0 | 6 votes |
public Expression visit(UnaryExpression expr) { Expression ret = lookup(expr); if (ret!=null) return ret; final ExprOperator op = expr.op(); final Expression child = expr.expression().accept(this); if (isEmpty(child)) return cache(expr, child); 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()==UnaryExpression.class) { if (((UnaryExpression)next).expression()==child) return cache(expr, next); } } ret = child==expr.expression() ? expr : child.apply(op); exprs.add(new PartialCannonicalizer.Holder<Expression>(ret, hash)); return cache(expr,ret); }
Example 5
Source File: Simplifier.java From quetzal with Eclipse Public License 2.0 | 5 votes |
public Expression visit(UnaryExpression expr) { Expression ret = lookup(expr); if (ret!=null) return ret; final ExprOperator op = expr.op(); final Expression child = expr.expression().accept(this); if (isEmpty(child)) return cache(expr, child); ret = child==expr.expression() ? expr : child.apply(op); return cache(expr,ret); }