kodkod.ast.Comprehension Java Examples
The following examples show how to use
kodkod.ast.Comprehension.
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: Skolemizer.java From org.alloytools.alloy with Apache License 2.0 | 6 votes |
/** * @see kodkod.ast.visitor.AbstractReplacer#visit(kodkod.ast.Comprehension) */ @Override public final Expression visit(Comprehension expr) { Expression ret = lookup(expr); if (ret != null) return ret; final Environment<Expression,Expression> oldRepEnv = repEnv; // skolemDepth // < 0 // at // this // point final Decls decls = visit(expr.decls()); final Formula formula = expr.formula().accept(this); ret = (decls == expr.decls() && formula == expr.formula()) ? expr : formula.comprehension(decls); repEnv = oldRepEnv; return cache(expr, ret); }
Example #2
Source File: FOL2BoolTranslator.java From org.alloytools.alloy with Apache License 2.0 | 5 votes |
/** * Calls lookup(cexpr) and returns the cached value, if any. If a translation * has not been cached, translates the expression, calls cache(...) on it and * returns it. * * @return let t = lookup(cexpr) | some t => t, cache(cexpr, translate(cexpr)) */ @Override public BooleanMatrix visit(Comprehension cexpr) { BooleanMatrix ret = lookup(cexpr); if (ret != null) return ret; ret = interpreter.factory().matrix(Dimensions.square(interpreter.universe().size(), cexpr.decls().size())); comprehension(cexpr.decls(), cexpr.formula(), 0, BooleanConstant.TRUE, 0, ret); return cache(cexpr, ret); }
Example #3
Source File: TranslateKodkodToJava.java From org.alloytools.alloy with Apache License 2.0 | 5 votes |
/** {@inheritDoc} */ @Override public void visit(Comprehension x) { String newname = makename(x); if (newname == null) return; String d = make(x.decls()); String f = make(x.formula()); file.printf("Expression %s=%s.comprehension(%s);%n", newname, f, d); }
Example #4
Source File: AbstractReplacer.java From kodkod with MIT License | 5 votes |
/** * Calls lookup(comprehension) and returns the cached value, if any. * If a replacement has not been cached, visits the expression's * children. If nothing changes, the argument is cached and * 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()) ? comprehension : formula.comprehension(decls); return cache(comprehension,ret); }
Example #5
Source File: AbstractCollector.java From kodkod with MIT License | 5 votes |
/** * 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. * @return let x = lookup(comprehension) | * x != null => x, * cache(comprehension, comprehension.declarations.accept(this) + comprehension.formula.accept(this)) */ public Set<T> visit(Comprehension comprehension) { Set<T> ret = lookup(comprehension); if (ret!=null) return ret; ret = newSet(); ret.addAll(comprehension.decls().accept(this)); ret.addAll(comprehension.formula().accept(this)); return cache(comprehension, ret); }
Example #6
Source File: Skolemizer.java From kodkod with MIT License | 5 votes |
/** * @see kodkod.ast.visitor.AbstractReplacer#visit(kodkod.ast.Comprehension) */ @Override public final Expression visit(Comprehension expr) { Expression ret = lookup(expr); if (ret!=null) return ret; final Environment<Expression> oldRepEnv = repEnv; // skolemDepth < 0 at this point final Decls decls = visit((Decls)expr.decls()); final Formula formula = expr.formula().accept(this); ret = (decls==expr.decls() && formula==expr.formula()) ? expr : formula.comprehension(decls); repEnv = oldRepEnv; return cache(expr,ret); }
Example #7
Source File: PrettyPrinter.java From org.alloytools.alloy with Apache License 2.0 | 5 votes |
/** * @ensures this.tokens' = concat[ this.tokens, "{", tokenize[node.decls], "|", * tokenize[ node.formula ], "}" ] */ @Override public void visit(Comprehension node) { append("{"); node.decls().accept(this); infix("|"); node.formula().accept(this); append("}"); }
Example #8
Source File: FOL2BoolTranslator.java From kodkod with MIT License | 5 votes |
/** * Calls lookup(cexpr) and returns the cached value, if any. * If a translation has not been cached, translates the expression, * calls cache(...) on it and returns it. * @return let t = lookup(cexpr) | some t => t, * cache(cexpr, translate(cexpr)) */ public BooleanMatrix visit(Comprehension cexpr) { BooleanMatrix ret = lookup(cexpr); if (ret!=null) return ret; ret = interpreter.factory().matrix(Dimensions.square(interpreter.universe().size(), cexpr.decls().size())); comprehension(cexpr.decls(), cexpr.formula(), 0, BooleanConstant.TRUE, 0, ret); return cache(cexpr,ret); }
Example #9
Source File: PrettyPrinter.java From kodkod with MIT License | 5 votes |
/** @ensures this.tokens' = concat[ this.tokens, * "{", tokenize[node.decls], "|", tokenize[ node.formula ], "}" ]*/ public void visit(Comprehension node) { append("{"); node.decls().accept(this); infix("|"); node.formula().accept(this); append("}"); }
Example #10
Source File: AbstractCollector.java From org.alloytools.alloy with Apache License 2.0 | 5 votes |
/** * 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. * * @return let x = lookup(comprehension) | x != null => x, cache(comprehension, * comprehension.declarations.accept(this) + * comprehension.formula.accept(this)) */ @Override public Set<T> visit(Comprehension comprehension) { Set<T> ret = lookup(comprehension); if (ret != null) return ret; ret = newSet(); ret.addAll(comprehension.decls().accept(this)); ret.addAll(comprehension.formula().accept(this)); return cache(comprehension, ret); }
Example #11
Source File: AbstractVoidVisitor.java From org.alloytools.alloy with Apache License 2.0 | 5 votes |
/** * Visits the declarations and the formula if this.visited(comprehension) * returns false. Otherwise does nothing. * * @ensures comprehension.declarations.accept(this) && * comprehension.formula.accept(this) */ @Override public void visit(Comprehension comprehension) { if (visited(comprehension)) return; comprehension.decls().accept(this); comprehension.formula().accept(this); }
Example #12
Source File: AbstractReplacer.java From org.alloytools.alloy with Apache License 2.0 | 5 votes |
/** * Calls lookup(comprehension) and returns the cached value, if any. If a * replacement has not been cached, visits the expression's children. If nothing * changes, the argument is cached and returned, otherwise a replacement * expression is cached and returned. * * @return { c: Comprehension | c.declarations = * comprehension.declarations.accept(delegate) && c.formula = * comprehension.formula.accept(delegate) } */ @Override public Expression visit(Comprehension comprehension) { Expression ret = lookup(comprehension); if (ret != null) return ret; final Decls decls = comprehension.decls().accept(delegate); final Formula formula = comprehension.formula().accept(delegate); ret = (decls == comprehension.decls() && formula == comprehension.formula()) ? comprehension : formula.comprehension(decls); return cache(comprehension, ret); }
Example #13
Source File: PrettyPrinter.java From quetzal with Eclipse Public License 2.0 | 5 votes |
/** @effects this.tokens' = concat[ this.tokens, * "{", tokenize[node.decls], "|", tokenize[ node.formula ], "}" ]*/ public void visit(Comprehension node) { if (displayed(node)) return; final boolean oldTop = notTop(); append("{"); node.decls().accept(this); infix("|"); node.formula().accept(this); append("}"); top = oldTop; }
Example #14
Source File: AnnotatedNode.java From org.alloytools.alloy with Apache License 2.0 | 4 votes |
@Override public Boolean visit(Comprehension cph) { return checkVisitedThenAccumA(cph, Boolean.FALSE, cph.decls(), cph.formula()); }
Example #15
Source File: PrettyPrinter.java From kodkod with MIT License | 4 votes |
public void visit(Comprehension comprehension) { visit(comprehension, "setcomp", comprehension.decls(), comprehension.formula()); }
Example #16
Source File: AnnotatedNode.java From kodkod with MIT License | 4 votes |
public Boolean visit(Comprehension comprehension) { return visit(comprehension, comprehension.decls(), comprehension.formula()); }
Example #17
Source File: AbstractVoidVisitor.java From kodkod with MIT License | 4 votes |
/** * Visits the declarations and the formula if * this.visited(comprehension) returns false. Otherwise does nothing. * @ensures comprehension.declarations.accept(this) && comprehension.formula.accept(this) */ public void visit(Comprehension comprehension) { if (visited(comprehension)) return; comprehension.decls().accept(this); comprehension.formula().accept(this); }
Example #18
Source File: AspectReturnVisitor.java From org.alloytools.alloy with Apache License 2.0 | 4 votes |
@Override public E visit(Comprehension comprehension) { start(comprehension); return end(comprehension, visitor.visit(comprehension)); }
Example #19
Source File: AnnotatedNode.java From org.alloytools.alloy with Apache License 2.0 | 4 votes |
/** * Calls visited(comp); comp's children are not top-level formulas so they are * not visited. */ @Override public void visit(Comprehension comp) { visited(comp); }
Example #20
Source File: AnnotatedNode.java From org.alloytools.alloy with Apache License 2.0 | 4 votes |
@Override public Boolean visit(Comprehension comprehension) { return visit(comprehension, comprehension.decls(), comprehension.formula()); }
Example #21
Source File: PrettyPrinter.java From org.alloytools.alloy with Apache License 2.0 | 4 votes |
@Override public void visit(Comprehension comprehension) { visit(comprehension, "setcomp", comprehension.decls(), comprehension.formula()); }
Example #22
Source File: HOLTranslator.java From org.alloytools.alloy with Apache License 2.0 | 4 votes |
@Override public Expression visit(Comprehension comprehension) { return comprehension; }
Example #23
Source File: VoidVisitor.java From kodkod with MIT License | 2 votes |
/** * Visits the given comprehension. **/ public void visit(Comprehension comprehension);
Example #24
Source File: ReturnVisitor.java From kodkod with MIT License | 2 votes |
/** * Visits the given comprehension and returns the result. * @return the result of visiting <code>comprehension</code> **/ public E visit(Comprehension comprehension);
Example #25
Source File: AbstractDetector.java From kodkod with MIT License | 2 votes |
/** * Calls lookup(expr) 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. * @return let x = lookup(expr) | * x != null => x, * cache(expr, expr.decls.accept(this) || expr.formula.accept(this)) */ public Boolean visit(Comprehension expr) { final Boolean ret = lookup(expr); return (ret!=null) ? ret : cache(expr, expr.decls().accept(this) || expr.formula().accept(this)); }
Example #26
Source File: FreeVariableCollector.java From kodkod with MIT License | 2 votes |
/** * Calls lookup(comprehension) and returns the cached value, if any. * If no cached value exists, computes, caches and returns the set * of free variables in comprehension. * @return let x = lookup(comprehension), d = comprehension.declarations, f = comprehension.formula | * x != null => x, * cache(comprehension, * (f.accept(this) - d.children.variable) + * {v: Variable | some i: [0..d.size) | * v in d.declarations[i].accept(this) - d.declarations[0..i).variable } ) */ @Override public Set<Variable> visit(Comprehension comprehension) { return visit(comprehension, comprehension.decls(), comprehension.formula()); }
Example #27
Source File: FreeVariableCollector.java From org.alloytools.alloy with Apache License 2.0 | 2 votes |
/** * Calls lookup(comprehension) and returns the cached value, if any. If no * cached value exists, computes, caches and returns the set of free variables * in comprehension. * * @return let x = lookup(comprehension), d = comprehension.declarations, f = * comprehension.formula | x != null => x, cache(comprehension, * (f.accept(this) - d.children.variable) + {v: Variable | some i: * [0..d.size) | v in d.declarations[i].accept(this) - * d.declarations[0..i).variable } ) */ @Override public Set<Variable> visit(Comprehension comprehension) { return visit(comprehension, comprehension.decls(), comprehension.formula()); }
Example #28
Source File: AbstractDetector.java From org.alloytools.alloy with Apache License 2.0 | 2 votes |
/** * Calls lookup(expr) 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. * * @return let x = lookup(expr) | x != null => x, cache(expr, * expr.decls.accept(this) || expr.formula.accept(this)) */ @Override public Boolean visit(Comprehension expr) { final Boolean ret = lookup(expr); return (ret != null) ? ret : cache(expr, expr.decls().accept(this) || expr.formula().accept(this)); }
Example #29
Source File: ReturnVisitor.java From org.alloytools.alloy with Apache License 2.0 | 2 votes |
/** * Visits the given comprehension and returns the result. * * @return the result of visiting <code>comprehension</code> **/ public E visit(Comprehension comprehension);
Example #30
Source File: AnnotatedNode.java From kodkod with MIT License | 2 votes |
/** * Calls visited(comp); comp's children are not top-level formulas * so they are not visited. */ public void visit(Comprehension comp) { visited(comp); }