Class OptimizeCodeGenerator
java.lang.Object
com.googlecode.aviator.code.OptimizeCodeGenerator
- All Implemented Interfaces:
CodeGenerator
Optimized code generator
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final EvalCodeGeneratorprivate Envprivate final AviatorEvaluatorInstanceprivate Map<String, LambdaFunctionBootstrap> Compiled lambda functions.private LambdaGeneratorprivate CodeGeneratorprivate Parserprivate final String -
Constructor Summary
ConstructorsConstructorDescriptionOptimizeCodeGenerator(AviatorEvaluatorInstance instance, String sourceFile, ClassLoader classLoader, OutputStream traceOutStream) -
Method Summary
Modifier and TypeMethodDescriptionprivate voidprivate voidprivate intexecute()private intexecuteOperator(Map<Integer, DelegateToken.DelegateTokenType> index2DelegateType, Token<?> operatorToken, OperatorType operatorType, int operatorIndex, int operandCount) private AviatorObjectgetAviatorObjectFromToken(Token<?> lookhead) private Envprivate Map<Integer, DelegateToken.DelegateTokenType> getIndex2DelegateTypeMap(OperatorType opType) getResult(boolean unboxObject) private Token<?> getTokenFromOperand(Token<?> operatorToken, AviatorObject operand) Get token from executing resultprivate booleanisLiteralOperand(Token<?> token, Token.TokenType tokenType, int index, Map<Integer, DelegateToken.DelegateTokenType> index2DelegateType) voidvoidvoidonAndRight(Token<?> lookhead) voidvoidonArrayIndexEnd(Token<?> lookhead) voidonArrayIndexStart(Token<?> lookhead) voidonAssignment(Token<?> lookhead) voidvoidvoidvoidvoidonConstant(Token<?> lookhead) voidvoidvoidonExponent(Token<?> lookhead) voidvoidvoidonJoinLeft(Token<?> lookhead) voidonJoinRight(Token<?> lookhead) voidonLambdaArgument(Token<?> lookhead, FunctionParam param) voidonLambdaBodyEnd(Token<?> lookhead) voidonLambdaBodyStart(Token<?> lookhead) voidonLambdaDefineStart(Token<?> lookhead) voidvoidvoidvoidonMethodInvoke(Token<?> lookhead) voidonMethodName(Token<?> lookhead) voidonMethodParameter(Token<?> lookhead) voidvoidvoidvoidvoidvoidonShiftLeft(Token<?> lookhead) voidonShiftRight(Token<?> lookhead) voidvoidonTernaryBoolean(Token<?> lookhead) voidonTernaryEnd(Token<?> lookhead) voidonTernaryLeft(Token<?> lookhead) voidonTernaryRight(Token<?> lookhead) voidonUnsignedShiftRight(Token<?> lookhead) private voidvoid
-
Field Details
-
codeGen
-
tokenList
-
lambdaGenerator
-
parentCodeGenerator
-
instance
-
parser
-
compileEnv
-
lambdaBootstraps
Compiled lambda functions. -
sourceFile
-
-
Constructor Details
-
OptimizeCodeGenerator
public OptimizeCodeGenerator(AviatorEvaluatorInstance instance, String sourceFile, ClassLoader classLoader, OutputStream traceOutStream)
-
-
Method Details
-
getCompileEnv
-
setParser
- Specified by:
setParserin interfaceCodeGenerator
-
getIndex2DelegateTypeMap
-
execute
private int execute() -
executeOperator
private int executeOperator(Map<Integer, DelegateToken.DelegateTokenType> index2DelegateType, Token<?> operatorToken, OperatorType operatorType, int operatorIndex, int operandCount) -
isLiteralOperand
private boolean isLiteralOperand(Token<?> token, Token.TokenType tokenType, int index, Map<Integer, DelegateToken.DelegateTokenType> index2DelegateType) -
getTokenFromOperand
Get token from executing result- Parameters:
operand-- Returns:
-
compactTokenList
private void compactTokenList() -
getAviatorObjectFromToken
-
getResult
- Specified by:
getResultin interfaceCodeGenerator
-
callASM
-
printTokenList
private void printTokenList() -
onAdd
- Specified by:
onAddin interfaceCodeGenerator
-
onAndLeft
- Specified by:
onAndLeftin interfaceCodeGenerator
-
onAndRight
- Specified by:
onAndRightin interfaceCodeGenerator
-
onConstant
- Specified by:
onConstantin interfaceCodeGenerator
-
onDiv
- Specified by:
onDivin interfaceCodeGenerator
-
onArrayIndexStart
- Specified by:
onArrayIndexStartin interfaceCodeGenerator
-
onAssignment
- Specified by:
onAssignmentin interfaceCodeGenerator
-
onArrayIndexEnd
- Specified by:
onArrayIndexEndin interfaceCodeGenerator
-
onArray
- Specified by:
onArrayin interfaceCodeGenerator
-
onEq
- Specified by:
onEqin interfaceCodeGenerator
-
onGe
- Specified by:
onGein interfaceCodeGenerator
-
onGt
- Specified by:
onGtin interfaceCodeGenerator
-
onJoinLeft
- Specified by:
onJoinLeftin interfaceCodeGenerator
-
onJoinRight
- Specified by:
onJoinRightin interfaceCodeGenerator
-
onLe
- Specified by:
onLein interfaceCodeGenerator
-
onLt
- Specified by:
onLtin interfaceCodeGenerator
-
onMatch
- Specified by:
onMatchin interfaceCodeGenerator
-
onMethodInvoke
- Specified by:
onMethodInvokein interfaceCodeGenerator
-
onMethodName
- Specified by:
onMethodNamein interfaceCodeGenerator
-
onMethodParameter
- Specified by:
onMethodParameterin interfaceCodeGenerator
-
onLambdaDefineStart
- Specified by:
onLambdaDefineStartin interfaceCodeGenerator
-
onLambdaArgument
- Specified by:
onLambdaArgumentin interfaceCodeGenerator
-
onLambdaBodyStart
- Specified by:
onLambdaBodyStartin interfaceCodeGenerator
-
onLambdaBodyEnd
- Specified by:
onLambdaBodyEndin interfaceCodeGenerator
-
onMod
- Specified by:
onModin interfaceCodeGenerator
-
onMult
- Specified by:
onMultin interfaceCodeGenerator
-
onExponent
- Specified by:
onExponentin interfaceCodeGenerator
-
onNeg
- Specified by:
onNegin interfaceCodeGenerator
-
onNeq
- Specified by:
onNeqin interfaceCodeGenerator
-
onNot
- Specified by:
onNotin interfaceCodeGenerator
-
onSub
- Specified by:
onSubin interfaceCodeGenerator
-
onTernaryBoolean
- Specified by:
onTernaryBooleanin interfaceCodeGenerator
-
onTernaryLeft
- Specified by:
onTernaryLeftin interfaceCodeGenerator
-
onTernaryRight
- Specified by:
onTernaryRightin interfaceCodeGenerator
-
onTernaryEnd
- Specified by:
onTernaryEndin interfaceCodeGenerator
-
onBitAnd
- Specified by:
onBitAndin interfaceCodeGenerator
-
onBitNot
- Specified by:
onBitNotin interfaceCodeGenerator
-
onBitOr
- Specified by:
onBitOrin interfaceCodeGenerator
-
onShiftLeft
- Specified by:
onShiftLeftin interfaceCodeGenerator
-
onShiftRight
- Specified by:
onShiftRightin interfaceCodeGenerator
-
onUnsignedShiftRight
- Specified by:
onUnsignedShiftRightin interfaceCodeGenerator
-
onBitXor
- Specified by:
onBitXorin interfaceCodeGenerator
-