kodkod.ast.visitor
Class AbstractCollector<T>

java.lang.Object
  extended by kodkod.ast.visitor.AbstractCollector<T>
All Implemented Interfaces:
ReturnVisitor<java.util.Set<T>,java.util.Set<T>,java.util.Set<T>,java.util.Set<T>>

public abstract class AbstractCollector<T>
extends java.lang.Object
implements ReturnVisitor<java.util.Set<T>,java.util.Set<T>,java.util.Set<T>,java.util.Set<T>>

A depth first collector. Subclasses should override the methods in which detection is performed to return the appropriate set. For example, a Variable collector could be implemented simply by subclassing this implementation and overriding the visit(Variable) method to return a singleton set containing the input argument.

Author:
Emina Torlak
specfield:
cached: set Node // result of visiting these nodes will be cached
cache: Node -> lone Set
cached in cache.Node

Method Summary
 java.util.Set<T> visit(BinaryExpression binExpr)
          Calls lookup(binExpr) and returns the cached value, if any.
 java.util.Set<T> visit(BinaryFormula binFormula)
          Calls lookup(binFormula) and returns the cached value, if any.
 java.util.Set<T> visit(BinaryIntExpression intExpr)
          Calls lookup(intExpr) and returns the cached value, if any.
 java.util.Set<T> visit(ComparisonFormula compFormula)
          Calls lookup(compFormula) and returns the cached value, if any.
 java.util.Set<T> visit(Comprehension comprehension)
          Calls lookup(comprehension) and returns the cached value, if any.
 java.util.Set<T> visit(ConstantExpression constExpr)
          Returns Collections.EMPTY_SET
 java.util.Set<T> visit(ConstantFormula constant)
          Returns Collections.EMPTY_SET
 java.util.Set<T> visit(Decl decl)
          Calls lookup(decl) and returns the cached value, if any.
 java.util.Set<T> visit(Decls decls)
          Calls lookup(decls) and returns the cached value, if any.
 java.util.Set<T> visit(ExprToIntCast intExpr)
          Calls lookup(intExpr) and returns the cached value, if any.
 java.util.Set<T> visit(IfExpression ifExpr)
          Calls lookup(ifExpr) and returns the cached value, if any.
 java.util.Set<T> visit(IfIntExpression intExpr)
          Calls lookup(intExpr) and returns the cached value, if any.
 java.util.Set<T> visit(IntComparisonFormula intComp)
          Calls lookup(intComp) and returns the cached value, if any.
 java.util.Set<T> visit(IntConstant intConst)
          Returns Collections.EMPTY_SET
 java.util.Set<T> visit(IntToExprCast castExpr)
          Calls lookup(castExpr) and returns the cached value, if any.
 java.util.Set<T> visit(MultiplicityFormula multFormula)
          Calls lookup(multFormula) and returns the cached value, if any.
 java.util.Set<T> visit(NotFormula not)
          Calls lookup(not) and returns the cached value, if any.
 java.util.Set<T> visit(ProjectExpression project)
          Calls lookup(project) and returns the cached value, if any.
 java.util.Set<T> visit(QuantifiedFormula quantFormula)
          Calls lookup(quantFormula) and returns the cached value, if any.
 java.util.Set<T> visit(Relation relation)
          Returns Collections.EMPTY_SET
 java.util.Set<T> visit(RelationPredicate pred)
          Calls lookup(predicate) and returns the cached value, if any.
 java.util.Set<T> visit(SumExpression intExpr)
          Calls lookup(intExpr) and returns the cached value, if any.
 java.util.Set<T> visit(UnaryExpression unaryExpr)
          Calls lookup(unaryExpr) and returns the cached value, if any.
 java.util.Set<T> visit(UnaryIntExpression intExpr)
          Calls lookup(intExpr) and returns the cached value, if any.
 java.util.Set<T> visit(Variable variable)
          Returns Collections.EMPTY_SET
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

visit

public java.util.Set<T> visit(Decls decls)
Calls lookup(decls) and returns the cached value, if any. If no cached value exists, visits each child, caches the union of the sets returned by the children and returns it.

Specified by:
visit in interface ReturnVisitor<java.util.Set<T>,java.util.Set<T>,java.util.Set<T>,java.util.Set<T>>
Returns:
let x = lookup(decls) | x != null => x, cache(decls, decls.declarations[0].accept(this) +...+ decls.declarations[decls.size-1].accept(this))

visit

public java.util.Set<T> visit(Decl decl)
Calls lookup(decl) and returns the cached value, if any. If no cached value exists, visits each child, caches the union of the sets returned by the children and returns it.

