Class MTableSwitchInsn
- java.lang.Object
-
- xyz.cofe.trambda.bc.mth.MAbstractBC
-
- xyz.cofe.trambda.bc.mth.MTableSwitchInsn
-
- All Implemented Interfaces:
Serializable,xyz.cofe.collection.ImTree<ByteCode>,xyz.cofe.collection.ImTreeWalk<ByteCode>,ByteCode,MethodByteCode,MethodWriter
public class MTableSwitchInsn extends MAbstractBC implements ByteCode, MethodWriter
tableswitchOperation
Access jump table by index and jumpFormat
tableswitch <0-3 byte pad> defaultbyte1 defaultbyte2 defaultbyte3 defaultbyte4 lowbyte1 lowbyte2 lowbyte3 lowbyte4 highbyte1 highbyte2 highbyte3 highbyte4 jump offsets...
Forms
tableswitch = 170 (0xaa)Operand Stack
..., index → ...
Description
A tableswitch is a variable-length instruction. Immediately after the tableswitch 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 are bytes constituting three signed 32-bit values: default, low, and high. Immediately following are bytes constituting a series of high - low + 1 signed 32-bit offsets. The value low must be less than or equal to high. The high - low + 1 signed 32-bit offsets are treated as a 0-based jump table. Each of these signed 32-bit values is constructed as (byte1 << 24) | (byte2 << 16) | (byte3 << 8) | byte4.The index must be of type int and is popped from the operand stack. If index is less than low or index is greater than high, then a target address is calculated by adding default to the address of the opcode of this tableswitch instruction. Otherwise, the offset at position index - low of the jump table is extracted. The target address is calculated by adding that offset to the address of the opcode of this tableswitch instruction. Execution then continues at the target address.
The target address that can be calculated from each jump table offset, as well as the one that can be calculated from default, must be the address of an opcode of an instruction within the method that contains this tableswitch instruction.
Notes
The alignment required of the 4-byte operands of the tableswitch instruction guarantees 4-byte alignment of those operands if and only if the method that contains the tableswitch starts on a 4-byte boundary.
Tablewitch - это инструкция переменной длины. Сразу после кода операции tablewitch от нуля до трех байтов должны действовать как заполнители, так что defaultbyte1 начинается с адреса, кратного четырем байтам от начала текущего метода (кода операции его первой инструкции). Сразу после заполнения идут байты, составляющие три 32-битных значения со знаком: по умолчанию, младший и высокий. Сразу после этого следуют байты, составляющие серию 32-битных смещений со знаком старшего и младшего + 1 со знаком. Значение low должно быть меньше или равно high. 32-битные смещения со знаком + 1 (high-low + 1) обрабатываются как таблица переходов с отсчетом от 0. Каждое из этих 32-битных значений со знаком строится как (byte1 << 24) | (byte2 << 16) | (byte3 << 8) | байт4.Индекс должен иметь тип int и извлекается из стека операндов. Если index меньше low или index больше high, то целевой адрес вычисляется путем добавления значения по умолчанию к адресу кода операции этой инструкции tablewitch. В противном случае извлекается смещение в позиции index - low таблицы переходов. Целевой адрес вычисляется путем добавления этого смещения к адресу кода операции этой инструкции tablewitch. Затем выполнение продолжается по целевому адресу.
Целевой адрес, который может быть вычислен из каждого смещения таблицы переходов, а также адрес, который может быть вычислен по умолчанию, должен быть адресом кода операции инструкции внутри метода, который содержит эту инструкцию tablewitch.
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description MTableSwitchInsn()Конструктор по умолчаниюMTableSwitchInsn(int min, int max, String dflt, String... labels)КонструкторMTableSwitchInsn(MTableSwitchInsn sample)Конструктор копирования
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description MTableSwitchInsnclone()StringgetDefaultLabel()beginning of the default handler block.String[]getLabels()beginnings of the handler blocks.intgetMax()the maximum key value.intgetMin()the minimum key valuevoidsetDefaultLabel(String defaultLabel)beginning of the default handler block.voidsetLabels(String[] labels)beginnings of the handler blocks.voidsetMax(int max)the maximum key value.voidsetMin(int min)the minimum key valueStringtoString()voidwrite(org.objectweb.asm.MethodVisitor v, MethodWriterCtx ctx)
-
-
-
Constructor Detail
-
MTableSwitchInsn
public MTableSwitchInsn()
Конструктор по умолчанию
-
MTableSwitchInsn
public MTableSwitchInsn(int min, int max, String dflt, String... labels)Конструктор- Parameters:
min- the minimum key value.max- the maximum key value.dflt- beginning of the default handler block.labels- beginnings of the handler blocks.labels[i]is the beginning of the handler block for themin + ikey.
-
MTableSwitchInsn
public MTableSwitchInsn(MTableSwitchInsn sample)
Конструктор копирования- Parameters:
sample- образец
-
-
Method Detail
-
clone
public MTableSwitchInsn clone()
- Specified by:
clonein interfaceMethodByteCode- Specified by:
clonein classMAbstractBC
-
getMin
public int getMin()
the minimum key value- Returns:
- the minimum key value
-
setMin
public void setMin(int min)
the minimum key value- Parameters:
min- the minimum key value
-
getMax
public int getMax()
the maximum key value.- Returns:
- the maximum key value.
-
setMax
public void setMax(int max)
the maximum key value.- Parameters:
max- the maximum key value.
-
getDefaultLabel
public String getDefaultLabel()
beginning of the default handler block.- Returns:
- beginning of the default handler block.
-
setDefaultLabel
public void setDefaultLabel(String defaultLabel)
beginning of the default handler block.- Parameters:
defaultLabel- beginning of the default handler block.
-
getLabels
public String[] getLabels()
beginnings of the handler blocks.labels[i]is the beginning of the handler block for themin + ikey.- Returns:
- handler blocks
-
setLabels
public void setLabels(String[] labels)
beginnings of the handler blocks.labels[i]is the beginning of the handler block for themin + ikey.- Parameters:
labels- handler blocks
-
write
public void write(org.objectweb.asm.MethodVisitor v, MethodWriterCtx ctx)- Specified by:
writein interfaceMethodWriter
-
-