kodkod.ast.visitor
Class DepthFirstDetector

java.lang.Object
  extended by kodkod.ast.visitor.DepthFirstDetector
All Implemented Interfaces:
ReturnVisitor<java.lang.Boolean,java.lang.Boolean,java.lang.Boolean,java.lang.Boolean>

public abstract class DepthFirstDetector
extends java.lang.Object
implements ReturnVisitor<java.lang.Boolean,java.lang.Boolean,java.lang.Boolean,java.lang.Boolean>

A depth first detector. Subclasses should override the methods in which detection is performed to return TRUE. For example, a Variable detector could be implemented simply by subclassing this implementation and overriding the visit(Variable) method to return TRUE.

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

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

Method Detail

visit

public java.lang.Boolean visit(Decls decls)
Calls lookup(decls) 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.lang.Boolean,java.lang.Boolean,java.lang.Boolean,java.lang.Boolean>
Returns:
let x = lookup(decls) | x != null => x, cache(decls, some d: decls.declarations | d.accept(this))

visit

public java.lang.Boolean visit(Decl decl)
Calls lookup(decl) 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.lang.Boolean,java.lang.Boolean,java.lang.Boolean,java.lang.Boolean>
Returns:
let x = lookup(decl) | x != null => x, cache(decl, decl.variable.accept(this) || decl.expression.accept(this))

visit

public java.lang.Boolean visit(Relation relation)
Returns FALSE.

Specified by:
visit in interface ReturnVisitor<java.lang.Boolean,java.lang.Boolean,java.lang.Boolean,java.lang.Boolean>
Returns:
FALSE

visit

public java.lang.Boolean visit(Variable variable)
Returns FALSE.

Specified by:
visit in interface ReturnVisitor<java.lang.Boolean,java.lang.Boolean,java.lang.Boolean,java.lang.Boolean>
Returns:
FALSE

visit

public java.lang.Boolean visit(ConstantExpression constExpr)
Returns FALSE.

Specified by:
visit in interface ReturnVisitor<java.lang.Boolean,java.lang.Boolean,java.lang.Boolean,java.lang.Boolean>
Returns:
FALSE

visit

public java.lang.Boolean visit(BinaryExpression binExpr)
Calls lookup(binExpr) 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.lang.Boolean,java.lang.Boolean,java.lang.Boolean,java.lang.Boolean>
Returns:
let x = lookup(binExpr) | x != null => x, cache(binExpr, binExpr.left.accept(this) || binExpr.right.accept(this))

visit

public java.lang.Boolean 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.lang.Boolean,java.lang.Boolean,java.lang.Boolean,java.lang.Boolean>
Returns:
let x = lookup(unaryExpr) | x != null => x, cache(unaryExpr, unaryExpr.expression.accept(this))

visit

public java.lang.Boolean visit(Comprehension comprehension)
Calls lookup(comprehension) 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.lang.Boolean,java.lang.Boolean,java.lang.Boolean,java.lang.Boolean>
Returns:
let x = lookup(comprehension) | x != null => x, cache(comprehension, comprehension.declarations.accept(this) || comprehension.formula.accept(this))

visit

public java.lang.Boolean visit(IfExpression ifExpr)
Calls lookup(ifExpr) 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.lang.Boolean,java.lang.Boolean,java.lang.Boolean,java.lang.Boolean>
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.lang.Boolean visit(ProjectExpression project)
Calls lookup(project) 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.lang.Boolean,java.lang.Boolean,java.lang.Boolean,java.lang.Boolean>
Returns:
let x = lookup(project) | x != null => x, cache(project, project.expression.accept(this) || project.columns[int].accept(this))

visit

public java.lang.Boolean 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.lang.Boolean,java.lang.Boolean,java.lang.Boolean,java.lang.Boolean>
Returns:
let x = lookup(castExpr) | x != null => x, cache(intExpr, castExpr.intExpr.accept(this))

visit

public java.lang.Boolean visit(IntConstant intConst)
Returns FALSE.

Specified by:
visit in interface ReturnVisitor<java.lang.Boolean,java.lang.Boolean,java.lang.Boolean,java.lang.Boolean>
Returns:
FALSE

visit

public java.lang.Boolean visit(IfIntExpression intExpr)
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.

Specified by:
visit in interface ReturnVisitor<java.lang.Boolean,java.lang.Boolean,java.lang.Boolean,java.lang.Boolean>
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.lang.Boolean 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.lang.Boolean,java.lang.Boolean,java.lang.Boolean,java.lang.Boolean>
Returns:
let x = lookup(intExpr) | x != null => x, cache(intExpr, intExpr.expression.accept(this))

visit

public java.lang.Boolean visit(BinaryIntExpression intExpr)
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.

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

visit

public java.lang.Boolean visit(SumExpression intExpr)
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.

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

visit

public java.lang.Boolean visit(IntComparisonFormula intComp)
Calls lookup(intComp) 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.lang.Boolean,java.lang.Boolean,java.lang.Boolean,java.lang.Boolean>
Returns:
let x = lookup(intComp) | x != null => x, cache(intComp, intComp.left.accept(this) || intComp.right.accept(this))

visit

public java.lang.Boolean visit(QuantifiedFormula quantFormula)
Calls lookup(quantFormula) 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.lang.Boolean,java.lang.Boolean,java.lang.Boolean,java.lang.Boolean>
Returns:
let x = lookup(quantFormula) | x != null => x, cache(quantFormula, quantFormula.declarations.accept(this) ||quantFormula.formula.accept(this))

visit

public java.lang.Boolean visit(BinaryFormula binFormula)
Calls lookup(binFormula) 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.lang.Boolean,java.lang.Boolean,java.lang.Boolean,java.lang.Boolean>
Returns:
let x = lookup(binFormula) | x != null => x, cache(binFormula, binFormula.left.accept(this) || binFormula.right.accept(this))

visit

public java.lang.Boolean 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.lang.Boolean,java.lang.Boolean,java.lang.Boolean,java.lang.Boolean>
Returns:
let x = lookup(not) | x != null => x, cache(not, not.formula.accept(this))

visit

public java.lang.Boolean visit(ConstantFormula constant)
Returns FALSE.

Specified by:
visit in interface ReturnVisitor<java.lang.Boolean,java.lang.Boolean,java.lang.Boolean,java.lang.Boolean>
Returns:
FALSE

visit

public java.lang.Boolean visit(ComparisonFormula compFormula)
Calls lookup(compFormula) 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.lang.Boolean,java.lang.Boolean,java.lang.Boolean,java.lang.Boolean>
Returns:
let x = lookup(compFormula) | x != null => x, cache(compFormula,compFormula.left.accept(this) || compFormula.right.accept(this))

visit

public java.lang.Boolean 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.lang.Boolean,java.lang.Boolean,java.lang.Boolean,java.lang.Boolean>
Returns:
let x = lookup(multFormula) | x != null => x, cache(multFormula, multFormula.expression.accept(this))

visit

public java.lang.Boolean visit(RelationPredicate predicate)
Calls lookup(compFormula) 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.lang.Boolean,java.lang.Boolean,java.lang.Boolean,java.lang.Boolean>
Returns:
let x = lookup(predicate) | x != null => x, cache(predicate, some n: predicate.children | n.accept(this))