Specified by:
visit in interface ReturnVisitor<java.util.Set<T>,java.util.Set<T>,java.util.Set<T>,java.util.Set<T>>
Returns:
let x = lookup(decl) | x != null => x, cache(decls, decl.variable.accept(this) + decl.expression.accept(this))

visit

public java.util.Set<T> visit(Relation relation)
Returns Collections.EMPTY_SET

Specified by:
visit in interface ReturnVisitor<java.util.Set<T>,java.util.Set<T>,java.util.Set<T>,java.util.Set<T>>
Returns:
Collections.EMPTY_SET

visit

public java.util.Set<T> visit(Variable variable)
Returns Collections.EMPTY_SET

Specified by:
visit in interface ReturnVisitor<java.util.Set<T>,java.util.Set<T>,java.util.Set<T>,java.util.Set<T>>
Returns:
Collections.EMPTY_SET

visit

public java.util.Set<T> visit(ConstantExpression constExpr)
Returns Collections.EMPTY_SET

Specified by:
visit in interface ReturnVisitor<java.util.Set<T>,java.util.Set<T>,java.util.Set<T>,java.util.Set<T>>
Returns:
Collections.EMPTY_SET

visit

public java.util.Set<T> visit(BinaryExpression binExpr)
Calls lookup(binExpr) 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.

Specified by:
visit in interface ReturnVisitor<java.util.Set<T>,java.util.Set<T>,java.util.Set<T>,java.util.Set<T>>
Returns:
let x = lookup(binExpr) | x != null => x, cache(binExpr, binExpr.left.accept(this) + binExpr.right.accept(this))

visit

public java.util.Set<T> visit(UnaryExpression unaryExpr)
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.

Specified by:
visit in interface ReturnVisitor<java.util.Set<T>,java.util.Set<T>,java.util.Set<T>,java.util.Set<T>>
Returns:
let x = lookup(unaryExpr) | x != null => x, cache(unaryExpr, unaryExpr.expression.accept(this))

visit

public java.util.Set<T> visit(Comprehension comprehension)
Calls lookup(comprehension) 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.

Specified by:
visit in interface ReturnVisitor<java.util.Set<T>,java.util.Set<T>,java.util.Set<T>,java.util.Set<T>>
Returns:
let x = lookup(comprehension) | x != null => x, cache(comprehension, comprehension.declarations.accept(this) + comprehension.formula.accept(this))

visit

public java.util.Set<T> visit(IfExpression ifExpr)
Calls lookup(ifExpr) 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.

Specified by:
visit in interface ReturnVisitor<java.util.Set<T>,java.util.Set<T>,java.util.Set<T>,java.util.Set<T>>
Returns:
let x = lookup(ifExpr) | x != null => x, cache(ifExpr, ifExpr.condition.accept(this) + ifExpr.thenExpr.accept(this) + ifExpr.elseExpr.accept(this))

visit

public java.util.Set<T> visit(ProjectExpression project)
Calls lookup(project) 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.

Specified by:
visit in interface ReturnVisitor<java.util.Set<T>,java.util.Set<T>,java.util.Set<T>,java.util.Set<T>>
Returns:
let x = lookup(project) | x != null => x, cache(project, project.expression.accept(this) + project.columns[int].accept(this))

visit

public java.util.Set<T> visit(IntToExprCast castExpr)
Calls lookup(castExpr) and returns the cached value, if any. If no cached value exists, visits the child, caches its return value and returns it.

Specified by:
visit in interface ReturnVisitor<java.util.Set<T>,java.util.Set<T>,java.util.Set<T>,java.util.Set<T>>
Returns:
let x = lookup(castExpr) | x != null => x, cache(intExpr, castExpr.intExpr.accept(this))

visit

public java.util.Set<T> visit(IntConstant intConst)
Returns Collections.EMPTY_SET

Specified by:
visit in interface ReturnVisitor<java.util.Set<T>,java.util.Set<T>,java.util.Set<T>,java.util.Set<T>>
Returns:
Collections.EMPTY_SET

visit

public java.util.Set<T> visit(IfIntExpression intExpr)
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.

Specified by:
visit in interface ReturnVisitor<java.util.Set<T>,java.util.Set<T>,java.util.Set<T>,java.util.Set<T>>
Returns:
let x = lookup(intExpr) | x != null => x, cache(intExpr, intExpr.condition.accept(this) + intExpr.thenExpr.accept(this) + intExpr.elseExpr.accept(this))

visit

public java.util.Set<T> visit(ExprToIntCast intExpr)
Calls lookup(intExpr) and returns the cached value, if any. If no cached value exists, visits the child, caches its return value and returns it.

