package rebelsky.pal;

import java.util.Collection;

/**
 * A PAL instruction annotated with additional information, such as
 * liveness information.  Intended primarily as a tool in doing
 * program analysis, such as liveness analysis or register allocation.
 *
 * @author Samuel A. Rebelsky
 * @version 1.0 of November 2002
 */
public class AnnotatedInstruction
  implements Instruction
{
  // +--------+------------------------------------------------------------
  // | Fields |
  // +--------+

  /** The instruction being annotated. */
  Instruction original;

  /** The indices of all successor instructions. */
  Collection successors;

  /** The indices of all predecessor instructions. */
  Collection predecessors;


  // +--------------+------------------------------------------------------
  // | Constructors |
  // +--------------+

  /**
   * Create a new annotated instruction from an original instruction.
   */
  public AnnotatedInstruction(Instruction original) {
    this.original = original;
  } // AnnotatedInstruction(Instruction)

  
  // +---------+-----------------------------------------------------------
  // | Methods |
  // +---------+

  /** 
   * Execute the instruction on a machine. 
   *
   * @exception Exception
   *   All the time: Instruction sequences are for building programs,
   *   not for executing them.
   */
  public void execute(Computer hal) 
    throws Exception
  {
    original.execute(hal);
  } // execute(Computer)

  /** Convert the instruction to a string (usually for printing). */
  public String toString() {
    return original.toString();
  } // toString()

} // class AnnotatedInstruction

