Class SuchThatShuttle
suchThat to in wherever possible.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static classWorkspace for converting a particularCore.Fromfrom "suchthat" to "in" form.private static classMaps patterns from their name in the "from" to their name after a sequence of renames.private static classSignals that we could not rewrite. -
Field Summary
FieldsModifier and TypeFieldDescription(package private) final Environment(package private) final Deque<SuchThatShuttle.FromState> Fields inherited from class net.hydromatic.morel.ast.Shuttle
typeSystem -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static voidaddConjunctions(com.google.common.collect.ImmutableList.Builder<Core.Exp> b, Core.Exp e) Returns an expression as a list of conjunctions.(package private) static booleancontainsSuchThat(Core.Decl decl) private Core.Exprewrite(UnaryOperator<Core.NamedPat> mapper, SortedMap<Core.NamedPat, Core.Exp> boundPats, Map<Core.IdPat, Core.Exp> scans, List<Core.Exp> filters, List<Core.Exp> exps) Rewrites a "from vars suchthat condition" expression to a "from vars in list" expression; returns null if no rewrite is possible.private Core.Expprivate @Nullable Core.ExprewriteElem(TypeSystem typeSystem, UnaryOperator<Core.NamedPat> mapper, SortedMap<Core.NamedPat, Core.Exp> boundPats, Map<Core.IdPat, Core.Exp> scans, List<Core.Exp> filters, Core.Exp a0, Core.Exp a1, List<Core.Exp> exps2) protected Core.Expprotected Core.ScanMethods inherited from class net.hydromatic.morel.ast.Shuttle
visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visitList, visitMap, visitSortedMap
-
Field Details
-
fromStates
-
env
-
-
Constructor Details
-
SuchThatShuttle
SuchThatShuttle(TypeSystem typeSystem, Environment env)
-
-
Method Details
-
containsSuchThat
-
visit
-
visit
-
rewrite0
-
rewrite
private Core.Exp rewrite(UnaryOperator<Core.NamedPat> mapper, SortedMap<Core.NamedPat, Core.Exp> boundPats, Map<Core.IdPat, Core.Exp> scans, List<Core.Exp> filters, List<Core.Exp> exps) Rewrites a "from vars suchthat condition" expression to a "from vars in list" expression; returns null if no rewrite is possible.The "filters" argument contains a list of conditions to be applied after generating rows. For example, "from x suchthat x % 2 = 1 and x elem list" becomes "from x in list where x % 2 = 1" with the filter "x % 2 = 1".
The "scans" argument contains scans to be added. For example, "from x suchthat x elem list" adds the scan "(x, list)".
The "boundPats" argument contains expressions that are bound to variables. For example, "from (x, y) suchthat (x, y) elem list" will add the scan "(e, list)" and boundPats [(x, #1 e), (y, #2 e)].
- Parameters:
mapper- Renames variablesboundPats- Variables that have been bound to a listscans- Scans (joins) to be appended to the resulting "from"filters- Filters to be appended as "where" in the resulting "from"exps- The condition, decomposed into conjunctions- Returns:
- Rewritten expression
-
rewriteElem
private @Nullable Core.Exp rewriteElem(TypeSystem typeSystem, UnaryOperator<Core.NamedPat> mapper, SortedMap<Core.NamedPat, Core.Exp> boundPats, Map<Core.IdPat, Core.Exp> scans, List<Core.Exp> filters, Core.Exp a0, Core.Exp a1, List<Core.Exp> exps2) -
conjunctions
Returns an expression as a list of conjunctions.For example
conjunctions(a andalso b)returns [a,b] (two elements);conjunctions(a andalso b andalso c)returns [a,b,c] (three elements);conjunctions(a orelse b)returns [a orelse b] (one element);conjunctions(true)returns [] (no elements);conjunctions(false)returns [false] (one element). -
addConjunctions
-