Package org.codehaus.groovy.classgen.asm
Class BinaryExpressionMultiTypeDispatcher
java.lang.Object
org.codehaus.groovy.classgen.asm.BinaryExpressionHelper
org.codehaus.groovy.classgen.asm.BinaryExpressionMultiTypeDispatcher
- Direct Known Subclasses:
StaticTypesBinaryExpressionMultiTypeDispatcher
This class is for internal use only!
This class will dispatch to the right type adapters according to the
kind of binary expression that is provided.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected BinaryExpressionWriter[]Per-type helpers used to emit primitive binary operations.Maps primitive operand types to helper indexes.static final String[]Human-readable names for the indexes used bytypeMap.Fields inherited from class org.codehaus.groovy.classgen.asm.BinaryExpressionHelper
controller -
Constructor Summary
ConstructorsConstructorDescriptionCreates a dispatcher that routes primitive binary expressions to type-specific helpers. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidassignToArray(Expression orig, Expression receiver, Expression index, Expression rhsValueLoader, boolean safe) Emits an array-style assignment using the dynamicputAtprotocol.protected booleandoPrimitiveCompare(ClassNode leftType, ClassNode rightType, BinaryExpression binExp) Attempts primitive comparison bytecode generation for the supplied operands.protected booleandoPrimtiveCompare(ClassNode leftType, ClassNode rightType, BinaryExpression binExp) Deprecated.protected voidevaluateBinaryExpression(String message, BinaryExpression binExp) Evaluates a dynamic binary operator by invoking the named helper method.protected voidevaluateBinaryExpressionWithAssignment(String method, BinaryExpression binExp) Evaluates an operator-assignment expression such as+=.protected voidevaluateCompareExpression(MethodCaller compareMethod, BinaryExpression binExp) Evaluates a comparison expression, using primitive helpers when possible.protected voidevaluateCompoundAssign(String assignName, String baseName, BinaryExpression binExp) GEP-15: dynamic-mode compound-assign codegen.protected intgetOperandType(ClassNode type) Returns the helper index for the supplied operand type.protected BinaryExpressionWriter[]Creates the helper table used for primitive binary-expression dispatch.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.BinaryExpressionHelper
eval, evaluateArrayAssignmentWithOperator, evaluateElvisEqual, evaluateEqual, evaluatePostfixMethod, evaluatePrefixMethod, evaluateTernary, getController, getIsCaseMethod
-
Field Details
-
binExpWriter
Per-type helpers used to emit primitive binary operations. -
typeMap
Maps primitive operand types to helper indexes. -
typeMapKeyNames
Human-readable names for the indexes used bytypeMap.
-
-
Constructor Details
-
BinaryExpressionMultiTypeDispatcher
Creates a dispatcher that routes primitive binary expressions to type-specific helpers.- Parameters:
wc- the active writer controller
-
-
Method Details
-
initializeDelegateHelpers
Creates the helper table used for primitive binary-expression dispatch.- Returns:
- the helper table indexed by
typeMap
-
getOperandType
Returns the helper index for the supplied operand type.- Parameters:
type- the operand type- Returns:
- the helper index, or
0when no primitive specialization applies
-
doPrimtiveCompare
@Deprecated protected boolean doPrimtiveCompare(ClassNode leftType, ClassNode rightType, BinaryExpression binExp) Deprecated. -
doPrimitiveCompare
protected boolean doPrimitiveCompare(ClassNode leftType, ClassNode rightType, BinaryExpression binExp) Attempts primitive comparison bytecode generation for the supplied operands.- Parameters:
leftType- the left operand typerightType- the right operand typebinExp- the comparison expression- Returns:
trueif a primitive-specialized implementation handled the comparison
-
evaluateCompareExpression
Evaluates a comparison expression, using primitive helpers when possible.- Overrides:
evaluateCompareExpressionin classBinaryExpressionHelper- Parameters:
compareMethod- the dynamic comparison helperbinExp- the comparison expression
-
evaluateBinaryExpression
Evaluates a dynamic binary operator by invoking the named helper method.- Overrides:
evaluateBinaryExpressionin classBinaryExpressionHelper- Parameters:
message- the operator method namebinExp- the expression to compile
-
evaluateBinaryExpressionWithAssignment
Evaluates an operator-assignment expression such as+=.- Overrides:
evaluateBinaryExpressionWithAssignmentin classBinaryExpressionHelper- Parameters:
method- the operator method namebinExp- the assignment expression
-
evaluateCompoundAssign
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 classBinaryExpressionHelper
-
assignToArray
protected void assignToArray(Expression orig, Expression receiver, Expression index, Expression rhsValueLoader, boolean safe) Emits an array-style assignment using the dynamicputAtprotocol.- Overrides:
assignToArrayin classBinaryExpressionHelper- Parameters:
orig- the original assignment expressionreceiver- the array or indexable receiverindex- the subscript expressionrhsValueLoader- an expression that reloads the right-hand valuesafe- whether the receiver access is null-safe
-
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 classBinaryExpressionHelper- Parameters:
op- the token typemethod- the helper method nameexpression- the receiver expressionorig- the original prefix/postfix expression
-
doPrimitiveCompare(ClassNode, ClassNode, BinaryExpression)instead