kodkod.ast.UnaryExpression Java Examples
The following examples show how to use
kodkod.ast.UnaryExpression.
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: 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 #2
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 #3
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 #4
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 #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); }
Example #6
Source File: PrettyPrinter.java From quetzal with Eclipse Public License 2.0 | 5 votes |
/** @effects appends the given op and child to this.tokens; the child is * parenthesized if it's an instance of binary expression or an if expression. **/ public void visit(UnaryExpression node) { if (displayed(node)) return; final boolean oldTop = notTop(); append(node.op()); visitChild(node.expression(), parenthesize(node.expression())); top = oldTop; }
Example #7
Source File: AbstractCollector.java From kodkod with MIT License | 5 votes |
/** * Calls lookup(unaryExpr) 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(unaryExpr) | * x != null => x, * cache(unaryExpr, unaryExpr.expression.accept(this)) */ public Set<T> visit(UnaryExpression unaryExpr) { Set<T> ret = lookup(unaryExpr); if (ret!=null) return ret; ret = newSet(); ret.addAll(unaryExpr.expression().accept(this)); return cache(unaryExpr,ret); }
Example #8
Source File: AbstractReplacer.java From kodkod with MIT License | 5 votes |
/** * Calls lookup(unaryExpr) 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 { u: UnaryExpression | u.left = unaryExpr.expression.accept(this) && u.op = unaryExpr.op } */ public Expression visit(UnaryExpression unaryExpr) { Expression ret = lookup(unaryExpr); if (ret!=null) return ret; final Expression child = unaryExpr.expression().accept(this); ret = (child==unaryExpr.expression()) ? unaryExpr : child.apply(unaryExpr.op()); return cache(unaryExpr,ret); }
Example #9
Source File: AbstractReplacer.java From org.alloytools.alloy with Apache License 2.0 | 5 votes |
/** * Calls lookup(unaryExpr) 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 { u: UnaryExpression | u.left = unaryExpr.expression.accept(delegate) * && u.op = unaryExpr.op } */ @Override public Expression visit(UnaryExpression unaryExpr) { Expression ret = lookup(unaryExpr); if (ret != null) return ret; final Expression child = unaryExpr.expression().accept(delegate); ret = (child == unaryExpr.expression()) ? unaryExpr : child.apply(unaryExpr.op()); return cache(unaryExpr, ret); }
Example #10
Source File: AbstractVoidVisitor.java From org.alloytools.alloy with Apache License 2.0 | 5 votes |
/** * Visits the subexpression if this.visited(unaryExpr) returns false. Otherwise * does nothing. * * @ensures unaryExpr.expression.accept(this) */ @Override public void visit(UnaryExpression unaryExpr) { if (visited(unaryExpr)) return; unaryExpr.expression().accept(this); }
Example #11
Source File: AbstractCollector.java From org.alloytools.alloy with Apache License 2.0 | 5 votes |
/** * Calls lookup(unaryExpr) 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(unaryExpr) | x != null => x, cache(unaryExpr, * unaryExpr.expression.accept(this)) */ @Override public Set<T> visit(UnaryExpression unaryExpr) { Set<T> ret = lookup(unaryExpr); if (ret != null) return ret; ret = newSet(); ret.addAll(unaryExpr.expression().accept(this)); return cache(unaryExpr, ret); }
Example #12
Source File: HOLTranslationNew.java From org.alloytools.alloy with Apache License 2.0 | 4 votes |
public boolean solveNext() { convInst = null; iterCnt = 0; int maxIter = options.getHolSome4AllMaxIter(); HOLTranslation currTr = convTr; while (currTr.cnf().solve()) { final Instance currInst = currTr.interpret(); final Evaluator eval = new Evaluator(currInst); convTr = currTr; convInst = currTr.interpret(); if (iterCnt == 0) rep.holFixpointFirstSolution(Fixpoint.this, currInst); else rep.holFixpointIncrementingOutcome(Fixpoint.this, currInst); if (maxIter > 0 && iterCnt > maxIter) throw new HOLException("[Fixpoint] Max number of iterations reached: " + maxIter); iterCnt++; // TODO: works only when inc is first order Formula inc = proc.fullConditionFormula().accept(new AbstractReplacer(new HashSet<Node>()) { @Override public Expression visit(UnaryExpression unaryExpr) { if (unaryExpr.op() != ExprOperator.PRE) return super.visit(unaryExpr); TupleSet val = eval.evaluate(unaryExpr.expression()); return bounds.ts2expr(val); } }); // if (iterCnt == 1) { // List<Formula> fix = new // ArrayList<Formula>(bounds.relations().size()); // for (Relation r: bounds.relations()) { // if (r.isAtom()) continue; // if (!r.name().endsWith("_clq") && // !r.name().endsWith("_e")) { // Expression val = bounds.ts2expr(currInst.tuples(r)); // fix.add(val == Expression.NONE ? r.no() : r.eq(val)); // } // } // inc = inc.and(Formula.and(fix)); // } rep.holFixpointIncrementing(Fixpoint.this, inc); currTr = currTr.next(inc); } if (convInst != null && iterCnt > 0) rep.holFixpointIncrementingOutcome(Fixpoint.this, null); return convInst != null; }
Example #13
Source File: AspectReturnVisitor.java From org.alloytools.alloy with Apache License 2.0 | 4 votes |
@Override public E visit(UnaryExpression unaryExpr) { start(unaryExpr); return end(unaryExpr, visitor.visit(unaryExpr)); }
Example #14
Source File: PrettyPrinter.java From kodkod with MIT License | 4 votes |
public void visit(UnaryExpression unaryExpr) { visit(unaryExpr, unaryExpr.op(), unaryExpr.expression()); }
Example #15
Source File: PrettyPrinter.java From kodkod with MIT License | 4 votes |
/** @ensures appends the given op and child to this.tokens; the child is * parenthesized if it's an instance of binary expression or an if expression. **/ public void visit(UnaryExpression node) { append(node.op()); visitChild(node.expression(), parenthesize(node.expression())); }
Example #16
Source File: AnnotatedNode.java From org.alloytools.alloy with Apache License 2.0 | 4 votes |
@Override public Boolean visit(UnaryExpression expr) { return checkVisitedThenAccumA(expr, Boolean.FALSE, expr.expression()); }
Example #17
Source File: PrettyPrinter.java From org.alloytools.alloy with Apache License 2.0 | 4 votes |
@Override public void visit(UnaryExpression unaryExpr) { visit(unaryExpr, unaryExpr.op(), unaryExpr.expression()); }
Example #18
Source File: PrettyPrinter.java From org.alloytools.alloy with Apache License 2.0 | 4 votes |
/** * @ensures appends the given op and child to this.tokens; the child is * parenthesized if it's an instance of binary expression or an if * expression. **/ @Override public void visit(UnaryExpression node) { append(node.op()); visitChild(node.expression(), parenthesize(node.expression())); }
Example #19
Source File: HOLTranslator.java From org.alloytools.alloy with Apache License 2.0 | 4 votes |
@Override public Expression visit(UnaryExpression unaryExpr) { return unaryExpr; }
Example #20
Source File: VoidVisitor.java From kodkod with MIT License | 2 votes |
/** * Visits the given unary expression. **/ public void visit(UnaryExpression unaryExpr);
Example #21
Source File: AbstractVoidVisitor.java From kodkod with MIT License | 2 votes |
/** * Visits the subexpression if * this.visited(unaryExpr) returns false. Otherwise does nothing. * @ensures unaryExpr.expression.accept(this) */ public void visit(UnaryExpression unaryExpr) { if (visited(unaryExpr)) return; unaryExpr.expression().accept(this); }
Example #22
Source File: ReturnVisitor.java From kodkod with MIT License | 2 votes |
/** * Visits the given unary expression and returns the result. * @return the result of visiting <code>unaryExpr</code> **/ public E visit(UnaryExpression unaryExpr);
Example #23
Source File: ReturnVisitor.java From org.alloytools.alloy with Apache License 2.0 | 2 votes |
/** * Visits the given unary expression and returns the result. * * @return the result of visiting <code>unaryExpr</code> **/ public E visit(UnaryExpression unaryExpr);
Example #24
Source File: AbstractDetector.java From kodkod with MIT License | 2 votes |
/** * Calls lookup(expr) 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(expr) | * x != null => x, * cache(expr, expr.expression.accept(this)) */ public Boolean visit(UnaryExpression expr) { final Boolean ret = lookup(expr); return (ret!=null) ? ret : cache(expr, expr.expression().accept(this)); }
Example #25
Source File: AbstractDetector.java From org.alloytools.alloy with Apache License 2.0 | 2 votes |
/** * Calls lookup(expr) 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(expr) | x != null => x, cache(expr, * expr.expression.accept(this)) */ @Override public Boolean visit(UnaryExpression expr) { final Boolean ret = lookup(expr); return (ret != null) ? ret : cache(expr, expr.expression().accept(this)); }
Example #26
Source File: VoidVisitor.java From org.alloytools.alloy with Apache License 2.0 | 2 votes |
/** * Visits the given unary expression. **/ public void visit(UnaryExpression unaryExpr);