Java Code Examples for kodkod.ast.Decl#expression()
The following examples show how to use
kodkod.ast.Decl#expression() .
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: AbstractReplacer.java From org.alloytools.alloy with Apache License 2.0 | 5 votes |
/** * Calls lookup(decl) and returns the cached value, if any. If a replacement has * not been cached, visits the declaration's variable and expression. If nothing * changes, the argument is cached and returned, otherwise a replacement Decl * object is cached and returned. * * @return { d: Declaration | d.variable = declaration.variable.accept(delegate) * && d.multiplicity = decl.multiplicity && d.expression = * declaration.expression.accept(delegate) */ @Override public Decl visit(Decl decl) { Decl ret = lookup(decl); if (ret != null) return ret; final Variable variable = (Variable) decl.variable().accept(delegate); final Expression expression = decl.expression().accept(delegate); ret = (variable == decl.variable() && expression == decl.expression()) ? decl : variable.declare(decl.multiplicity(), expression); return cache(decl, ret); }
Example 2
Source File: Skolemizer.java From org.alloytools.alloy with Apache License 2.0 | 5 votes |
/** * Visits the given decl's expression. Note that we must not visit variables in * case they are re-used. For example, consider the formula some x: X | all x: Y * | F(x). Since x bound by the existential quantifier is going to be * skolemized, if we visited the variable in the enclosed declaration, we would * get the skolem constant as a return value and a ClassCastException would be * thrown. * * @return { d: Declaration | d.variable = decl.variable && d.multiplicity = * decl.multiplicity && d.expression = decl.expression.accept(this) } */ @Override public final Decl visit(Decl decl) { Decl ret = lookup(decl); if (ret != null) return ret; final int oldDepth = skolemDepth; skolemDepth = -1; // can't skolemize inside a decl final Expression expression = decl.expression().accept(this); skolemDepth = oldDepth; ret = (expression == decl.expression()) ? decl : decl.variable().declare(decl.multiplicity(), expression); return cache(decl, ret); }
Example 3
Source File: AbstractReplacer.java From kodkod with MIT License | 5 votes |
/** * Calls lookup(decl) and returns the cached value, if any. * If a replacement has not been cached, visits the declaration's * variable and expression. If nothing changes, the argument is cached and * returned, otherwise a replacement Decl object is cached and returned. * @return { d: Declaration | d.variable = declaration.variable.accept(this) && * d.multiplicity = decl.multiplicity && * d.expression = declaration.expression.accept(this) */ public Decl visit(Decl decl) { Decl ret = lookup(decl); if (ret!=null) return ret; final Variable variable = (Variable) decl.variable().accept(this); final Expression expression = decl.expression().accept(this); ret = (variable==decl.variable() && expression==decl.expression()) ? decl : variable.declare(decl.multiplicity(), expression); return cache(decl,ret); }
Example 4
Source File: Skolemizer.java From kodkod with MIT License | 5 votes |
/** * Visits the given decl's expression. Note that we must not visit variables * in case they are re-used. For example, consider the formula * some x: X | all x: Y | F(x). Since x bound by the existential quantifier * is going to be skolemized, if we visited the variable in the enclosed * declaration, we would get the skolem constant as a return value and * a ClassCastException would be thrown. * * @return { d: Declaration | d.variable = decl.variable && d.multiplicity = decl.multiplicity && * d.expression = decl.expression.accept(this) } */ @Override public final Decl visit(Decl decl) { Decl ret = lookup(decl); if (ret!=null) return ret; final int oldDepth = skolemDepth; skolemDepth = -1; // can't skolemize inside a decl final Expression expression = decl.expression().accept(this); skolemDepth = oldDepth; ret = (expression==decl.expression()) ? decl : decl.variable().declare(decl.multiplicity(), expression); return cache(decl,ret); }