Package kodkod.ast

Examples of kodkod.ast.IntExpression


   
   
    /** @effects appends the given op and child to this.tokens; the child is
     * parenthesized if it's not an instance of unary int expression or int constant. **/
    public void visit(UnaryIntExpression node)  {
      final IntExpression child = node.intExpr();
      final IntOperator op = node.op();
      final boolean parens =
        (op==IntOperator.ABS) || (op==IntOperator.SGN) ||
        parenthesize(child);
      append(node.op());
View Full Code Here


  /**
   * @see kodkod.ast.visitor.AbstractReplacer#visit(kodkod.ast.SumExpression)
   */
  @Override
  public final IntExpression visit(SumExpression intExpr) {
    IntExpression ret = lookup(intExpr);
    if (ret!=null) return ret; 
    final Environment<Expression> oldRepEnv = repEnv; // skolemDepth < 0 at this point
    final Decls decls  = visit((Decls)intExpr.decls());
    final IntExpression expr = intExpr.intExpr().accept(this);
    ret =  (decls==intExpr.decls() && expr==intExpr.intExpr()) ? intExpr : expr.sum(decls);
    repEnv = oldRepEnv;
    return cache(intExpr,ret);
  }
View Full Code Here

   */
  public Expression visit(IntToExprCast castExpr) {
    Expression ret = lookup(castExpr);
    if (ret!=null) return ret;

    final IntExpression intExpr = castExpr.intExpr().accept(this);
    ret = (intExpr==castExpr.intExpr()) ? castExpr : intExpr.cast(castExpr.op());
    return cache(castExpr, ret);
  }
View Full Code Here

   * Calls lookup(intconst) and returns the cached value, if any. 
   * If a replacement has not been cached, the constant is cached and returned.
   * @return intconst
   */
    public IntExpression visit(IntConstant intconst) {
    IntExpression ret = lookup(intconst);
    return ret==null ? cache(intconst, intconst) : intconst;
    }
View Full Code Here

   * @return { i: IfIntExpression | i.condition = intExpr.condition.accept(this) &&
   *                             i.thenExpr = intExpr.thenExpr.accept(this) &&
   *                             i.elseExpr = intExpr.elseExpr.accept(this) }
   */
  public IntExpression visit(IfIntExpression intExpr) {
    IntExpression ret = lookup(intExpr);
    if (ret!=null) return ret;

    final Formula condition = intExpr.condition().accept(this);
    final IntExpression thenExpr = intExpr.thenExpr().accept(this);
    final IntExpression elseExpr = intExpr.elseExpr().accept(this);
    ret = (condition==intExpr.condition() && thenExpr==intExpr.thenExpr() &&
         elseExpr==intExpr.elseExpr()) ?
          intExpr : condition.thenElse(thenExpr, elseExpr);
    return cache(intExpr,ret);
  }
View Full Code Here

   * child.  If nothing changes, the argument is cached and
   * returned, otherwise a replacement expression is cached and returned.
   * @return { i: ExprToIntCast | i.expression = intExpr.expression.accept(this) && i.op = intExpr.op}
   */
    public IntExpression visit(ExprToIntCast intExpr) {
    IntExpression ret = lookup(intExpr);
    if (ret!=null) return ret;
 
    final Expression expr = intExpr.expression().accept(this);
    ret = expr==intExpr.expression() ? intExpr : expr.apply(intExpr.op());
    return cache(intExpr, ret);
View Full Code Here

   * children.  If nothing changes, the argument is cached and
   * returned, otherwise a replacement intExpr is cached and returned.
   * @return { e: IntExpression | e.op = intExpr.op && #e.children = #intExpr.children && all i: [0..intExpr.children) | e.child(i) = intExpr.child(i).accept(this) }
   */
    public IntExpression visit(NaryIntExpression intExpr) {
    IntExpression ret = lookup(intExpr);
    if (ret!=null) return ret;
 
    final IntExpression[] visited = new IntExpression[intExpr.size()];
    boolean allSame = true;
    for(int i = 0 ; i < visited.length; i++) {
      final IntExpression child = intExpr.child(i);
      visited[i] = child.accept(this);
      allSame = allSame && visited[i]==child;
    }
   
    ret = allSame ? intExpr : IntExpression.compose(intExpr.op(), visited);
    return cache(intExpr,ret);
View Full Code Here

   * 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);
    }
View Full Code Here

   * child.  If nothing changes, the argument is cached and
   * returned, otherwise a replacement expression is cached and returned.
   * @return { u: UnaryIntExpression | u.expression = intExpr.expression.accept(this) && u.op = intExpr.op }
   */
  public IntExpression visit(UnaryIntExpression intExpr) {
    IntExpression ret = lookup(intExpr);
    if (ret!=null) return ret;

    final IntExpression child = intExpr.intExpr().accept(this);
    ret = (child==intExpr.intExpr()) ?  intExpr : child.apply(intExpr.op());
    return cache(intExpr,ret);
  }
View Full Code Here

   * children.  If nothing changes, the argument is cached and
   * returned, otherwise a replacement expression is cached and returned.
   * @return { c: IntExpression | [[c]] = sum intExpr.decls.accept(this) | intExpr.intExpr.accept(this) }
   */
    public IntExpression visit(SumExpression intExpr) {
    IntExpression ret = lookup(intExpr);
    if (ret!=null) return ret;
 
    final Decls decls  = intExpr.decls().accept(this);
    final IntExpression expr = intExpr.intExpr().accept(this);
    ret =  (decls==intExpr.decls() && expr==intExpr.intExpr()) ?
        intExpr : expr.sum(decls);
    return cache(intExpr,ret);
    }
View Full Code Here

TOP

Related Classes of kodkod.ast.IntExpression

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.