Specified by:
visit in interface ReturnVisitor<java.util.Set<T>,java.util.Set<T>,java.util.Set<T>,java.util.Set<T>>
Returns:
let x = lookup(intExpr) | x != null => x, cache(intExpr, intExpr.expression.accept(this))

visit

public java.util.Set<T> visit(BinaryIntExpression intExpr)
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.

Specified by:
visit in interface ReturnVisitor<java.util.Set<T>,java.util.Set<T>,java.util.Set<T>,java.util.Set<T>>
Returns:
let x = lookup(intExpr) | x != null => x, cache(intExpr, intExpr.left.accept(this) + intExpr.right.accept(this))

visit

public java.util.Set<T> visit(UnaryIntExpression intExpr)
Calls lookup(intExpr) and returns the cached value, if any. If no cached value exists, visits the child, caches its return value and returns it.

Specified by:
visit in interface ReturnVisitor<java.util.Set<T>,java.util.Set<T>,java.util.Set<T>,java.util.Set<T>>
Returns:
let x = lookup(intExpr) | x != null => x, cache(intExpr, intExpr.expression.accept(this))

visit

public java.util.Set<T> visit(SumExpression intExpr)
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.

Specified by:
visit in interface ReturnVisitor<java.util.Set<T>,java.util.Set<T>,java.util.Set<T>,java.util.Set<T>>
Returns:
let x = lookup(intExpr) | x != null => x, cache(intExpr, intExpr.decls.accept(this) + intExpr.intExpr.accept(this))

visit

public java.util.Set<T> visit(IntComparisonFormula intComp)
Calls lookup(intComp) 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.

Specified by:
visit in interface ReturnVisitor<java.util.Set<T>,java.util.Set<T>,java.util.Set<T>,java.util.Set<T>>
Returns:
let x = lookup(intComp) | x != null => x, cache(intComp, intComp.left.accept(this) + intComp.right.accept(this))

visit

public java.util.Set<T> visit(QuantifiedFormula quantFormula)
Calls lookup(quantFormula) 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.

Specified by:
visit in interface ReturnVisitor<java.util.Set<T>,java.util.Set<T>,java.util.Set<T>,java.util.Set<T>>
Returns:
let x = lookup(quantFormula) | x != null => x, cache(quantFormula, quantFormula.declarations.accept(this) + quantFormula.formula.accept(this))

visit

public java.util.Set<T> visit(BinaryFormula binFormula)
Calls lookup(binFormula) 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.

Specified by:
visit in interface ReturnVisitor<java.util.Set<T>,java.util.Set<T>,java.util.Set<T>,java.util.Set<T>>
Returns:
let x = lookup(binFormula) | x != null => x, cache(binFormula, binFormula.left.accept(this) + binFormula.right.accept(this))

visit

public java.util.Set<T> visit(NotFormula not)
Calls lookup(not) and returns the cached value, if any. If no cached value exists, visits the child, caches its return value and returns it.

Specified by:
visit in interface ReturnVisitor<java.util.Set<T>,java.util.Set<T>,java.util.Set<T>,java.util.Set<T>>
Returns:
let x = lookup(not) | x != null => x, cache(not, not.formula.accept(this))

visit

public java.util.Set<T> visit(ConstantFormula constant)
Returns Collections.EMPTY_SET

Specified by:
visit in interface ReturnVisitor<java.util.Set<T>,java.util.Set<T>,java.util.Set<T>,java.util.Set<T>>
Returns:
Collections.EMPTY_SET

visit

public java.util.Set<T> visit(ComparisonFormula compFormula)
Calls lookup(compFormula) 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.

Specified by:
visit in interface ReturnVisitor<java.util.Set<T>,java.util.Set<T>,java.util.Set<T>,java.util.Set<T>>
Returns:
let x = lookup(compFormula) | x != null => x, cache(compFormula,compFormula.left.accept(this) + compFormula.right.accept(this))

visit

public java.util.Set<T> visit(MultiplicityFormula multFormula)
Calls lookup(multFormula) and returns the cached value, if any. If no cached value exists, visits the child, caches its return value and returns it.

Specified by:
visit in interface ReturnVisitor<java.util.Set<T>,java.util.Set<T>,java.util.Set<T>,java.util.Set<T>>
Returns:
let x = lookup(multFormula) | x != null => x, cache(multFormula, multFormula.expression.accept(this))

visit

public java.util.Set<T> visit(RelationPredicate pred)
Calls lookup(predicate) 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.

Specified by:
visit in interface ReturnVisitor<java.util.Set<T>,java.util.Set<T>,java.util.Set<T>,java.util.Set<T>>
Returns:
let x = lookup(predicate) | x != null => x, cache(predicate, some n: predicate.children | n.accept(this))