tableswitch = 170 |
...0-3 byte pad... |
default-offset1 |
default-offset2 |
default-offset3 |
default-offset4 |
low1 |
low2 |
low3 |
low4 |
high1 |
high2 |
high3 |
high4 |
...jump offsets... |
Stack: ..., index => ...
tableswitch
is a variable length instruction. Immediately after the tableswitch
instruction, between zero and three 0's are inserted as padding so that the next byte begins at an address that is a multiple of four. After the padding follow a series of signed 4-byte quantities: default-offset, low, high, and then high-low+1 further signed 4-byte offsets. The high-low+1 signed 4-byte offsets are treated as a 0-based jump table.The index must be an integer. If index is less than low or index is greater than high, then default-offset is added to the address of this instruction. Otherwise, low is subtracted from index, and the index-low'th element of the jump table is extracted, and added to the address of this instruction.
lookupswitch = 171 |
...0-3 byte pad... |
default-offset1 |
default-offset2 |
default-offset3 |
default-offset4 |
npairs1 |
npairs2 |
npairs3 |
npairs4 |
..match-offset pairs.. |
Stack: ..., key => ...
lookupswitch
is a variable length instruction. Immediately after the lookupswitch
instruction, between zero and three 0's are inserted as padding so that the next byte begins at an address that is a multiple of four. Immediately after the padding are a series of pairs of signed 4-byte quantities. The first pair is special. The first item of that pair is the default offset, and the second item of that pair gives the number of pairs that follow. Each subsequent pair consists of a match and an offset.
The key must be an integer. The integer key on the stack is compared against each of the matches. If it is equal to one of them, the offset is added to the address of this instruction. If the key does not match any of the matches, the default offset is added to the address of this instruction.