Package kodkod.ast

Examples of kodkod.ast.Expression


   * returned, otherwise a replacement expression is cached and returned.
   * @return { c: Comprehension | c.declarations = comprehension.declarations.accept(this) &&
   *                              c.formula = comprehension.formula.accept(this) }
   */
  public Expression visit(Comprehension comprehension) {
    Expression ret = lookup(comprehension);
    if (ret!=null) return ret;
   
    final Decls decls = (Decls)comprehension.decls().accept(this);
    final Formula formula = comprehension.formula().accept(this);
    ret = (decls==comprehension.decls() && formula==comprehension.formula()) ?
View Full Code Here


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

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

   * returned, otherwise a replacement Decls object is cached and returned.
   * @return { d: Decls | d.size = decls.size &&
   *                      all i: [0..d.size) | d.declarations[i] = decls.declarations[i].accept(this) }
   */
  public Expression visit(ProjectExpression project) {
    Expression ret = lookup(project);
    if (ret!=null) return ret;

    final Expression expr = project.expression().accept(this);
    final IntExpression[] cols = new IntExpression[project.arity()];
    boolean allSame = expr==project.expression();
    for(int i = 0, arity = project.arity(); i < arity; i++) {
      cols[i] = project.column(i).accept(this);
      allSame = allSame && (cols[i]==project.column(i));
    }
    ret = allSame ? project : expr.project(cols);
    return cache(project, ret);
  }
View Full Code Here

   * 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 { e: Expression | e = castExpr.intExpr.accept(this).toExpression() }
   */
  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

   */
    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

   */
  public Formula visit(ComparisonFormula compFormula) {
    Formula ret = lookup(compFormula);
    if (ret!=null) return ret;
     
    final Expression left  = compFormula.left().accept(this);
    final Expression right = compFormula.right().accept(this);
    ret =  (left==compFormula.left() && right==compFormula.right()) ?
         compFormula : left.compare(compFormula.op(), right)
    return cache(compFormula,ret);
  }
View Full Code Here

   */
  public Formula visit(MultiplicityFormula multFormula) {
    Formula ret = lookup(multFormula);
    if (ret!=null) return ret;
   
    final Expression expression = multFormula.expression().accept(this);
    ret = (expression==multFormula.expression()) ?
        multFormula : expression.apply(multFormula.multiplicity());
    return cache(multFormula,ret);
  }
View Full Code Here

    case ACYCLIC : 
      ret = (r==pred.relation()) ? pred : r.acyclic();
      break;
    case FUNCTION :
      final RelationPredicate.Function fp = (RelationPredicate.Function) pred;
      final Expression domain = fp.domain().accept(this);
      final Expression range = fp.range().accept(this);
      ret = (r==fp.relation() && domain==fp.domain() && range==fp.range()) ?
          fp :
          (fp.targetMult()==Multiplicity.ONE ? r.function(domain, range) : r.partialFunction(domain,range));
      break;
    case TOTAL_ORDERING :
View Full Code Here

                String sigName = (String)(t[i]);
                i++;
                String fieldName = (String)(t[i]);
                Sig first = hasSig(sigs,sigName);
                if (first==null) return null;
                Expression expr = null;
                if (fieldName.length()==0) {
                    expr=frame.a2k(first);
                } else {
                    for(Field field:first.getFields()) if (field.label.equals(fieldName)) {
                        expr=frame.a2k(field);
                        while(expr instanceof BinaryExpression) expr=((BinaryExpression)expr).right();
                        break;
                    }
                }
                if (!(expr instanceof Relation)) return null;
                if (b==null) b = frame.getBounds(); // We delay the expansive Bounds.clone() until we really find a possible match
                if (ts==null) ts = fac.noneOf(expr.arity());
                if (!ts.containsAll(b.lowerBound((Relation)expr))) return null; // Sanity check
                if (!b.upperBound((Relation)expr).containsAll(ts)) return null; // Sanity check
                b.boundExactly((Relation)expr, ts);
                ts=null;
                continue;
View Full Code Here

TOP

Related Classes of kodkod.ast.Expression

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.