Package net.hydromatic.morel.eval
Class Codes
- java.lang.Object
-
- net.hydromatic.morel.eval.Codes
-
public abstract class Codes extends java.lang.ObjectHelpers forCode.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCodes.TupleCodeA code that evaluates expressions and creates a tuple with the results.
-
Field Summary
Fields Modifier and Type Field Description private static ApplicableABSAn applicable that returns the absolute value of an int.private static com.google.common.collect.ImmutableMap<BuiltIn,java.lang.Object>BUILT_IN_VALUESprivate static ApplicableIGNOREprivate static ApplicableLIST_ALLprivate static ApplicableLIST_APPprivate static ApplicableLIST_ATprivate static ApplicableLIST_COLLATEprivate static ApplicableLIST_CONCATprivate static ApplicableLIST_DROPprivate static ApplicableLIST_EXISTSprivate static ApplicableLIST_FILTERprivate static ApplicableLIST_FINDprivate static ApplicableLIST_FOLDLprivate static ApplicableLIST_FOLDRprivate static ApplicableLIST_GET_ITEMprivate static ApplicableLIST_HDprivate static ApplicableLIST_LASTprivate static ApplicableLIST_LENGTHprivate static ApplicableLIST_MAPprivate static ApplicableLIST_NTHprivate static ApplicableLIST_NULLprivate static ApplicableLIST_PARTITIONprivate static ApplicableLIST_REVprivate static ApplicableLIST_REV_APPENDprivate static ApplicableLIST_TABULATEprivate static ApplicableLIST_TAKEprivate static ApplicableLIST_TLprivate static ApplicableNOTAn applicable that negates a boolean value.private static ApplicableRELATIONAL_COUNTprivate static ApplicableRELATIONAL_SUMprivate static ApplicableSTRING_CONCATprivate static ApplicableSTRING_CONCAT_WITHprivate static ApplicableSTRING_EXPLODEprivate static ApplicableSTRING_EXTRACTprivate static ApplicableSTRING_IMPLODEprivate static ApplicableSTRING_IS_PREFIXprivate static ApplicableSTRING_IS_SUBSTRINGprivate static ApplicableSTRING_IS_SUFFIXprivate static ApplicableSTRING_MAPprivate static java.lang.IntegerSTRING_MAX_SIZEprivate static ApplicableSTRING_SIZEprivate static ApplicableSTRING_STRprivate static ApplicableSTRING_SUBprivate static ApplicableSTRING_SUBSTRINGprivate static ApplicableSTRING_TRANSLATEprivate static MacroSYS_ENV
-
Constructor Summary
Constructors Modifier Constructor Description privateCodes()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Applicableaggregate(Environment env, Code aggregate, Code argumentCode)static CodeandAlso(Code code0, Code code1)Returns a Code that evaluates "andalso".static Codeapply(Applicable fnValue, Code argCode)Generates the code for applying a function value to an argument.static Codeapply(Code fnCode, Code argCode)Generates the code for applying a function (or function value) to an argument.static Codecaret(Code code0, Code code1)Returns a Code that evaluates "^" (string concatenation).private static Applicablecollate(Applicable comparator)static Codecons(Code code0, Code code1)Returns a Code that evaluates "::" (list cons).static Codeconstant(java.lang.Comparable value)Returns a Code that evaluates to the same value in all environments.static Codediv(Code code0, Code code1)Returns a Code that evaluates "div".static Codedivide(Code code0, Code code1)Returns a Code that evaluates "/".static EvalEnvemptyEnv()Creates an empty evaluation environment.static EvalEnvemptyEnvWith(Environment env)Creates an evaluation environment that contains the bound values from a compilation environment.static Environmentenv(TypeSystem typeSystem, Environment environment)Creates a compilation environment.static Codeeq(Code code0, Code code1)Returns a Code that evaluates "=".private static Applicablefind(Applicable fn)static Codefrom(java.util.Map<Ast.Id,Code> sources, Code filterCode, Code yieldCode)static CodefromGroup(java.util.Map<Ast.Id,Code> sources, Code filterCode, java.util.List<Code> groupCodes, java.util.List<Applicable> aggregateCodes, java.util.List<java.lang.String> labels)static Codege(Code code0, Code code1)Returns a Code that evaluates ">=".static Codeget(java.lang.String name)Returns a Code that returns the value of variable "name" in the current environment.static Codegt(Code code0, Code code1)Returns a Code that evaluates ">".static CodeifThenElse(Code condition, Code ifTrue, Code ifFalse)private static ApplicableisPrefix(java.lang.String s)private static ApplicableisSubstring(java.lang.String s)private static ApplicableisSuffix(java.lang.String s)static Codele(Code code0, Code code1)Returns a Code that evaluates "<=".static Codelet(java.util.List<Code> fnCodes, Code argCode)static Codelist(java.lang.Iterable<? extends Code> codes)private static ApplicablelistAll(Applicable fn)private static ApplicablelistApp(Applicable consumer)private static ApplicablelistExists(Applicable fn)private static ApplicablelistFilter(Applicable fn)private static ApplicablelistFold(boolean left, Applicable fn)private static ApplicablelistFold2(boolean left, Applicable fn, java.lang.Object init)private static ApplicablelistMap(Applicable fn)private static ApplicablelistPartition(Applicable fn)static Codelt(Code code0, Code code1)Returns a Code that evaluates "<".private static <E> java.util.Set<E>minus(java.util.Set<E> set1, java.util.Set<E> set0)static Codeminus(Code code0, Code code1)Returns a Code that evaluates "-".static Codemod(Code code0, Code code1)Returns a Code that evaluates "mod".static Codene(Code code0, Code code1)Returns a Code that evaluates "<>".static Codenegate(Code code)static Applicablenth(int slot)Returns an applicable that returns theslotth field of a tuple or record.static CodeorElse(Code code0, Code code1)Returns a Code that evaluates "orelse".static Codeplus(Code code0, Code code1)Returns a Code that evaluates "+".private static voidpopulateBuiltIns(java.util.Map<java.lang.String,java.lang.Object> valueMap)private static ApplicablestringConcat(java.lang.String separator)private static ApplicablestringMap(Applicable f)static Codetimes(Code code0, Code code1)Returns a Code that evaluates "*".private static Applicabletranslate(Applicable f)static Codetuple(java.lang.Iterable<? extends Code> codes)static ApplicabletyCon(Type dataType, java.lang.String name)Returns an applicable that constructs an instance of a datatype.
-
-
-
Field Detail
-
NOT
private static final Applicable NOT
An applicable that negates a boolean value.
-
ABS
private static final Applicable ABS
An applicable that returns the absolute value of an int.
-
IGNORE
private static final Applicable IGNORE
- See Also:
BuiltIn.IGNORE
-
STRING_MAX_SIZE
private static final java.lang.Integer STRING_MAX_SIZE
- See Also:
BuiltIn.STRING_MAX_SIZE
-
STRING_SIZE
private static final Applicable STRING_SIZE
- See Also:
BuiltIn.STRING_SIZE
-
STRING_SUB
private static final Applicable STRING_SUB
- See Also:
BuiltIn.STRING_SUB
-
STRING_EXTRACT
private static final Applicable STRING_EXTRACT
- See Also:
BuiltIn.STRING_EXTRACT
-
STRING_SUBSTRING
private static final Applicable STRING_SUBSTRING
- See Also:
BuiltIn.STRING_SUBSTRING
-
STRING_CONCAT
private static final Applicable STRING_CONCAT
- See Also:
BuiltIn.STRING_CONCAT
-
STRING_CONCAT_WITH
private static final Applicable STRING_CONCAT_WITH
- See Also:
BuiltIn.STRING_CONCAT_WITH
-
STRING_STR
private static final Applicable STRING_STR
- See Also:
BuiltIn.STRING_STR
-
STRING_IMPLODE
private static final Applicable STRING_IMPLODE
- See Also:
BuiltIn.STRING_IMPLODE
-
STRING_EXPLODE
private static final Applicable STRING_EXPLODE
- See Also:
BuiltIn.STRING_EXPLODE
-
STRING_MAP
private static final Applicable STRING_MAP
- See Also:
BuiltIn.STRING_MAP
-
STRING_TRANSLATE
private static final Applicable STRING_TRANSLATE
- See Also:
BuiltIn.STRING_TRANSLATE
-
STRING_IS_PREFIX
private static final Applicable STRING_IS_PREFIX
- See Also:
BuiltIn.STRING_IS_PREFIX
-
STRING_IS_SUBSTRING
private static final Applicable STRING_IS_SUBSTRING
- See Also:
BuiltIn.STRING_IS_SUBSTRING
-
STRING_IS_SUFFIX
private static final Applicable STRING_IS_SUFFIX
- See Also:
BuiltIn.STRING_IS_SUFFIX
-
LIST_NULL
private static final Applicable LIST_NULL
- See Also:
BuiltIn.LIST_NULL
-
LIST_LENGTH
private static final Applicable LIST_LENGTH
- See Also:
BuiltIn.LIST_LENGTH
-
LIST_AT
private static final Applicable LIST_AT
- See Also:
BuiltIn.LIST_AT
-
LIST_HD
private static final Applicable LIST_HD
- See Also:
BuiltIn.LIST_HD
-
LIST_TL
private static final Applicable LIST_TL
- See Also:
BuiltIn.LIST_TL
-
LIST_LAST
private static final Applicable LIST_LAST
- See Also:
BuiltIn.LIST_LAST
-
LIST_GET_ITEM
private static final Applicable LIST_GET_ITEM
- See Also:
BuiltIn.LIST_GET_ITEM
-
LIST_NTH
private static final Applicable LIST_NTH
- See Also:
BuiltIn.LIST_NTH
-
LIST_TAKE
private static final Applicable LIST_TAKE
- See Also:
BuiltIn.LIST_TAKE
-
LIST_DROP
private static final Applicable LIST_DROP
- See Also:
BuiltIn.LIST_DROP
-
LIST_REV
private static final Applicable LIST_REV
- See Also:
BuiltIn.LIST_REV
-
LIST_CONCAT
private static final Applicable LIST_CONCAT
- See Also:
BuiltIn.LIST_CONCAT
-
LIST_REV_APPEND
private static final Applicable LIST_REV_APPEND
- See Also:
BuiltIn.LIST_REV_APPEND
-
LIST_APP
private static final Applicable LIST_APP
- See Also:
BuiltIn.LIST_APP
-
LIST_MAP
private static final Applicable LIST_MAP
- See Also:
BuiltIn.LIST_MAP
-
LIST_FIND
private static final Applicable LIST_FIND
- See Also:
BuiltIn.LIST_FIND
-
LIST_FILTER
private static final Applicable LIST_FILTER
- See Also:
BuiltIn.LIST_FILTER
-
LIST_PARTITION
private static final Applicable LIST_PARTITION
- See Also:
BuiltIn.LIST_PARTITION
-
LIST_FOLDL
private static final Applicable LIST_FOLDL
- See Also:
BuiltIn.LIST_FOLDL
-
LIST_FOLDR
private static final Applicable LIST_FOLDR
- See Also:
BuiltIn.LIST_FOLDR
-
LIST_EXISTS
private static final Applicable LIST_EXISTS
- See Also:
BuiltIn.LIST_EXISTS
-
LIST_ALL
private static final Applicable LIST_ALL
- See Also:
BuiltIn.LIST_ALL
-
LIST_TABULATE
private static final Applicable LIST_TABULATE
- See Also:
BuiltIn.LIST_TABULATE
-
LIST_COLLATE
private static final Applicable LIST_COLLATE
- See Also:
BuiltIn.LIST_COLLATE
-
RELATIONAL_COUNT
private static final Applicable RELATIONAL_COUNT
- See Also:
BuiltIn.RELATIONAL_COUNT
-
RELATIONAL_SUM
private static final Applicable RELATIONAL_SUM
- See Also:
BuiltIn.RELATIONAL_SUM
-
SYS_ENV
private static final Macro SYS_ENV
- See Also:
BuiltIn.SYS_ENV
-
BUILT_IN_VALUES
private static final com.google.common.collect.ImmutableMap<BuiltIn,java.lang.Object> BUILT_IN_VALUES
-
-
Method Detail
-
constant
public static Code constant(java.lang.Comparable value)
Returns a Code that evaluates to the same value in all environments.
-
andAlso
public static Code andAlso(Code code0, Code code1)
Returns a Code that evaluates "andalso".
-
caret
public static Code caret(Code code0, Code code1)
Returns a Code that evaluates "^" (string concatenation).
-
cons
public static Code cons(Code code0, Code code1)
Returns a Code that evaluates "::" (list cons).
-
get
public static Code get(java.lang.String name)
Returns a Code that returns the value of variable "name" in the current environment.
-
apply
public static Code apply(Code fnCode, Code argCode)
Generates the code for applying a function (or function value) to an argument.
-
apply
public static Code apply(Applicable fnValue, Code argCode)
Generates the code for applying a function value to an argument.
-
tyCon
public static Applicable tyCon(Type dataType, java.lang.String name)
Returns an applicable that constructs an instance of a datatype. The instance is a list with two elements [constructorName, value].
-
fromGroup
public static Code fromGroup(java.util.Map<Ast.Id,Code> sources, Code filterCode, java.util.List<Code> groupCodes, java.util.List<Applicable> aggregateCodes, java.util.List<java.lang.String> labels)
-
nth
public static Applicable nth(int slot)
Returns an applicable that returns theslotth field of a tuple or record.
-
stringConcat
private static Applicable stringConcat(java.lang.String separator)
-
stringMap
private static Applicable stringMap(Applicable f)
-
translate
private static Applicable translate(Applicable f)
-
isPrefix
private static Applicable isPrefix(java.lang.String s)
-
isSubstring
private static Applicable isSubstring(java.lang.String s)
-
isSuffix
private static Applicable isSuffix(java.lang.String s)
-
listApp
private static Applicable listApp(Applicable consumer)
-
listMap
private static Applicable listMap(Applicable fn)
-
find
private static Applicable find(Applicable fn)
-
listFilter
private static Applicable listFilter(Applicable fn)
-
listPartition
private static Applicable listPartition(Applicable fn)
-
listFold
private static Applicable listFold(boolean left, Applicable fn)
-
listFold2
private static Applicable listFold2(boolean left, Applicable fn, java.lang.Object init)
-
listExists
private static Applicable listExists(Applicable fn)
-
listAll
private static Applicable listAll(Applicable fn)
-
collate
private static Applicable collate(Applicable comparator)
-
populateBuiltIns
private static void populateBuiltIns(java.util.Map<java.lang.String,java.lang.Object> valueMap)
-
emptyEnv
public static EvalEnv emptyEnv()
Creates an empty evaluation environment.
-
emptyEnvWith
public static EvalEnv emptyEnvWith(Environment env)
Creates an evaluation environment that contains the bound values from a compilation environment.
-
env
public static Environment env(TypeSystem typeSystem, Environment environment)
Creates a compilation environment.
-
minus
private static <E> java.util.Set<E> minus(java.util.Set<E> set1, java.util.Set<E> set0)
-
aggregate
public static Applicable aggregate(Environment env, Code aggregate, Code argumentCode)
-
-