Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.chaoswg.xtc4y.classdesc.code.instructions
Class TableSwitchInstruction  view TableSwitchInstruction download TableSwitchInstruction.java

java.lang.Object
  extended bycom.chaoswg.xtc4y.classdesc.code.instructions.Instruction
      extended bycom.chaoswg.xtc4y.classdesc.code.instructions.TableSwitchInstruction

public class TableSwitchInstruction
extends Instruction

A Lookup switch instruction is used to represent switch statements. It consists of the command, an int giving the start number, an int defining the last number of table entires, an int defining the default jump address and a set of entries where each entry consists of one int, a jump address. The end of a TableSwitch Instruction is aligned to 4 byte and therefore gaps are filled up with nop's. That means: (1byte+4bytes+4bytes+4bytes+(4bytes)*+((index+length)%4)) TBD: add methods to instanciate a tableswitch without a stream


Field Summary
private  Instruction defaultInstr
           
private  int defaultJumpAdress
           
private  java.io.DataInputStream dis
           
private  int endIndex
           
private  int gap
           
private  Instruction[] jumpInstr
           
private  int[] jumps
           
private  int startIndex
           
static byte TABLESWITCH
          Opcode of int binary instructions
 
Fields inherited from class com.chaoswg.xtc4y.classdesc.code.instructions.Instruction
 
Constructor Summary
protected TableSwitchInstruction(java.io.DataInputStream dis, com.chaoswg.xtc4y.classdesc.ConstantPool cp)
          Creates an LookupSwitchInstruction and initializes it from a DataInputStream
 
Method Summary
 int getNumberOfUsedBytes()
           
 void resolveIndices(com.chaoswg.xtc4y.classdesc.code.Code code)
          Resolve indices of instructions.
 void setIndex(short index)
          Set the index of this instruction, is set by the code container
 void write(java.io.DataOutputStream dos, com.chaoswg.xtc4y.classdesc.ConstantPool cp)
          Write the instruction onto the DataOutputStream, using the constant pool to register variables.
 
Methods inherited from class com.chaoswg.xtc4y.classdesc.code.instructions.Instruction
getCommand, getIndex, getOpcode, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

startIndex

private int startIndex

endIndex

private int endIndex

defaultJumpAdress

private int defaultJumpAdress

jumps

private int[] jumps

gap

private int gap

defaultInstr

private Instruction defaultInstr

jumpInstr

private Instruction[] jumpInstr

dis

private java.io.DataInputStream dis

TABLESWITCH

public static final byte TABLESWITCH
Opcode of int binary instructions

See Also:
Constant Field Values
Constructor Detail

TableSwitchInstruction

protected TableSwitchInstruction(java.io.DataInputStream dis,
                                 com.chaoswg.xtc4y.classdesc.ConstantPool cp)
                          throws java.io.IOException
Creates an LookupSwitchInstruction and initializes it from a DataInputStream

Method Detail

setIndex

public void setIndex(short index)
Set the index of this instruction, is set by the code container

Overrides:
setIndex in class Instruction

resolveIndices

public void resolveIndices(com.chaoswg.xtc4y.classdesc.code.Code code)
Resolve indices of instructions. By default do nothing

Overrides:
resolveIndices in class Instruction

write

public final void write(java.io.DataOutputStream dos,
                        com.chaoswg.xtc4y.classdesc.ConstantPool cp)
                 throws java.io.IOException
Write the instruction onto the DataOutputStream, using the constant pool to register variables. .

Overrides:
write in class Instruction

getNumberOfUsedBytes

public int getNumberOfUsedBytes()
Specified by:
getNumberOfUsedBytes in class Instruction