Class StaticTypesBinaryExpressionMultiTypeDispatcher
java.lang.Object
org.codehaus.groovy.classgen.asm.BinaryExpressionHelper
org.codehaus.groovy.classgen.asm.BinaryExpressionMultiTypeDispatcher
org.codehaus.groovy.classgen.asm.sc.StaticTypesBinaryExpressionMultiTypeDispatcher
- Direct Known Subclasses:
IndyStaticTypesMultiTypeDispatcher
public class StaticTypesBinaryExpressionMultiTypeDispatcher
extends BinaryExpressionMultiTypeDispatcher
A specialized version of the multi type binary expression dispatcher which is aware of static compilation.
It is able to generate optimized bytecode for some operations using JVM instructions when available.
-
Field Summary
Fields inherited from class org.codehaus.groovy.classgen.asm.BinaryExpressionMultiTypeDispatcher
binExpWriter, typeMap, typeMapKeyNamesFields inherited from class org.codehaus.groovy.classgen.asm.BinaryExpressionHelper
controller -
Constructor Summary
ConstructorsConstructorDescriptionCreates a binary-expression dispatcher for statically compiled bytecode generation. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidassignToArray(Expression enclosing, Expression receiver, Expression subscript, Expression rhsValueLoader, boolean safe) Emits an array-style assignment using the dynamicputAtprotocol.protected voidevaluateBinaryExpressionWithAssignment(String method, BinaryExpression expression) Evaluates an operator-assignment expression such as+=.protected voidevaluateCompoundAssign(String assignName, String baseName, BinaryExpression expression) GEP-15: dynamic-mode compound-assign codegen.voidevaluateEqual(BinaryExpression expression, boolean defineVariable) Evaluates an assignment expression.protected voidwritePostOrPrefixMethod(int op, String method, Expression expression, Expression orig) Emits the method call used to implement a prefix or postfix operation.Methods inherited from class org.codehaus.groovy.classgen.asm.BinaryExpressionMultiTypeDispatcher
doPrimitiveCompare, doPrimtiveCompare, evaluateBinaryExpression, evaluateCompareExpression, getOperandType, initializeDelegateHelpersMethods inherited from class org.codehaus.groovy.classgen.asm.BinaryExpressionHelper
eval, evaluateArrayAssignmentWithOperator, evaluateElvisEqual, evaluatePostfixMethod, evaluatePrefixMethod, evaluateTernary, getController, getIsCaseMethod
-
Constructor Details
-
StaticTypesBinaryExpressionMultiTypeDispatcher
Creates a binary-expression dispatcher for statically compiled bytecode generation.
-
-
Method Details
-
writePostOrPrefixMethod
protected void writePostOrPrefixMethod(int op, String method, Expression expression, Expression orig) Emits the method call used to implement a prefix or postfix operation.- Overrides:
writePostOrPrefixMethodin classBinaryExpressionMultiTypeDispatcher- Parameters:
op- the token typemethod- the helper method nameexpression- the receiver expressionorig- the original prefix/postfix expression
-
evaluateBinaryExpressionWithAssignment
Evaluates an operator-assignment expression such as+=.- Overrides:
evaluateBinaryExpressionWithAssignmentin classBinaryExpressionMultiTypeDispatcher- Parameters:
method- the operator method nameexpression- the assignment expression
-
evaluateCompoundAssign
protected void evaluateCompoundAssign(String assignName, String baseName, BinaryExpression expression) GEP-15: dynamic-mode compound-assign codegen. Routes throughScriptBytecodeAdapter.compoundAssign(Object, Object, String, String)which dispatches toassignNamewhen the receiver responds to it, and falls back tobaseNameotherwise. The caller stores the helper's return value into the LHS — for the in-place branch this is a no-op store of the receiver back to itself; for the fallback branch it is the usual "x = x.op(y)" assignment.- Overrides:
evaluateCompoundAssignin classBinaryExpressionMultiTypeDispatcher
-
evaluateEqual
Evaluates an assignment expression.- Overrides:
evaluateEqualin classBinaryExpressionHelper- Parameters:
expression- the assignment expressiondefineVariable- whether the left-hand side declares a new variable
-
assignToArray
protected void assignToArray(Expression enclosing, Expression receiver, Expression subscript, Expression rhsValueLoader, boolean safe) Emits an array-style assignment using the dynamicputAtprotocol.- Overrides:
assignToArrayin classBinaryExpressionMultiTypeDispatcher- Parameters:
enclosing- the original assignment expressionreceiver- the array or indexable receiversubscript- the subscript expressionrhsValueLoader- an expression that reloads the right-hand valuesafe- whether the receiver access is null-safe
-