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

java.lang.Object
  extended by edu.rice.cs.cunit.classFile.code.instructions.AInstruction
Direct Known Subclasses:
BranchInstruction, GenericInstruction, LookupSwitchInstruction, TableSwitchInstruction, WideBranchInstruction

public abstract class AInstruction
extends java.lang.Object

Abstract Java instruction.

Author:
Mathias Ricken

Constructor Summary
AInstruction()
           
 
Method Summary
abstract  boolean equals(java.lang.Object o)
          Return true of this instruction and the other object are equal.
abstract  int[] getBranchTargets()
          Return an array of target indices.
abstract  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
abstract  int getBytecodeLength(int pc)
          Get the length bytecode for this instruction, padded for the specified program counter value.
static AInstruction getCorrespondingLoad(AInstruction storeInstruction)
          Returns a load instruction that corresponds to the given store instruction.
static AInstruction getCorrespondingStore(AInstruction loadInstruction)
          Returns a store instruction that corresponds to the given load instruction.
abstract  byte getOpcode()
          Get the opcode of this instruction.
abstract  int hashCode()
          Return hash code.
static AInstruction makeInstruction(byte[] bytecode, int pc, int paddingPC, LineNumberTable lnt)
          Make an instruction from the bytecode starting at pc, using the specified padding PC and the line number table.
abstract  void setBranchTargets(int[] branchTargets)
          Set the branch target indices.
 java.lang.String toStringVerbose(ConstantPool cp)
          Return a verbose string representation.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AInstruction

public AInstruction()
Method Detail

getBytecode

public abstract 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

Parameters:
pc - PC for padding
lnt - line number table for branches
Returns:
bytecode

getOpcode

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

Returns:
opcode

getBytecodeLength

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

Parameters:
pc - PC for padding
Returns:
bytecode length

getBranchTargets

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

Returns:
array of target indices.

setBranchTargets

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

Parameters:
branchTargets - array of target indices

makeInstruction

public static AInstruction makeInstruction(byte[] bytecode,
                                           int pc,
                                           int paddingPC,
                                           LineNumberTable lnt)
Make an instruction from the bytecode starting at pc, using the specified padding PC and the line number table.

Parameters:
bytecode - bytecode
pc - start PC in bytecode
paddingPC - PC used for padding
lnt - line number table for branches
Returns:
instruction

equals

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

Overrides:
equals in class java.lang.Object
Parameters:
o - other object
Returns:
true if equal

hashCode

public abstract int hashCode()
Return hash code.

Overrides:
hashCode in class java.lang.Object
Returns:
hash code

toStringVerbose

public java.lang.String toStringVerbose(ConstantPool cp)
Return a verbose string representation.

Parameters:
cp - constant pool
Returns:
verbose string representation

getCorrespondingStore

public static AInstruction getCorrespondingStore(AInstruction loadInstruction)
Returns a store instruction that corresponds to the given load instruction.

Parameters:
loadInstruction - load instruction
Returns:
corresponding store instruction

getCorrespondingLoad

public static AInstruction getCorrespondingLoad(AInstruction storeInstruction)
Returns a load instruction that corresponds to the given store instruction.

Parameters:
storeInstruction - store instruction
Returns:
corresponding load instruction