Class SuchThatShuttle

java.lang.Object
net.hydromatic.morel.ast.Shuttle
net.hydromatic.morel.compile.SuchThatShuttle

class SuchThatShuttle extends Shuttle
Converts suchThat to in wherever possible.
  • Field Details

  • Constructor Details

  • Method Details

    • containsSuchThat

      static boolean containsSuchThat(Core.Decl decl)
    • visit

      protected Core.Exp visit(Core.From from)
      Overrides:
      visit in class Shuttle
    • visit

      protected Core.Scan visit(Core.Scan scan)
      Overrides:
      visit in class Shuttle
    • rewrite0

      private Core.Exp rewrite0(SortedMap<Core.NamedPat,Core.Exp> boundPats, Core.Pat pat, Core.Exp exp)
    • 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 variables
      boundPats - Variables that have been bound to a list
      scans - 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

      static List<Core.Exp> conjunctions(Core.Exp e)
      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

      private static void addConjunctions(com.google.common.collect.ImmutableList.Builder<Core.Exp> b, Core.Exp e)