Package org.codehaus.groovy.classgen.asm
Class BinaryObjectExpressionHelper
java.lang.Object
org.codehaus.groovy.classgen.asm.BinaryExpressionWriter
org.codehaus.groovy.classgen.asm.BinaryObjectExpressionHelper
Binary expression helper used for object operations that fall back to dynamic dispatch.
-
Field Summary
Fields inherited from class org.codehaus.groovy.classgen.asm.BinaryExpressionWriter
stdCompareCodes -
Constructor Summary
ConstructorsConstructorDescriptionBinaryObjectExpressionHelper(WriterController controller) Creates an object-specialized binary expression helper. -
Method Summary
Modifier and TypeMethodDescriptionprotected voiddoubleTwoOperands(org.objectweb.asm.MethodVisitor mv) Duplicates the two operands already on the operand stack.protected ClassNodeprotected intgetBitwiseOperationBytecode(int type) Returns the bitwise opcode for the supplied token.protected intprotected ClassNodeprotected ClassNodeprotected intgetShiftOperationBytecode(int type) Returns the shift opcode for the supplied token.protected intgetStandardOperationBytecode(int type) Returns the arithmetic opcode for the supplied token.protected voidremoveTwoOperands(org.objectweb.asm.MethodVisitor mv) Removes the two operands already on the operand stack.booleanwrite(int operation, boolean simulate) Attempts to write the supplied binary operation.protected booleanwriteDivision(boolean simulate) Writes a division operation for the current primitive type.protected voidwriteMinusMinus(org.objectweb.asm.MethodVisitor mv) Emits a prefix/postfix decrement.protected voidwritePlusPlus(org.objectweb.asm.MethodVisitor mv) Emits a prefix/postfix increment.booleanwritePostOrPrefixMethod(int operation, boolean simulate) Attempts to write a postfix or prefix increment/decrement operation.Methods inherited from class org.codehaus.groovy.classgen.asm.BinaryExpressionWriter
arrayGet, arraySet, getArrayGetCaller, getArraySetCaller, getController, setArraySetAndGet, supportsDivision, writeBitwiseOp, writeShiftOp, writeSpaceship, writeStdCompare, writeStdOperators
-
Constructor Details
-
BinaryObjectExpressionHelper
Creates an object-specialized binary expression helper.- Parameters:
controller- the active writer controller
-
-
Method Details
-
writePostOrPrefixMethod
public boolean writePostOrPrefixMethod(int operation, boolean simulate) Attempts to write a postfix or prefix increment/decrement operation.- Overrides:
writePostOrPrefixMethodin classBinaryExpressionWriter- Parameters:
operation- the token typesimulate- whether to probe support without emitting bytecode- Returns:
trueif the operation is supported
-
write
public boolean write(int operation, boolean simulate) Attempts to write the supplied binary operation.- Overrides:
writein classBinaryExpressionWriter- Parameters:
operation- the token typesimulate- whether to probe support without emitting bytecode- Returns:
trueif the operation is supported
-
writeDivision
protected boolean writeDivision(boolean simulate) Writes a division operation for the current primitive type.- Overrides:
writeDivisionin classBinaryExpressionWriter- Parameters:
simulate- whether to probe support without emitting bytecode- Returns:
trueif division is supported
-
getBitwiseOperationBytecode
protected int getBitwiseOperationBytecode(int type) Returns the bitwise opcode for the supplied token.- Specified by:
getBitwiseOperationBytecodein classBinaryExpressionWriter- Parameters:
type- the normalized token index- Returns:
- the ASM opcode
-
getCompareCode
protected int getCompareCode()- Specified by:
getCompareCodein classBinaryExpressionWriter- Returns:
- the ASM compare opcode used by this primitive type
-
getNormalOpResultType
- Specified by:
getNormalOpResultTypein classBinaryExpressionWriter- Returns:
- the result type for normal arithmetic operations
-
getDevisionOpResultType
- Specified by:
getDevisionOpResultTypein classBinaryExpressionWriter- Returns:
- the result type for division operations
-
getShiftOperationBytecode
protected int getShiftOperationBytecode(int type) Returns the shift opcode for the supplied token.- Specified by:
getShiftOperationBytecodein classBinaryExpressionWriter- Parameters:
type- the normalized token index- Returns:
- the ASM opcode
-
getStandardOperationBytecode
protected int getStandardOperationBytecode(int type) Returns the arithmetic opcode for the supplied token.- Specified by:
getStandardOperationBytecodein classBinaryExpressionWriter- Parameters:
type- the normalized token index- Returns:
- the ASM opcode
-
removeTwoOperands
protected void removeTwoOperands(org.objectweb.asm.MethodVisitor mv) Removes the two operands already on the operand stack.- Specified by:
removeTwoOperandsin classBinaryExpressionWriter- Parameters:
mv- the current method visitor
-
writePlusPlus
protected void writePlusPlus(org.objectweb.asm.MethodVisitor mv) Emits a prefix/postfix increment.- Specified by:
writePlusPlusin classBinaryExpressionWriter- Parameters:
mv- the current method visitor
-
writeMinusMinus
protected void writeMinusMinus(org.objectweb.asm.MethodVisitor mv) Emits a prefix/postfix decrement.- Specified by:
writeMinusMinusin classBinaryExpressionWriter- Parameters:
mv- the current method visitor
-
doubleTwoOperands
protected void doubleTwoOperands(org.objectweb.asm.MethodVisitor mv) Duplicates the two operands already on the operand stack.- Specified by:
doubleTwoOperandsin classBinaryExpressionWriter- Parameters:
mv- the current method visitor
-
getArrayGetResultType
- Overrides:
getArrayGetResultTypein classBinaryExpressionWriter- Returns:
- the result type produced by
BinaryExpressionWriter.getArrayGetCaller()
-