edu.wisc.cs.java
Class LookupSwitch
java.lang.Object
|
+--edu.wisc.cs.java.Bytecode
|
+--edu.wisc.cs.java.Switch
|
+--edu.wisc.cs.java.LookupSwitch
- public class LookupSwitch
- extends Switch
This class represents the LookupSwitch instruction. This instruction is used
to implement switch statements with sparse case coverage. This instruction is
less efficient to execute than the TableSwitch, but it can be more space
efficient to represent the table. See the Java Virtual Machine specification
for more details.
Field Summary |
protected int[] |
match_values
An array of integer values to match the parameter to. |
protected int |
n_pairs
The number of pairs in the jump table. |
Constructor Summary |
LookupSwitch(java.io.DataInputStream in,
int pad,
int pc)
Constructs a LookupSwitch 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 lookupswitch 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 |
n_pairs
protected int n_pairs
- The number of pairs in the jump table.
match_values
protected int[] match_values
- An array of integer values to match the parameter to.
LookupSwitch
public LookupSwitch(java.io.DataInputStream in,
int pad,
int pc)
throws java.io.IOException
- Constructs a LookupSwitch 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
lookupswitch
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.