Package net.hydromatic.morel.compile
Class Compiler
- java.lang.Object
-
- net.hydromatic.morel.compile.Compiler
-
public class Compiler extends java.lang.ObjectCompiles an expression to code that can be evaluated.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static interfaceCompiler.ActionSomething that needs to happen when a declaration is evaluated.private static classCompiler.ComparableSingletonList<E extends java.lang.Comparable<E>>A comparable singleton list.private static classCompiler.LinkCodeA piece of code that is references another piece of code.
-
Field Summary
Fields Modifier and Type Field Description private static EvalEnvEMPTY_ENVprivate TypeResolver.TypeMaptypeMap
-
Constructor Summary
Constructors Constructor Description Compiler(TypeResolver.TypeMap typeMap)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidassignSelector(Ast.Apply apply)Codecompile(Environment env, Ast.Exp expression)private CodecompileAggregate(Environment env, Ast.Aggregate aggregate)private ApplicablecompileApplicable(Environment env, Ast.Exp fn)Compiles a function value to anApplicable, if possible, or returns null.private voidcompileDatatypeDecl(Environment env, Ast.DatatypeDecl datatypeDecl, java.util.List<Binding> bindings, java.util.List<Compiler.Action> actions)private voidcompileDecl(Environment env, Ast.Decl decl, java.util.List<Code> varCodes, java.util.List<Binding> bindings, java.util.List<Compiler.Action> actions)private CodecompileInfix(Environment env, Ast.InfixCall call)private CodecompileLet(Environment env, java.util.List<Ast.Decl> decls, Ast.Exp e)private CodecompileLet(Environment env, Ast.Decl decl, Ast.Exp e)private CodecompileMatchList(Environment env, java.lang.Iterable<Ast.Match> matchList)Compiles amatchexpression.(package private) CompiledStatementcompileStatement(Environment env, Ast.Decl decl)private voidcompileTyCon(Environment env, Type dataType, Ast.TyCon tyCon, java.util.List<Binding> bindings)private CodecompileUnary(Environment env, Ast.Exp call)private voidcompileValBind(Environment env, Ast.ValBind valBind, java.util.List<Code> varCodes, java.util.List<Binding> bindings, java.util.List<Compiler.Action> actions)private voidcompileValDecl(Environment env, Ast.ValDecl valDecl, java.util.List<Code> varCodes, java.util.List<Binding> bindings, java.util.List<Compiler.Action> actions)private Ast.PatexpandRecordPattern(Ast.Pat pat)Expands a pattern if it is a record pattern that has an ellipsis or if the arguments are not in the same order as the labels in the type.private voidflatten(java.util.Map<Ast.Pat,Ast.Exp> matches, Ast.Pat pat, Ast.Exp exp)private Ast.LetExpflattenLet(java.util.List<Ast.Decl> decls, Ast.Exp e)private voidlink(java.util.Map<Ast.IdPat,Compiler.LinkCode> linkCodes, Ast.Pat pat, Code code)
-
-
-
Field Detail
-
EMPTY_ENV
private static final EvalEnv EMPTY_ENV
-
typeMap
private final TypeResolver.TypeMap typeMap
-
-
Constructor Detail
-
Compiler
public Compiler(TypeResolver.TypeMap typeMap)
-
-
Method Detail
-
compileStatement
CompiledStatement compileStatement(Environment env, Ast.Decl decl)
-
compile
public Code compile(Environment env, Ast.Exp expression)
-
assignSelector
private void assignSelector(Ast.Apply apply)
-
compileApplicable
private Applicable compileApplicable(Environment env, Ast.Exp fn)
Compiles a function value to anApplicable, if possible, or returns null.
-
compileAggregate
private Code compileAggregate(Environment env, Ast.Aggregate aggregate)
-
compileLet
private Code compileLet(Environment env, java.util.List<Ast.Decl> decls, Ast.Exp e)
-
compileLet
private Code compileLet(Environment env, Ast.Decl decl, Ast.Exp e)
-
flattenLet
private Ast.LetExp flattenLet(java.util.List<Ast.Decl> decls, Ast.Exp e)
-
compileDecl
private void compileDecl(Environment env, Ast.Decl decl, java.util.List<Code> varCodes, java.util.List<Binding> bindings, java.util.List<Compiler.Action> actions)
-
compileValDecl
private void compileValDecl(Environment env, Ast.ValDecl valDecl, java.util.List<Code> varCodes, java.util.List<Binding> bindings, java.util.List<Compiler.Action> actions)
-
compileDatatypeDecl
private void compileDatatypeDecl(Environment env, Ast.DatatypeDecl datatypeDecl, java.util.List<Binding> bindings, java.util.List<Compiler.Action> actions)
-
compileTyCon
private void compileTyCon(Environment env, Type dataType, Ast.TyCon tyCon, java.util.List<Binding> bindings)
-
compileInfix
private Code compileInfix(Environment env, Ast.InfixCall call)
-
compileUnary
private Code compileUnary(Environment env, Ast.Exp call)
-
compileMatchList
private Code compileMatchList(Environment env, java.lang.Iterable<Ast.Match> matchList)
Compiles amatchexpression.- Parameters:
env- Compile environmentmatchList- List of Match- Returns:
- Code for match
-
expandRecordPattern
private Ast.Pat expandRecordPattern(Ast.Pat pat)
Expands a pattern if it is a record pattern that has an ellipsis or if the arguments are not in the same order as the labels in the type.
-
compileValBind
private void compileValBind(Environment env, Ast.ValBind valBind, java.util.List<Code> varCodes, java.util.List<Binding> bindings, java.util.List<Compiler.Action> actions)
-
link
private void link(java.util.Map<Ast.IdPat,Compiler.LinkCode> linkCodes, Ast.Pat pat, Code code)
-
-