|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--at.dms.classfile.AbstractInstructionAccessor | +--at.dms.classfile.Instruction | +--at.dms.classfile.SwitchInstruction
Complex switch instruction. This class decides whether to use the lookupswitch or tableswitch opcode.
Some instructions are perniticky enough that its simpler to write them separately instead of smushing them with all the rest. The Switch Intstruction is one of them.
Constructor Summary | |
SwitchInstruction(InstructionAccessor defaultTarget,
int[] matches,
InstructionAccessor[] targets)
Constructs a switch instruction. |
|
SwitchInstruction(InstructionAccessor defaultTarget,
java.util.List matches,
java.util.List targets)
Constructs a switch instruction. |
Method Summary | |
boolean |
canComplete()
Returns true iff control flow can reach the next instruction in textual order. |
(package private) void |
check(CodeEnv env,
int curStack)
Verifies the enclosed instruction and computes the stack height. |
(package private) void |
computeEndAddress(CodePosition position)
Computes the address of the end of the instruction. |
int |
getMatch(int position)
Returns the case label's value at the specified position in the list of cases. |
int |
getPushedOnStack()
Returns the size of data pushed on the stack by this instruction. |
byte |
getReturnType()
Returns the type pushed on the stack. |
(package private) int |
getSize()
Returns the number of bytes used by the the instruction in the code array. |
int |
getStack()
Return the amount of stack (positive or negative) used by this instruction. |
int |
getSwitchCount()
Gets the number of 'case' labels. |
InstructionAccessor |
getTarget(int position)
Returns the target of the specified position in the list of cases. |
(package private) void |
resolveConstants(ConstantPool cp)
Insert or check location of constant value on constant pool. |
void |
selectSwitchType()
Select the appropriate switch type. |
void |
setTarget(InstructionAccessor target,
int position)
Sets the target for this instruction. |
void |
setTarget(int position,
InstructionAccessor accessor)
Sets the target of the specified position in the list of cases. |
void |
transformAccessors(AccessorTransformer transformer)
Transforms targets. |
(package private) void |
write(ConstantPool cp,
java.io.DataOutput out)
Write this instruction into a file. |
Methods inherited from class at.dms.classfile.Instruction |
dump, getAddress, getLocalVar, getOpcode, getPoppedFromStack, isLiteral, setAddress, setOpcode |
Methods inherited from class at.dms.classfile.AbstractInstructionAccessor |
transform |
Methods inherited from class java.lang.Object |
|
Constructor Detail |
public SwitchInstruction(InstructionAccessor defaultTarget, int[] matches, InstructionAccessor[] targets)
defaultTarget
- Default target for switch.matches
- Array of match values to compare the key to.targets
- Array of target instructions for each match value.public SwitchInstruction(InstructionAccessor defaultTarget, java.util.List matches, java.util.List targets)
defaultTarget
- Default target for switch.matches
- List of match values to compare the key to.targets
- List of target instructions for each match value.Method Detail |
public boolean canComplete()
canComplete
in class Instruction
public void transformAccessors(AccessorTransformer transformer) throws BadAccessorException
transformAccessors
in interface AccessorContainer
at.dms.classfile.AccessorContainer
transformer
- The transformer used to transform accessors.public void setTarget(InstructionAccessor target, int position)
public int getSwitchCount()
public int getMatch(int position)
public InstructionAccessor getTarget(int position)
public void setTarget(int position, InstructionAccessor accessor)
public void selectSwitchType()
int getSize()
getSize
in class Instruction
public byte getReturnType()
getReturnType
in class Instruction
void check(CodeEnv env, int curStack) throws ClassFileFormatException
check
in class Instruction
env
- The check environment.curStack
- The stack height at the end of the execution of the instruction.ClassFileFormatException
- A problem was detected.void computeEndAddress(CodePosition position)
computeEndAddress
in class Instruction
position
- The minimum and maximum address of the begin of this instruction.
This parameter is changed to the minimum and maximum address of the
end of this instruction.public int getPushedOnStack()
getPushedOnStack
in class Instruction
public int getStack()
getStack
in class Instruction
void resolveConstants(ConstantPool cp)
resolveConstants
in class Instruction
cp
- The constant pool for this class.void write(ConstantPool cp, java.io.DataOutput out) throws java.io.IOException
write
in class Instruction
cp
- The constant pool that contain all data.out
- The file where to write this object info.java.io.IOException
- An io problem has occured.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |