edu.rice.cs.cunit.classFile.code.instructions
Class LookupSwitchInstruction

java.lang.Object
  extended by edu.rice.cs.cunit.classFile.code.instructions.AInstruction
      extended by edu.rice.cs.cunit.classFile.code.instructions.LookupSwitchInstruction

public class LookupSwitchInstruction
extends AInstruction

LOOKUPSWITCH Java instruction.

Author:
Mathias Ricken

Field Summary
protected  int _defaultTarget
          Default target.
protected  int[] _keys
          Branch keys.
protected  int[] _targets
          Branch targets.
 
Constructor Summary
LookupSwitchInstruction(byte[] bytecode, int pc, int paddingPC, LineNumberTable lnt)
          Make a new LOOKUPSWITCH instruction from the bytecode stating at pc, padded using paddingPC, and use the line number table for branches.
LookupSwitchInstruction(int defaultTarget, int[] keys, int[] targets)
          Constructor.
 
Method Summary
 boolean equals(java.lang.Object o)
          Return true of this instruction and the other object are equal.
 int[] getBranchTargets()
          Return an array of target indices.
 byte[] getBytecode(int pc, LineNumberTable lnt)
          Get the bytecode for this instruction, padded for the specified program counter value, with branch targets according to the specified line number table
 int getBytecodeLength(int pc)
          Get the length bytecode for this instruction, padded for the specified program counter value.
 byte getOpcode()
          Get the opcode of this instruction.
 int hashCode()
          Return hash code.
 void setBranchTargets(int[] branchTargets)
          Set the branch target indices.
 java.lang.String toString()
          Return instruction in human-readable form.
 
Methods inherited from class edu.rice.cs.cunit.classFile.code.instructions.AInstruction
getCorrespondingLoad, getCorrespondingStore, makeInstruction, toStringVerbose
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

_defaultTarget

protected int _defaultTarget
Default target.


_targets

protected int[] _targets
Branch targets.


_keys

protected int[] _keys
Branch keys.

Constructor Detail

LookupSwitchInstruction

public LookupSwitchInstruction(int defaultTarget,
                               int[] keys,
                               int[] targets)
Constructor.

Parameters:
defaultTarget - default target line number
keys - keys
targets - target line numbers

LookupSwitchInstruction

public LookupSwitchInstruction(byte[] bytecode,
                               int pc,
                               int paddingPC,
                               LineNumberTable lnt)
Make a new LOOKUPSWITCH instruction from the bytecode stating at pc, padded using paddingPC, and use the line number table for branches.

Parameters:
bytecode - bytecode
pc - starting index in bytecode
paddingPC - PC for padding
lnt - line number table for branches
Method Detail

getOpcode

public byte getOpcode()
Get the opcode of this instruction.

Specified by:
getOpcode in class AInstruction
Returns:
opcode

getBytecodeLength

public int getBytecodeLength(int pc)
Get the length bytecode for this instruction, padded for the specified program counter value.

Specified by:
getBytecodeLength in class AInstruction
Parameters:
pc - PC for padding
Returns:
bytecode length

getBytecode

public byte[] getBytecode(int pc,
                          LineNumberTable lnt)
Get the bytecode for this instruction, padded for the specified program counter value, with branch targets according to the specified line number table

Specified by:
getBytecode in class AInstruction
Parameters:
pc - PC for padding
lnt - line number table for branches
Returns:
bytecode

equals

public boolean equals(java.lang.Object o)
Return true of this instruction and the other object are equal.

Specified by:
equals in class AInstruction
Parameters:
o - other object
Returns:
true if equal

hashCode

public int hashCode()
Return hash code.

Specified by:
hashCode in class AInstruction
Returns:
hash code

getBranchTargets

public int[] getBranchTargets()
Return an array of target indices.

Specified by:
getBranchTargets in class AInstruction
Returns:
array of target indices.

setBranchTargets

public void setBranchTargets(int[] branchTargets)
Set the branch target indices.

Specified by:
setBranchTargets in class AInstruction
Parameters:
branchTargets - array of target indices

toString

public java.lang.String toString()
Return instruction in human-readable form.

Overrides:
toString in class java.lang.Object
Returns:
string representation