Class InstructionSelect

All Implemented Interfaces:
Serializable, Cloneable, Constants, InstructionTargeter
Direct Known Subclasses:
LOOKUPSWITCH, TABLESWITCH

public abstract class InstructionSelect extends InstructionBranch
Select - Abstract super class for LOOKUPSWITCH and TABLESWITCH instructions.
Version:
$Id: InstructionSelect.java,v 1.4 2009/10/05 17:35:36 aclement Exp $
Author:
M. Dahm
See Also:
LOOKUPSWITCH, TABLESWITCH, InstructionList, Serialized Form
  • Field Details

    • match

      protected int[] match
    • indices

      protected int[] indices
    • targets

      protected InstructionHandle[] targets
    • fixedLength

      protected int fixedLength
    • matchLength

      protected int matchLength
    • padding

      protected int padding
    • length

      protected short length
  • Constructor Details

  • Method Details

    • getTargetOffset

      protected int getTargetOffset(InstructionHandle target)
    • updatePosition

      protected int updatePosition(int offset, int max_offset)
      Since this is a variable length instruction, it may shift the following instructions which then need to update their position. Called by InstructionList.setPositions when setting the position for every instruction. In the presence of variable length instructions `setPositions' performs multiple passes over the instruction list to calculate the correct (byte) positions and offsets by calling this function.
      Overrides:
      updatePosition in class InstructionBranch
      Parameters:
      offset - additional offset caused by preceding (variable length) instructions
      max_offset - the maximum offset that may be caused by these instructions
      Returns:
      additional offset caused by possible change of this instruction's length
    • dump

      public void dump(DataOutputStream out) throws IOException
      Dump instruction as byte code to stream out.
      Overrides:
      dump in class InstructionBranch
      Parameters:
      out - Output stream
      Throws:
      IOException
    • toString

      public String toString(boolean verbose)
      Description copied from class: InstructionBranch
      Long output format:
      Overrides:
      toString in class InstructionBranch
      Parameters:
      verbose - long/short format switch
      Returns:
      mnemonic for instruction
    • setTarget

      public void setTarget(int i, InstructionHandle target)
      Set branch target for `i'th case
    • updateTarget

      public void updateTarget(InstructionHandle old_ih, InstructionHandle new_ih)
      Description copied from class: InstructionBranch
      Update the target destination for this instruction. If an oldHandle is provided it is checked to verify that is where the target currently points to before changing it.
      Specified by:
      updateTarget in interface InstructionTargeter
      Overrides:
      updateTarget in class InstructionBranch
      Parameters:
      old_ih - old target
      new_ih - new target
    • containsTarget

      public boolean containsTarget(InstructionHandle ih)
      Specified by:
      containsTarget in interface InstructionTargeter
      Overrides:
      containsTarget in class InstructionBranch
      Returns:
      true, if ih is target of this instruction
    • getMatchs

      public int[] getMatchs()
      Returns:
      array of match indices
    • getIndices

      public int[] getIndices()
      Returns:
      array of match target offsets
    • equals

      public boolean equals(Object other)
      Description copied from class: InstructionBranch
      Only equal if they are the same branch instruction - otherwise too risky as the targets may only temporarily be pointing at the same destination.
      Overrides:
      equals in class InstructionBranch
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class InstructionBranch
    • getTargets

      public InstructionHandle[] getTargets()
      Returns:
      array of match targets
    • getLength

      public int getLength()
      Overrides:
      getLength in class Instruction