kodkod.ast.BinaryIntExpression Java Examples
The following examples show how to use
kodkod.ast.BinaryIntExpression.
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 kodkod with MIT License | 6 votes |
/** * Calls lookup(intExpr) 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(intExpr) | some t => t, * cache(intExpr, intExpr.left.accept(this) intExpr.op intExpr.right.accept(this)) */ public final Int visit(BinaryIntExpression intExpr) { Int ret = lookup(intExpr); if (ret!=null) return ret; final Int left = intExpr.left().accept(this); final Int right = intExpr.right().accept(this); switch(intExpr.op()) { case PLUS : ret = left.plus(right); break; case MINUS : ret = left.minus(right); break; case MULTIPLY : ret = left.multiply(right); break; case DIVIDE : ret = left.divide(right); break; case MODULO : ret = left.modulo(right); break; case AND : ret = left.and(right); break; case OR : ret = left.or(right); break; case XOR : ret = left.xor(right); break; case SHL : ret = left.shl(right); break; case SHR : ret = left.shr(right); break; case SHA : ret = left.sha(right); break; default : throw new IllegalArgumentException("Unknown operator: " + intExpr.op()); } return cache(intExpr, ret); }
Example #2
Source File: Simplifier.java From quetzal with Eclipse Public License 2.0 | 5 votes |
public IntExpression visit(BinaryIntExpression expr) { IntExpression ret = lookup(expr); if (ret!=null) return ret; final IntOperator op = expr.op(); final IntExpression left = expr.left().accept(this); final IntExpression 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); }
Example #3
Source File: AbstractReplacer.java From org.alloytools.alloy with Apache License 2.0 | 5 votes |
/** * Calls lookup(intExpr) and returns the cached value, if any. If a replacement * has not been cached, visits the expression's children. If nothing changes, * the argument is cached and returned, otherwise a replacement expression is * cached and returned. * * @return { c: IntExpression | [[c]] = intExpr.left.accept(delegate) op * intExpr.right.accept(delegate) } */ @Override public IntExpression visit(BinaryIntExpression intExpr) { IntExpression ret = lookup(intExpr); if (ret != null) return ret; final IntExpression left = intExpr.left().accept(delegate); final IntExpression right = intExpr.right().accept(delegate); ret = (left == intExpr.left() && right == intExpr.right()) ? intExpr : left.compose(intExpr.op(), right); return cache(intExpr, ret); }
Example #4
Source File: AbstractVoidVisitor.java From org.alloytools.alloy with Apache License 2.0 | 5 votes |
/** * Visits the children of the given integer expression if this.visited(intExpr) * returns false. Otherwise does nothing. * * @ensures intExpr.left.accept(this) && intExpr.right.accept(this) */ @Override public void visit(BinaryIntExpression intExpr) { if (visited(intExpr)) return; intExpr.left().accept(this); intExpr.right().accept(this); }
Example #5
Source File: PrettyPrinter.java From quetzal with Eclipse Public License 2.0 | 5 votes |
/** @effects appends the tokenization of the given node to this.tokens */ public void visit(BinaryIntExpression node) { if (displayed(node)) return; final boolean oldTop = notTop(); final IntOperator op = node.op(); visitChild(node.left(), parenthesize(op, node.left())); infix(op); visitChild(node.right(), parenthesize(op, node.right())); top = oldTop; }
Example #6
Source File: AbstractCollector.java From org.alloytools.alloy with Apache License 2.0 | 5 votes |
/** * Calls lookup(intExpr) and returns the cached value, if any. If no cached * value exists, visits each child, caches the union of the children's return * values and returns it. * * @return let x = lookup(intExpr) | x != null => x, cache(intExpr, * intExpr.left.accept(this) + intExpr.right.accept(this)) */ @Override public Set<T> visit(BinaryIntExpression intExpr) { Set<T> ret = lookup(intExpr); if (ret != null) return ret; ret = newSet(); ret.addAll(intExpr.left().accept(this)); ret.addAll(intExpr.right().accept(this)); return cache(intExpr, ret); }
Example #7
Source File: PrettyPrinter.java From quetzal with Eclipse Public License 2.0 | 5 votes |
/** @return true if the given int expression needs to be parenthesized if a * child of a binary int expression with the given operator */ private boolean parenthesize(IntOperator op, IntExpression child) { return child instanceof SumExpression || child instanceof IfIntExpression || child instanceof NaryIntExpression || (child instanceof BinaryIntExpression && (!associative(op) || ((BinaryIntExpression)child).op()!=op)); }
Example #8
Source File: PartialCannonicalizer.java From quetzal with Eclipse Public License 2.0 | 5 votes |
public IntExpression visit(BinaryIntExpression expr) { IntExpression ret = lookup(expr); if (ret!=null) return ret; final IntOperator op = expr.op(); final IntExpression left = expr.left().accept(this); final IntExpression right = expr.right().accept(this); ret = simplify(op, left, right); if (ret==null) { final int hash = hash(op, left, right); for(Iterator<PartialCannonicalizer.Holder<IntExpression>> itr = intExprs.get(hash); itr.hasNext(); ) { final IntExpression next = itr.next().obj; if (next instanceof BinaryIntExpression) { final BinaryIntExpression hit = (BinaryIntExpression) 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); intExprs.add(new PartialCannonicalizer.Holder<IntExpression>(ret, hash)); } return cache(expr,ret); }
Example #9
Source File: PrettyPrinter.java From kodkod with MIT License | 5 votes |
/** @ensures appends the tokenization of the given node to this.tokens */ public void visit(BinaryIntExpression node) { final IntOperator op = node.op(); visitChild(node.left(), parenthesize(op, node.left())); infix(op); visitChild(node.right(), parenthesize(op, node.right())); }
Example #10
Source File: PrettyPrinter.java From kodkod with MIT License | 5 votes |
/** @return true if the given int expression needs to be parenthesized if a * child of a binary int expression with the given operator */ private boolean parenthesize(IntOperator op, IntExpression child) { return child instanceof SumExpression || child instanceof IfIntExpression || child instanceof NaryIntExpression || (child instanceof BinaryIntExpression && (!associative(op) || ((BinaryIntExpression)child).op()!=op)); }
Example #11
Source File: PrettyPrinter.java From org.alloytools.alloy with Apache License 2.0 | 5 votes |
/** * @ensures appends the tokenization of the given node to this.tokens */ @Override public void visit(BinaryIntExpression node) { final IntOperator op = node.op(); visitChild(node.left(), parenthesize(op, node.left())); infix(op); visitChild(node.right(), parenthesize(op, node.right())); }
Example #12
Source File: AbstractCollector.java From kodkod with MIT License | 5 votes |
/** * Calls lookup(intExpr) and returns the cached value, if any. * If no cached value exists, visits each child, caches the * union of the children's return values and returns it. * @return let x = lookup(intExpr) | * x != null => x, * cache(intExpr, intExpr.left.accept(this) + intExpr.right.accept(this)) */ public Set<T> visit(BinaryIntExpression intExpr) { Set<T> ret = lookup(intExpr); if (ret!=null) return ret; ret = newSet(); ret.addAll(intExpr.left().accept(this)); ret.addAll(intExpr.right().accept(this)); return cache(intExpr, ret); }
Example #13
Source File: AbstractReplacer.java From kodkod with MIT License | 5 votes |
/** * Calls lookup(intExpr) and returns the cached value, if any. * If a replacement has not been cached, visits the expression's * children. If nothing changes, the argument is cached and * returned, otherwise a replacement expression is cached and returned. * @return { c: IntExpression | [[c]] = intExpr.left.accept(this) op intExpr.right.accept(this) } */ public IntExpression visit(BinaryIntExpression intExpr) { IntExpression ret = lookup(intExpr); if (ret!=null) return ret; final IntExpression left = intExpr.left().accept(this); final IntExpression right = intExpr.right().accept(this); ret = (left==intExpr.left() && right==intExpr.right()) ? intExpr : left.compose(intExpr.op(), right); return cache(intExpr,ret); }
Example #14
Source File: TranslateKodkodToJava.java From org.alloytools.alloy with Apache License 2.0 | 4 votes |
/** {@inheritDoc} */ @Override public void visit(BinaryIntExpression x) { String newname = makename(x); if (newname == null) return; String left = make(x.left()); String right = make(x.right()); switch (x.op()) { case PLUS : file.printf("IntExpression %s=%s.plus(%s);%n", newname, left, right); break; case MINUS : file.printf("IntExpression %s=%s.minus(%s);%n", newname, left, right); break; case MULTIPLY : file.printf("IntExpression %s=%s.multiply(%s);%n", newname, left, right); break; case DIVIDE : file.printf("IntExpression %s=%s.divide(%s);%n", newname, left, right); break; case MODULO : file.printf("IntExpression %s=%s.modulo(%s);%n", newname, left, right); break; case AND : file.printf("IntExpression %s=%s.and(%s);%n", newname, left, right); break; case OR : file.printf("IntExpression %s=%s.or(%s);%n", newname, left, right); break; case XOR : file.printf("IntExpression %s=%s.xor(%s);%n", newname, left, right); break; case SHA : file.printf("IntExpression %s=%s.sha(%s);%n", newname, left, right); break; case SHL : file.printf("IntExpression %s=%s.shl(%s);%n", newname, left, right); break; case SHR : file.printf("IntExpression %s=%s.shr(%s);%n", newname, left, right); break; default : throw new RuntimeException("Unknown kodkod operator \"" + x.op() + "\" encountered"); } }
Example #15
Source File: AbstractVoidVisitor.java From kodkod with MIT License | 4 votes |
/** * Visits the children of the given integer expression if * this.visited(intExpr) returns false. Otherwise does nothing. * @ensures intExpr.left.accept(this) && intExpr.right.accept(this) */ public void visit(BinaryIntExpression intExpr) { if (visited(intExpr)) return; intExpr.left().accept(this); intExpr.right().accept(this); }
Example #16
Source File: AspectReturnVisitor.java From org.alloytools.alloy with Apache License 2.0 | 4 votes |
@Override public I visit(BinaryIntExpression intExpr) { start(intExpr); return end(intExpr, visitor.visit(intExpr)); }
Example #17
Source File: OverflowTestUtils.java From org.alloytools.alloy with Apache License 2.0 | 4 votes |
public static IntExpression applyIntOp(IntOperator intOp, IntExpression lhs, IntExpression rhs) { return new BinaryIntExpression(lhs, intOp, rhs); }
Example #18
Source File: AnnotatedNode.java From org.alloytools.alloy with Apache License 2.0 | 4 votes |
@Override public Boolean visit(BinaryIntExpression e) { return checkVisitedThenAccumA(e, Boolean.FALSE, e.left(), e.right()); }
Example #19
Source File: PrettyPrinter.java From org.alloytools.alloy with Apache License 2.0 | 4 votes |
@Override public void visit(BinaryIntExpression intExpr) { visit(intExpr, intExpr.op(), intExpr.left(), intExpr.right()); }
Example #20
Source File: HOLTranslator.java From org.alloytools.alloy with Apache License 2.0 | 4 votes |
@Override public IntExpression visit(BinaryIntExpression intExpr) { return intExpr; }
Example #21
Source File: FOL2BoolTranslator.java From org.alloytools.alloy with Apache License 2.0 | 4 votes |
/** * Calls lookup(intExpr) 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(intExpr) | some t => t, cache(intExpr, * intExpr.left.accept(this) intExpr.op intExpr.right.accept(this)) */ @Override public final Int visit(BinaryIntExpression intExpr) { Int ret = lookup(intExpr); if (ret != null) return ret; final Int left = intExpr.left().accept(this); final Int right = intExpr.right().accept(this); switch (intExpr.op()) { case PLUS : ret = left.plus(right); break; case MINUS : ret = left.minus(right); break; case MULTIPLY : ret = left.multiply(right); break; case DIVIDE : ret = left.divide(right); break; case MODULO : ret = left.modulo(right); break; case AND : ret = left.and(right); break; case OR : ret = left.or(right); break; case XOR : ret = left.xor(right); break; case SHL : ret = left.shl(right); break; case SHR : ret = left.shr(right); break; case SHA : ret = left.sha(right); break; default : throw new IllegalArgumentException("Unknown operator: " + intExpr.op()); } return cache(intExpr, ret); }
Example #22
Source File: VoidVisitor.java From kodkod with MIT License | 2 votes |
/** * Visits the given binary integer expression. */ public void visit(BinaryIntExpression intExpr);
Example #23
Source File: ReturnVisitor.java From kodkod with MIT License | 2 votes |
/** * Visits the given binary integer expression and returns the result. * @return the result of visiting <code>intExpr</code> */ public I visit(BinaryIntExpression intExpr);
Example #24
Source File: AbstractDetector.java From kodkod with MIT License | 2 votes |
/** * Calls lookup(intExpr) and returns the cached value, if any. * If no cached value exists, visits each child, caches the * disjunction of the children's return values and returns it. * @return let x = lookup(intExpr) | * x != null => x, * cache(intExpr, intExpr.left.accept(this) || intExpr.right.accept(this)) */ public Boolean visit(BinaryIntExpression intExpr) { final Boolean ret = lookup(intExpr); return (ret!=null) ? ret : cache(intExpr, intExpr.left().accept(this) || intExpr.right().accept(this)); }
Example #25
Source File: PrettyPrinter.java From org.alloytools.alloy with Apache License 2.0 | 2 votes |
/** * @return true if the given int expression needs to be parenthesized if a child * of a binary int expression with the given operator */ private boolean parenthesize(IntOperator op, IntExpression child) { return child instanceof SumExpression || child instanceof IfIntExpression || child instanceof NaryIntExpression || (child instanceof BinaryIntExpression && (!associative(op) || ((BinaryIntExpression) child).op() != op)); }
Example #26
Source File: AbstractDetector.java From org.alloytools.alloy with Apache License 2.0 | 2 votes |
/** * Calls lookup(intExpr) and returns the cached value, if any. If no cached * value exists, visits each child, caches the disjunction of the children's * return values and returns it. * * @return let x = lookup(intExpr) | x != null => x, cache(intExpr, * intExpr.left.accept(this) || intExpr.right.accept(this)) */ @Override public Boolean visit(BinaryIntExpression intExpr) { final Boolean ret = lookup(intExpr); return (ret != null) ? ret : cache(intExpr, intExpr.left().accept(this) || intExpr.right().accept(this)); }
Example #27
Source File: ReturnVisitor.java From org.alloytools.alloy with Apache License 2.0 | 2 votes |
/** * Visits the given binary integer expression and returns the result. * * @return the result of visiting <code>intExpr</code> */ public I visit(BinaryIntExpression intExpr);
Example #28
Source File: VoidVisitor.java From org.alloytools.alloy with Apache License 2.0 | 2 votes |
/** * Visits the given binary integer expression. */ public void visit(BinaryIntExpression intExpr);
Example #29
Source File: PrettyPrinter.java From kodkod with MIT License | votes |
public void visit(BinaryIntExpression intExpr) { visit(intExpr, intExpr.op(), intExpr.left(), intExpr.right()); }