Package net.hydromatic.morel.compile
Class Compiler
java.lang.Object
net.hydromatic.morel.compile.Compiler
- Direct Known Subclasses:
CalciteCompiler
Compiles an expression to code that can be evaluated.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static interfaceSomething that needs to happen when a declaration is evaluated.static classCompilation context.private static classA piece of code that is references another piece of code.private static classCode that implementscompileMatchList(Context, List). -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate com.google.common.collect.ImmutableList<String> bindingNames(List<Binding> bindings) compile(Compiler.Context cx, Core.Exp expression) final Codecompile(Environment env, Core.Exp expression) private ApplicablecompileApplicable(Compiler.Context cx, Core.Exp fn, Type argType, Pos pos) Compiles a function value to anApplicable, if possible, or returns null.protected CodecompileApply(Compiler.Context cx, Core.Apply apply) compileArg(Compiler.Context cx, Core.Exp expression) Compiles the argument to "apply".compileArgs(Compiler.Context cx, Iterable<? extends Core.Exp> expressions) Compiles the tuple arguments to "apply".private CodecompileCall(Compiler.Context cx, BuiltIn builtIn, Core.Exp arg, Pos pos) private voidcompileDatatypeDecl(List<DataType> dataTypes, List<Binding> bindings, List<Compiler.Action> actions) (package private) voidcompileDecl(Compiler.Context cx, Core.Decl decl, @Nullable Core.NamedPat skipPat, Set<Core.Exp> queriesToWrap, List<Code> matchCodes, List<Binding> bindings, List<Compiler.Action> actions) private CodecompileFieldName(Compiler.Context cx, Core.NamedPat idPat) private CodecompileFieldNames(Compiler.Context cx, List<Core.IdPat> fieldNames) protected CodecompileFrom(Compiler.Context cx, Core.From from) private CodecompileLet(Compiler.Context cx, Core.Let let) private CodecompileLocal(Compiler.Context cx, Core.Local local) private voidcompileMatch(Compiler.Context cx, Core.Match match, BiConsumer<Core.Pat, Code> consumer) private CodecompileMatchList(Compiler.Context cx, List<Core.Match> matchList) Compiles amatchexpression.(package private) CompiledStatementcompileStatement(Environment env, Core.Decl decl, @Nullable Core.NamedPat skipPat, Set<Core.Exp> queriesToWrap) private voidcompileValDecl(Compiler.Context cx, Core.ValDecl valDecl, @Nullable Core.Pat skipPat, Set<Core.Exp> queriesToWrap, List<Code> matchCodes, List<Binding> bindings, List<Compiler.Action> actions) protected CalciteFunctions.ContextcreateContext(Environment env) Creates a context.protected Supplier<Codes.RowSink> createRowSinkFactory(Compiler.Context cx0, com.google.common.collect.ImmutableList<Binding> bindings, List<Core.FromStep> steps, Type elementType) protected CodefinishCompileApply(Compiler.Context cx, Applicable fnValue, Code argCode, Type argType) protected CodefinishCompileApply(Compiler.Context cx, Code fnCode, Code argCode, Type argType) protected CodefinishCompileLet(Compiler.Context cx, List<Code> matchCodes, Code resultCode, Type resultType) private voidlink(Map<Core.NamedPat, Compiler.LinkCode> linkCodes, Core.Pat pat, Code code) private voidshredValue(Core.Pat pat, Object o, BiConsumer<Core.NamedPat, Object> consumer) sortedBindingMap(Iterable<Binding> bindings) private @Nullable ApplicabletoApplicable(Compiler.Context cx, Object o, Type argType, Pos pos)
-
Field Details
-
EMPTY_ENV
-
typeSystem
-
-
Constructor Details
-
Compiler
-
-
Method Details
-
compileStatement
CompiledStatement compileStatement(Environment env, Core.Decl decl, @Nullable Core.NamedPat skipPat, Set<Core.Exp> queriesToWrap) -
createContext
Creates a context.The whole way we provide compilation environments (including Environment) to generated code is a mess:
- This method is protected so that CalciteCompiler can override and get a Calcite type factory.
- User-defined functions should have a 'prepare' phase, where they use a type factory and environment, that is distinct from the 'eval' phase.
- We should pass compile and runtime environments via parameters, not thread-locals.
- The dummy session is there because session is mandatory, but we have not created a session yet. Lifecycle confusion.
-
compile
-
compileArg
Compiles the argument to "apply". -
compileArgs
Compiles the tuple arguments to "apply". -
compile
-
compileFieldName
-
compileFieldNames
-
compileApply
-
finishCompileApply
protected Code finishCompileApply(Compiler.Context cx, Applicable fnValue, Code argCode, Type argType) -
finishCompileApply
-
compileFrom
-
createRowSinkFactory
protected Supplier<Codes.RowSink> createRowSinkFactory(Compiler.Context cx0, com.google.common.collect.ImmutableList<Binding> bindings, List<Core.FromStep> steps, Type elementType) -
sortedBindingMap
-
bindingNames
-
compileApplicable
Compiles a function value to anApplicable, if possible, or returns null. -
toApplicable
-
compileLet
-
finishCompileLet
-
compileLocal
-
compileDecl
void compileDecl(Compiler.Context cx, Core.Decl decl, @Nullable Core.NamedPat skipPat, Set<Core.Exp> queriesToWrap, List<Code> matchCodes, List<Binding> bindings, List<Compiler.Action> actions) -
compileDatatypeDecl
-
compileCall
-
compileMatchList
Compiles amatchexpression.- Parameters:
cx- Compile contextmatchList- List of Match- Returns:
- Code for match
-
compileMatch
private void compileMatch(Compiler.Context cx, Core.Match match, BiConsumer<Core.Pat, Code> consumer) -
compileValDecl
private void compileValDecl(Compiler.Context cx, Core.ValDecl valDecl, @Nullable Core.Pat skipPat, Set<Core.Exp> queriesToWrap, List<Code> matchCodes, List<Binding> bindings, List<Compiler.Action> actions) -
shredValue
-
link
-