Package net.hydromatic.morel.compile
Class Compiler
- java.lang.Object
-
- net.hydromatic.morel.compile.Compiler
-
- Direct Known Subclasses:
CalciteCompiler
public class Compiler extends Object
Compiles an expression to code that can be evaluated.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static interfaceCompiler.ActionSomething that needs to happen when a declaration is evaluated.(package private) static classCompiler.ContextCompilation context.private static classCompiler.LinkCodeA piece of code that is references another piece of code.private static classCompiler.MatchCodeCode that implementscompileMatchList(Context, List).
-
Field Summary
Fields Modifier and Type Field Description protected static EvalEnvEMPTY_ENVprotected TypeSystemtypeSystem
-
Constructor Summary
Constructors Constructor Description Compiler(TypeSystem typeSystem)
-
Method Summary
-
-
-
Field Detail
-
EMPTY_ENV
protected static final EvalEnv EMPTY_ENV
-
typeSystem
protected final TypeSystem typeSystem
-
-
Constructor Detail
-
Compiler
public Compiler(TypeSystem typeSystem)
-
-
Method Detail
-
compileStatement
CompiledStatement compileStatement(Environment env, Core.Decl decl, boolean isDecl, Set<Core.Exp> queriesToWrap)
-
createContext
protected CalciteFunctions.Context createContext(Environment env)
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
public final Code compile(Environment env, Core.Exp expression)
-
compileArg
public Code compileArg(Compiler.Context cx, Core.Exp expression)
Compiles the argument to "apply".
-
compileArgs
public List<Code> compileArgs(Compiler.Context cx, Iterable<? extends Core.Exp> expressions)
Compiles the tuple arguments to "apply".
-
compile
public Code compile(Compiler.Context cx, Core.Exp expression)
-
compileFieldName
private Code compileFieldName(Compiler.Context cx, Core.NamedPat idPat)
-
compileFieldNames
private Code compileFieldNames(Compiler.Context cx, List<Core.IdPat> fieldNames)
-
compileApply
protected Code compileApply(Compiler.Context cx, Core.Apply apply)
-
finishCompileApply
protected Code finishCompileApply(Compiler.Context cx, Applicable fnValue, Code argCode, Type argType)
-
finishCompileApply
protected Code finishCompileApply(Compiler.Context cx, Code fnCode, Code argCode, Type argType)
-
compileFrom
protected Code compileFrom(Compiler.Context cx, Core.From from)
-
createRowSinkFactory
protected Supplier<Codes.RowSink> createRowSinkFactory(Compiler.Context cx0, com.google.common.collect.ImmutableList<Binding> bindings, List<Core.FromStep> steps, Type elementType)
-
sortedBindingMap
private com.google.common.collect.ImmutableSortedMap<String,Binding> sortedBindingMap(Iterable<Binding> bindings)
-
bindingNames
private com.google.common.collect.ImmutableList<String> bindingNames(List<Binding> bindings)
-
compileApplicable
private Applicable compileApplicable(Compiler.Context cx, Core.Exp fn, Type argType, Pos pos)
Compiles a function value to anApplicable, if possible, or returns null.
-
toApplicable
@Nullable private Applicable toApplicable(Compiler.Context cx, Object o, Type argType, Pos pos)
-
compileLet
private Code compileLet(Compiler.Context cx, Core.Let let)
-
finishCompileLet
protected Code finishCompileLet(Compiler.Context cx, List<Code> matchCodes, Code resultCode, Type resultType)
-
compileLocal
private Code compileLocal(Compiler.Context cx, Core.Local local)
-
compileDecl
void compileDecl(Compiler.Context cx, Core.Decl decl, boolean isDecl, Set<Core.Exp> queriesToWrap, List<Code> matchCodes, List<Binding> bindings, List<Compiler.Action> actions)
-
compileDatatypeDecl
private void compileDatatypeDecl(List<DataType> dataTypes, List<Binding> bindings, List<Compiler.Action> actions)
-
compileCall
private Code compileCall(Compiler.Context cx, BuiltIn builtIn, Core.Exp arg, Pos pos)
-
compileMatchList
private Code compileMatchList(Compiler.Context cx, List<Core.Match> matchList)
Compiles amatchexpression.- Parameters:
cx- Compile contextmatchList- List of Match- Returns:
- Code for match
-
compileMatch
private Pair<Core.Pat,Code> compileMatch(Compiler.Context cx, Core.Match match)
-
compileValDecl
private void compileValDecl(Compiler.Context cx, Core.ValDecl valDecl, boolean isDecl, Set<Core.Exp> queriesToWrap, List<Code> matchCodes, List<Binding> bindings, List<Compiler.Action> actions)
-
shredValue
private void shredValue(Core.Pat pat, Object o, BiConsumer<Core.NamedPat,Object> consumer)
-
link
private void link(Map<Core.NamedPat,Compiler.LinkCode> linkCodes, Core.Pat pat, Code code)
-
-