Class MLookupSwitchInsn
- java.lang.Object
-
- xyz.cofe.trambda.bc.mth.MAbstractBC
-
- xyz.cofe.trambda.bc.mth.MLookupSwitchInsn
-
- All Implemented Interfaces:
Serializable,xyz.cofe.collection.ImTree<ByteCode>,xyz.cofe.collection.ImTreeWalk<ByteCode>,ByteCode,MethodByteCode,MethodWriter
public class MLookupSwitchInsn extends MAbstractBC implements MethodWriter
lookupswitchOperation
Access jump table by key match and jumpFormat
lookupswitch <0-3 byte pad> defaultbyte1 defaultbyte2 defaultbyte3 defaultbyte4 npairs1 npairs2 npairs3 npairs4 match-offset pairs...
Forms
lookupswitch = 171 (0xab)Operand Stack
..., key → ...Description
A lookupswitch is a variable-length instruction. Immediately after the lookupswitch opcode, between zero and three bytes must act as padding, such that defaultbyte1 begins at an address that is a multiple of four bytes from the start of the current method (the opcode of its first instruction). Immediately after the padding follow a series of signed 32-bit values: default, npairs, and then npairs pairs of signed 32-bit values. The npairs must be greater than or equal to 0. Each of the npairs pairs consists of an int match and a signed 32-bit offset. Each of these signed 32-bit values is constructed from four unsigned bytes as (byte1 << 24) | (byte2 << 16) | (byte3 << 8) | byte4.The table match-offset pairs of the lookupswitch instruction must be sorted in increasing numerical order by match.
The key must be of type int and is popped from the operand stack. The key is compared against the match values. If it is equal to one of them, then a target address is calculated by adding the corresponding offset to the address of the opcode of this lookupswitch instruction. If the key does not match any of the match values, the target address is calculated by adding default to the address of the opcode of this lookupswitch instruction. Execution then continues at the target address.
The target address that can be calculated from the offset of each match-offset pair, as well as the one calculated from default, must be the address of an opcode of an instruction within the method that contains this lookupswitch instruction.
Notes
The alignment required of the 4-byte operands of the lookupswitch instruction guarantees 4-byte alignment of those operands if and only if the method that contains the lookupswitch is positioned on a 4-byte boundary.The match-offset pairs are sorted to support lookup routines that are quicker than linear search.
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description MLookupSwitchInsn()MLookupSwitchInsn(String defHdl, int[] keys, String[] labels)MLookupSwitchInsn(MLookupSwitchInsn sample)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description MLookupSwitchInsnclone()StringgetDefaultHandlerLabel()int[]getKeys()String[]getLabels()voidsetDefaultHandlerLabel(String defaultHandlerLabel)voidsetKeys(int[] keys)voidsetLabels(String[] labels)StringtoString()voidwrite(org.objectweb.asm.MethodVisitor v, MethodWriterCtx ctx)
-
-
-
Constructor Detail
-
MLookupSwitchInsn
public MLookupSwitchInsn()
-
MLookupSwitchInsn
public MLookupSwitchInsn(MLookupSwitchInsn sample)
-
-
Method Detail
-
clone
public MLookupSwitchInsn clone()
- Specified by:
clonein interfaceMethodByteCode- Specified by:
clonein classMAbstractBC
-
getDefaultHandlerLabel
public String getDefaultHandlerLabel()
-
setDefaultHandlerLabel
public void setDefaultHandlerLabel(String defaultHandlerLabel)
-
getKeys
public int[] getKeys()
-
setKeys
public void setKeys(int[] keys)
-
getLabels
public String[] getLabels()
-
setLabels
public void setLabels(String[] labels)
-
write
public void write(org.objectweb.asm.MethodVisitor v, MethodWriterCtx ctx)- Specified by:
writein interfaceMethodWriter
-
-