Package net.hydromatic.morel.compile
Class Compiles
- java.lang.Object
-
- net.hydromatic.morel.compile.Compiles
-
public abstract class Compiles extends Object
Helpers forCompilerandTypeResolver.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classCompiles.PatternBinder
-
Constructor Summary
Constructors Constructor Description Compiles()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidacceptBinding(TypeSystem typeSystem, Core.Pat pat, List<Binding> bindings)Visits a pattern, adding bindings to a list.static voidbindDataType(TypeSystem typeSystem, List<Binding> bindings, DataType dataType)(package private) static Compiles.PatternBinderbinding(TypeSystem typeSystem, List<Binding> bindings)(package private) static voidbindPattern(TypeSystem typeSystem, List<Binding> bindings, Core.DatatypeDecl datatypeDecl)(package private) static voidbindPattern(TypeSystem typeSystem, List<Binding> bindings, Core.NamedPat namedPat)(package private) static voidbindPattern(TypeSystem typeSystem, List<Binding> bindings, Core.Pat pat)(package private) static voidbindPattern(TypeSystem typeSystem, List<Binding> bindings, Core.ValDecl valDecl)Richer thanbindPattern(TypeSystem, List, Core.Pat)because we have the expression.private static voidcheckPatternCoverage(TypeSystem typeSystem, Core.Case kase, Consumer<CompileException> errorConsumer, Consumer<CompileException> warningConsumer)private static voidcheckPatternCoverage(TypeSystem typeSystem, Core.Decl decl, Consumer<CompileException> warningConsumer)Checks for exhaustive and redundant patterns, and throws if there are errors/warnings.private static CompiledStatementprepareDecl(TypeSystem typeSystem, Session session, Environment env, @Nullable Calcite calcite, Ast.Decl decl, boolean isDecl, Consumer<CompileException> warningConsumer, Tracer tracer)Validates and compiles a declaration, and compiles it to code that can be evaluated by the interpreter.static CompiledStatementprepareStatement(TypeSystem typeSystem, Session session, Environment env, AstNode statement, @Nullable Calcite calcite, Consumer<CompileException> warningConsumer, Tracer tracer)Validates and compiles a statement (expression or declaration), and compiles it to code that can be evaluated by the interpreter.static Ast.DecltoDecl(AstNode statement)Converts an expression or declaration to a declaration.static Core.ExptoExp(Core.NonRecValDecl decl)static Ast.ValDecltoValDecl(Ast.Exp statement)Convertsetoval = e.static Ast.ValDecltoValDecl(AstNode statement)Converts an expression or value declaration to a value declaration.static TypeResolver.ResolvedvalidateExpression(AstNode statement, Map<String,ForeignValue> valueMap)Validates an expression or declaration, deducing its type and perhaps rewriting the expression to a form that can more easily be compiled.
-
-
-
Method Detail
-
validateExpression
public static TypeResolver.Resolved validateExpression(AstNode statement, Map<String,ForeignValue> valueMap)
Validates an expression or declaration, deducing its type and perhaps rewriting the expression to a form that can more easily be compiled.Used for testing.
-
prepareStatement
public static CompiledStatement prepareStatement(TypeSystem typeSystem, Session session, Environment env, AstNode statement, @Nullable Calcite calcite, Consumer<CompileException> warningConsumer, Tracer tracer)
Validates and compiles a statement (expression or declaration), and compiles it to code that can be evaluated by the interpreter.
-
prepareDecl
private static CompiledStatement prepareDecl(TypeSystem typeSystem, Session session, Environment env, @Nullable Calcite calcite, Ast.Decl decl, boolean isDecl, Consumer<CompileException> warningConsumer, Tracer tracer)
Validates and compiles a declaration, and compiles it to code that can be evaluated by the interpreter.
-
checkPatternCoverage
private static void checkPatternCoverage(TypeSystem typeSystem, Core.Decl decl, Consumer<CompileException> warningConsumer)
Checks for exhaustive and redundant patterns, and throws if there are errors/warnings.
-
checkPatternCoverage
private static void checkPatternCoverage(TypeSystem typeSystem, Core.Case kase, Consumer<CompileException> errorConsumer, Consumer<CompileException> warningConsumer)
-
toValDecl
public static Ast.ValDecl toValDecl(Ast.Exp statement)
Convertsetoval = e.
-
toValDecl
public static Ast.ValDecl toValDecl(AstNode statement)
Converts an expression or value declaration to a value declaration.
-
toDecl
public static Ast.Decl toDecl(AstNode statement)
Converts an expression or declaration to a declaration.
-
toExp
public static Core.Exp toExp(Core.NonRecValDecl decl)
-
bindPattern
static void bindPattern(TypeSystem typeSystem, List<Binding> bindings, Core.DatatypeDecl datatypeDecl)
-
bindPattern
static void bindPattern(TypeSystem typeSystem, List<Binding> bindings, Core.ValDecl valDecl)
Richer thanbindPattern(TypeSystem, List, Core.Pat)because we have the expression.
-
bindPattern
static void bindPattern(TypeSystem typeSystem, List<Binding> bindings, Core.Pat pat)
-
bindPattern
static void bindPattern(TypeSystem typeSystem, List<Binding> bindings, Core.NamedPat namedPat)
-
bindDataType
public static void bindDataType(TypeSystem typeSystem, List<Binding> bindings, DataType dataType)
-
binding
static Compiles.PatternBinder binding(TypeSystem typeSystem, List<Binding> bindings)
-
acceptBinding
public static void acceptBinding(TypeSystem typeSystem, Core.Pat pat, List<Binding> bindings)
Visits a pattern, adding bindings to a list.If the pattern is an
Core.IdPat, don't use this method: just bind directly.
-
-