Package com.googlecode.aviator
Class BaseExpression
java.lang.Object
com.googlecode.aviator.BaseExpression
- All Implemented Interfaces:
Expression
,Serializable
- Direct Known Subclasses:
ClassExpression
,InterpretExpression
,LiteralExpression
Base expression
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Env
private String
static final String
private Map
<Integer, List<FunctionArgument>> protected AviatorEvaluatorInstance
protected Map
<String, LambdaFunctionBootstrap> private static final long
protected String
protected SymbolTable
private List
<VariableMeta> -
Constructor Summary
ConstructorsConstructorDescriptionBaseExpression
(AviatorEvaluatorInstance instance, List<VariableMeta> vars, SymbolTable symbolTable) -
Method Summary
Modifier and TypeMethodDescriptionAdds the specified symbol to the symbol table and returns a reference to the unique symbol.protected void
afterPopulateFullNames
(Map<String, VariableMeta> fullNames, Set<String> parentVars) void
void
customWriteObject
(ObjectOutputStream output) execute()
Execute an expression with an empty environment, returns the result.Execute an expression with an environment, returns the result.protected Object
abstract Object
executeDirectly
(Map<String, Object> env) protected Env
private long
getExecutionStartNs
(boolean checkExecutionTimeout) Returns the expression string when turn onOptions.TRACE_EVAL
option, else returns null.Returns the function names in the expression when using AviatorEvaluator.EVAL mode, otherwise returns an empty list.Returns the source file name.getStringSegements
(String lexeme, int lineNo) Returns this expression's all uninitialized global variable full names(contains dot) in order when using AviatorEvaluator.EVAL mode, otherwise returns an empty list.Returns this expression's all uninitialized global variable names in order when using AviatorEvaluator.EVAL mode, otherwise returns an empty list.getVars()
Created a faster env map(compare variable names by reference).The arguments should be a sequence of pair invalid input: '<'String, Object>.protected Env
protected Env
private void
private void
private void
protected void
setCompileEnv
(Env compileEnv) protected void
setExpression
(String expression) protected void
setFuncsArgs
(Map<Integer, List<FunctionArgument>> funcsArgs) protected void
setFunctionNames
(List<String> functionNames) protected void
setInstance
(AviatorEvaluatorInstance instance) protected void
setLambdaBootstraps
(Map<String, LambdaFunctionBootstrap> lambdaBootstraps) protected void
setSourceFile
(String sourceFile)
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
FUNC_PARAMS_VAR
- See Also:
-
varNames
-
varFullNames
-
vars
-
expression
-
instance
-
compileEnv
-
funcsArgs
-
symbolTable
-
stringSegs
private transient ConcurrentHashMap<String,FutureTask<AviatorEvaluatorInstance.StringSegments>> stringSegs -
functionNames
-
filteredFunctionNames
-
sourceFile
-
lambdaBootstraps
-
-
Constructor Details
-
BaseExpression
public BaseExpression(AviatorEvaluatorInstance instance, List<VariableMeta> vars, SymbolTable symbolTable)
-
-
Method Details
-
getSourceFile
Description copied from interface:Expression
Returns the source file name.- Specified by:
getSourceFile
in interfaceExpression
- Returns:
- the source file name
-
setSourceFile
-
setInstance
-
populateNames
private void populateNames() -
afterPopulateFullNames
-
populateFullNames
private void populateFullNames() -
getFullNameMetas
-
getStringSegements
-
newEnv
Description copied from interface:Expression
Created a faster env map(compare variable names by reference).The arguments should be a sequence of pair invalid input: '<'String, Object>.- Specified by:
newEnv
in interfaceExpression
- Parameters:
args
-- Returns:
- an env map
-
executeDirectly
-
execute
Description copied from interface:Expression
Execute an expression with an environment, returns the result.- Specified by:
execute
in interfaceExpression
- Parameters:
map
- Binding variable environment- Returns:
- the result of execution
-
execute
-
setFuncsArgs
-
getCompileEnv
-
setCompileEnv
-
getExpression
Returns the expression string when turn onOptions.TRACE_EVAL
option, else returns null.- Returns:
- expression in string.
-
setExpression
-
addSymbol
Description copied from interface:Expression
Adds the specified symbol to the symbol table and returns a reference to the unique symbol. If the symbol already exists, the previous symbol reference is returned instead, in order guarantee that symbol references remain unique.- Specified by:
addSymbol
in interfaceExpression
- Parameters:
name
- The symbol name.
-
execute
Description copied from interface:Expression
Execute an expression with an empty environment, returns the result.- Specified by:
execute
in interfaceExpression
- Returns:
- the result of execution
-
getVariableFullNames
Description copied from interface:Expression
Returns this expression's all uninitialized global variable full names(contains dot) in order when using AviatorEvaluator.EVAL mode, otherwise returns an empty list.- Specified by:
getVariableFullNames
in interfaceExpression
- Returns:
-
getVars
-
getVariableNames
Description copied from interface:Expression
Returns this expression's all uninitialized global variable names in order when using AviatorEvaluator.EVAL mode, otherwise returns an empty list.- Specified by:
getVariableNames
in interfaceExpression
- Returns:
- See Also:
-
newEnv
-
genTopEnv
-
getExecutionStartNs
private long getExecutionStartNs(boolean checkExecutionTimeout) -
newEnv
-
getFunctionNames
Description copied from interface:Expression
Returns the function names in the expression when using AviatorEvaluator.EVAL mode, otherwise returns an empty list.- Specified by:
getFunctionNames
in interfaceExpression
- Returns:
- the function name list
-
populateFilteredFuncNames
private void populateFilteredFuncNames() -
setFunctionNames
-
getLambdaBootstraps
-
setLambdaBootstraps
-
newLambda
-
customReadObject
- Throws:
ClassNotFoundException
IOException
-
customWriteObject
- Throws:
IOException
-