Package org.mvel2.util
Class CompilerTools
- java.lang.Object
-
- org.mvel2.util.CompilerTools
-
public class CompilerTools extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description CompilerTools()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static BinaryOperationboOptimize(int op, ASTNode tk, ASTNode tk2, ParserContext pCtx)static voidexpectType(ParserContext pCtx, ASTNode node, java.lang.Class type, boolean compileMode)static voidexpectType(ParserContext pCtx, Accessor expression, java.lang.Class type, boolean compileMode)static AccessorextractAccessor(ASTNode n)static java.util.Map<java.lang.String,Function>extractAllDeclaredFunctions(CompiledExpression compile)Returns an ordered Map of all functions declared within an compiled script.static ASTLinkedListfinalizePayload(ASTLinkedList astLinkedList, boolean secondPassOptimization, ParserContext pCtx)Finalize the payload, by reducing any stack-based-operations to dedicated nodes where possible.static java.util.Map<java.lang.String,java.lang.Object>getInjectedImports(VariableResolverFactory factory)static java.lang.ClassgetReturnType(ASTIterator input, boolean strongTyping)static java.lang.ClassgetReturnTypeFromOp(int operation, java.lang.Class left, java.lang.Class right)private static booleanisIntOptimizationviolation(BooleanNode bn, ASTNode bn2)private static booleanisReductionOpportunity(ASTNode oper, ASTNode node)private static voidoptimizeOperator(int operator, ASTNode tk, ASTNode tkOp, ASTLinkedList astLinkedList, ASTLinkedList optimizedAst, ParserContext pCtx)private static booleanreducacbleOperator(int oper)static java.lang.NumbersignNumber(java.lang.Object number)
-
-
-
Method Detail
-
finalizePayload
public static ASTLinkedList finalizePayload(ASTLinkedList astLinkedList, boolean secondPassOptimization, ParserContext pCtx)
Finalize the payload, by reducing any stack-based-operations to dedicated nodes where possible.- Parameters:
astLinkedList- - AST to be optimized.secondPassOptimization- - perform a second pass optimization to optimize boolean expressions.pCtx- - The parser context- Returns:
- optimized AST
-
boOptimize
private static BinaryOperation boOptimize(int op, ASTNode tk, ASTNode tk2, ParserContext pCtx)
-
reducacbleOperator
private static boolean reducacbleOperator(int oper)
-
optimizeOperator
private static void optimizeOperator(int operator, ASTNode tk, ASTNode tkOp, ASTLinkedList astLinkedList, ASTLinkedList optimizedAst, ParserContext pCtx)
-
isIntOptimizationviolation
private static boolean isIntOptimizationviolation(BooleanNode bn, ASTNode bn2)
-
getReturnType
public static java.lang.Class getReturnType(ASTIterator input, boolean strongTyping)
-
extractAllDeclaredFunctions
public static java.util.Map<java.lang.String,Function> extractAllDeclaredFunctions(CompiledExpression compile)
Returns an ordered Map of all functions declared within an compiled script.- Parameters:
compile- compile- Returns:
- - ordered Map
-
expectType
public static void expectType(ParserContext pCtx, Accessor expression, java.lang.Class type, boolean compileMode)
-
expectType
public static void expectType(ParserContext pCtx, ASTNode node, java.lang.Class type, boolean compileMode)
-
getReturnTypeFromOp
public static java.lang.Class getReturnTypeFromOp(int operation, java.lang.Class left, java.lang.Class right)
-
getInjectedImports
public static java.util.Map<java.lang.String,java.lang.Object> getInjectedImports(VariableResolverFactory factory)
-
signNumber
public static java.lang.Number signNumber(java.lang.Object number)
-
-