Java Code Examples for kodkod.ast.IntExpression#getClass()
The following examples show how to use
kodkod.ast.IntExpression#getClass() .
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 IntExpression visit(IfIntExpression expr) { IntExpression ret = lookup(expr); if (ret!=null) return ret; final Formula cond = expr.condition().accept(this); final IntExpression thenExpr = expr.thenExpr().accept(this); final IntExpression elseExpr = expr.elseExpr().accept(this); ret = simplify(cond,thenExpr,elseExpr); if (ret==null) { final int hash = hash(IfIntExpression.class, cond, thenExpr, elseExpr); for(Iterator<PartialCannonicalizer.Holder<IntExpression>> itr = intExprs.get(hash); itr.hasNext(); ) { final IntExpression next = itr.next().obj; if (next.getClass()==IfIntExpression.class) { final IfIntExpression hit = (IfIntExpression) next; if (hit.condition()==cond && hit.thenExpr()==thenExpr && hit.elseExpr()==elseExpr) { return cache(expr, hit); } } } ret = cond==expr.condition()&&thenExpr==expr.thenExpr()&&elseExpr==expr.elseExpr() ? expr : cond.thenElse(thenExpr, elseExpr); intExprs.add(new PartialCannonicalizer.Holder<IntExpression>(ret, hash)); } return cache(expr,ret); }
Example 2
Source File: PartialCannonicalizer.java From quetzal with Eclipse Public License 2.0 | 6 votes |
public IntExpression visit(UnaryIntExpression expr) { IntExpression ret = lookup(expr); if (ret!=null) return ret; final IntOperator op = expr.op(); final IntExpression child = expr.intExpr().accept(this); ret = simplify(op, child); if (ret==null) { final int hash = hash(op, child); for(Iterator<PartialCannonicalizer.Holder<IntExpression>> itr = intExprs.get(hash); itr.hasNext(); ) { final IntExpression next = itr.next().obj; if (next.getClass()==UnaryIntExpression.class) { if (((UnaryIntExpression)next).intExpr()==child) return cache(expr, next); } } ret = child==expr.intExpr() ? expr : child.apply(op); intExprs.add(new PartialCannonicalizer.Holder<IntExpression>(ret, hash)); } return cache(expr,ret); }
Example 3
Source File: PartialCannonicalizer.java From quetzal with Eclipse Public License 2.0 | 6 votes |
public IntExpression visit(ExprToIntCast expr) { IntExpression ret = lookup(expr); if (ret!=null) return ret; final ExprCastOperator op = expr.op(); final Expression child = expr.expression().accept(this); final int hash = hash(op, child); for(Iterator<PartialCannonicalizer.Holder<IntExpression>> itr = intExprs.get(hash); itr.hasNext(); ) { final IntExpression next = itr.next().obj; if (next.getClass()==ExprToIntCast.class) { if (((ExprToIntCast)next).expression()==child) return cache(expr, next); } } ret = child==expr.expression() ? expr : child.apply(op); intExprs.add(new PartialCannonicalizer.Holder<IntExpression>(ret, hash)); return cache(expr,ret); }