edu.wisc.cs.java
Class TableSwitch
java.lang.Object
|
+--edu.wisc.cs.java.Bytecode
|
+--edu.wisc.cs.java.Switch
|
+--edu.wisc.cs.java.TableSwitch
- public class TableSwitch
- extends Switch
This class represents the TableSwitch instruction. This instruction is used
to implement a switch statement that has relatively dense cases. See the
Java Virtual Machine specification for details.
Field Summary |
protected int |
high
The highest value for which there is a case in the jump table. |
protected int |
low
The smallest value for which there is a case in the jump table. |
Constructor Summary |
TableSwitch(java.io.DataInputStream in,
int pad,
int pc)
Constructs a TableSwitch instruction by reading the table
of the appropriate type from the given source. |
Method Summary |
int |
getParamBytes()
Returns the number of bytes required to represent the parameters for this
bytecode. |
void |
writeTo(java.io.DataOutputStream out,
java.util.HashMap labels,
int pc)
Writes a tableswitch instruction to a stream in the
specified format. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
low
protected int low
- The smallest value for which there is a case in the jump table.
high
protected int high
- The highest value for which there is a case in the jump table.
TableSwitch
public TableSwitch(java.io.DataInputStream in,
int pad,
int pc)
throws java.io.IOException
- Constructs a TableSwitch instruction by reading the table
of the appropriate type from the given source. Note that it is assumed
that any padding bytes have already been read or skipped over in the
stream.
- Parameters:
in
- the stream from which to read the jump table.- Throws:
- java.io.IOException - if there is a problem reading from the stream.
getParamBytes
public int getParamBytes()
- Returns the number of bytes required to represent the parameters for this
bytecode. Note that for this instruction, this does not include bytes
for the padding between the opcode and the start of the default offset.
- Overrides:
- getParamBytes in class Switch
- Returns:
- the number of bytes required to store this jump table.
writeTo
public void writeTo(java.io.DataOutputStream out,
java.util.HashMap labels,
int pc)
throws java.io.IOException
- Writes a
tableswitch
instruction to a stream in the
specified format. The pad is already expected to have been adjusted to the
proper value given the pc.
- Overrides:
- writeTo in class Switch
- Parameters:
out
- a stream to which to write the data for this instruction.labels
- a map comtaining the labels in the method and their pc's.pc
- the program counter for this instruction.- Throws:
- java.io.IOException - if there is a problem writing to the stream.