Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.bcel.generic
Class Instruction

    java.lang.Object
      |
      +--org.apache.bcel.generic.Instruction

All Implemented Interfaces:
  java.lang.Cloneable, java.io.Serializable

Direct Known Subclasses:
  ACONST_NULL, ArithmeticInstruction, ArrayInstruction, ARRAYLENGTH, ATHROW, BIPUSH, BranchInstruction, BREAKPOINT, ConversionInstruction, CPInstruction, DCMPG, DCMPL, DCONST, FCMPG, FCMPL, FCONST, ICONST, IMPDEP1, IMPDEP2, LCMP, LCONST, LocalVariableInstruction, MONITORENTER, MONITOREXIT, NEWARRAY, NOP, RET, ReturnInstruction, SIPUSH, StackInstruction

public abstract class Instruction
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable

Abstract super class for all Java byte codes.

Version:
  $Id: Instruction.java,v 1.3 2002/08/07 18:01:32 mdahm Exp $
Author:
  M. Dahm
See Also:
  Serialized Form

Field Summary
`protected short` | `length`
`protected short` | `opcode`

Constructor Summary
`Instruction(short opcode, short length)`

Method Summary
`abstract void` | `accept(Visitor v)` Call corresponding visitor method(s).
`int` | `consumeStack(ConstantPoolGen cpg)` This method also gives right results for instructions whose effect on the stack depends on the constant pool entry they reference.
`Instruction` | `copy()` Use with caution, since `BranchInstruction's have a `target' reference which is not copied correctly (only basic types are).
`void` | `dump(java.io.DataOutputStream out)` Dump instruction as byte code to stream out.
`boolean` | `equals(java.lang.Object that)` Check for equality, delegated to comparator
`static InstructionComparator` | `getComparator()` Get Comparator object used in the equals() method to determine equality of instructions.
`int` | `getLength()`
`java.lang.String` | `getName()`
`short` | `getOpcode()`
`protected void` | `initFromFile(ByteSequence bytes, boolean wide)` Read needed data (e.g. index) from file.
`int` | `produceStack(ConstantPoolGen cpg)` This method also gives right results for instructions whose effect on the stack depends on the constant pool entry they reference.
`static Instruction` | `readInstruction(ByteSequence bytes)` Read an instruction from (byte code) input stream and return the appropiate object.
`static void` | `setComparator(InstructionComparator c)` Set comparator to be used for equals().
`java.lang.String` | `toString()`
`java.lang.String` | `toString(boolean verbose)` Long output format: <name of opcode> "["<opcode number>"]" "("<length of instruction>")"
`java.lang.String` | `toString(ConstantPool cp)`

Methods inherited from class java.lang.Object
`clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### length

    protected short length

### opcode

    protected short opcode

Constructor Detail

### Instruction

    public Instruction(short opcode,
                       short length)

Method Detail

### dump

    public void dump(java.io.DataOutputStream out)
              throws java.io.IOException

  Dump instruction as byte code to stream out.

  Parameters:
    `out` - Output stream
    `java.io.IOException`

### getName

    public java.lang.String getName()

  Returns:
    name of instruction, i.e., opcode name

### toString

    public java.lang.String toString(boolean verbose)

  Long output format: <name of opcode> "["<opcode number>"]" "("<length of instruction>")"

  Parameters:
    `verbose` - long/short format switch
  Returns:
    mnemonic for instruction

### toString

    public java.lang.String toString()

  Overrides:
    `toString` in class `java.lang.Object`
  Returns:
    mnemonic for instruction in verbose format

### toString

    public java.lang.String toString(ConstantPool cp)

  Returns:
    mnemonic for instruction with sumbolic references resolved

### copy

    public Instruction copy()

  Use with caution, since `BranchInstruction's have a `target' reference which is not copied correctly (only basic types are). This also applies for `Select' instructions with their multiple branch targets.

  Returns:
    (shallow) copy of an instruction
  See Also:
    `BranchInstruction`

### initFromFile

    protected void initFromFile(ByteSequence bytes,
                                boolean wide)
                         throws java.io.IOException

  Read needed data (e.g. index) from file.

  Parameters:
    `bytes` - byte sequence to read from
    `wide` - "wide" instruction flag
    `java.io.IOException`

### readInstruction

    public static final Instruction readInstruction(ByteSequence bytes)
                                             throws java.io.IOException

  Read an instruction from (byte code) input stream and return the appropiate object.

  Returns:
    instruction object being read
    `java.io.IOException`

### consumeStack

    public int consumeStack(ConstantPoolGen cpg)

  This method also gives right results for instructions whose effect on the stack depends on the constant pool entry they reference.

  Returns:
    Number of words consumed from stack by this instruction, or Constants.UNPREDICTABLE, if this can not be computed statically

### produceStack

    public int produceStack(ConstantPoolGen cpg)

  This method also gives right results for instructions whose effect on the stack depends on the constant pool entry they reference.

  Returns:
    Number of words produced onto stack by this instruction, or Constants.UNPREDICTABLE, if this can not be computed statically

### getOpcode

    public short getOpcode()

  Returns:
    this instructions opcode

### getLength

    public int getLength()

  Returns:
    length (in bytes) of instruction

### accept

    public abstract void accept(Visitor v)

  Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.

  Parameters:
    `v` - Visitor object

### getComparator

    public static InstructionComparator getComparator()

  Get Comparator object used in the equals() method to determine equality of instructions.

  Returns:
    currently used comparator for equals()

### setComparator

    public static void setComparator(InstructionComparator c)

  Set comparator to be used for equals().

### equals

    public boolean equals(java.lang.Object that)

  Check for equality, delegated to comparator

  Overrides:
    `equals` in class `java.lang.Object`
  Returns:
    true if that is an Instruction and has the same opcode

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2002-2003 Apache Software Foundation. All Rights Reserved.