//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// PLEASE DO NOT EDIT WITHOUT THE EXPLICIT CONSENT OF THE AUTHOR! \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\

package hlt.language.design.instructions;

/**
 * @version     Last modified on Wed Jun 20 14:29:51 2012 by hak
 * @author      <a href="mailto:hak@acm.org">Hassan A&iuml;t-Kaci</a>
 * @copyright   &copy; <a href="http://www.hassan-ait-kaci.net/">by the author</a>
 */

import hlt.language.design.types.Type;

public abstract class TypedInstruction extends Instruction
{
  protected Type _type;

  protected TypedInstruction (Type type)
    {
      _type = type;
    }

  final Type type ()
    {
      return _type;
    }

  public final boolean equals (Object object)
    {
      if (this == object)
        return true;

      if (!(object instanceof TypedInstruction))
        return false;

      TypedInstruction other = (TypedInstruction)object;

      return name() == other.name() && _type.equals(other.type());
    }

  public final int hashCode ()
    {
      return name().hashCode() + _type.eqCode();
    }

  public final String toString ()
    {
      return name() + "(" + _type + ")";
    }
}
