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

package ilog.language.design.kernel;

/**
 * @version     Last modified on Fri Oct 18 17:50:49 2002 by hak
 * @version          modified on Wed Jul 24 12:18:22 2002 by pviry
 * @author      <a href="mailto:hak@ilog.fr">Hassan A&iuml;t-Kaci</a>
 * @copyright   &copy; 2000-2002 <a href="http://www.ilog.fr/">ILOG, S.A.</a>
 */

import ilog.language.design.types.*;
import ilog.language.design.base.*;

import java.util.HashSet;

public class Dummy extends Expression
{
  protected Tables _tables;
  protected String _name;
  protected Type _type = new TypeParameter();

  public Dummy (Tables tables, String name)
    {
      _tables = tables;
      _name = name.intern();
    }

  public final Tables tables ()
    {
      return _tables;
    }

  public final String name ()
    {
      return _name;
    }

  public final Type type ()
    {
      return _type;
    }

  public final void setType (Type type)
    {
      if (type != null) _type = type;
    }

  public final Type typeRef ()
    {
      return _type;
    }

  /**
   * This is a no-op since a Dummy never gets to invoke this.
   */
  public final Type checkedType ()
    {
      return null;
    }

  /**
   * This is a no-op since a Dummy never gets to invoke this.
   */
  public final void setCheckedType ()
    {
      if (isSetCheckedType()) return;
    }

  /**
   * This is a no-op since a Dummy never gets to invoke this.
   */
  public final void setCheckedType (Type type)
    {
    }

  /**
   * This is a no-op since a Dummy never gets to invoke this.
   */
  public final Expression shiftOffsets (int intShift, int realShift, int objectShift,
                                        int intDepth, int realDepth, int objectDepth)
    {
      return this;
    }

  public Expression sanitizeNames (ParameterStack parameters, ClassTypeHandle handle)
    {
      Parameter parameter = parameters.getLocalParameter(_name);
      Expression actual = (parameter == null)
                        ? (Expression)new Global(_tables,_name,_type)
                        : (Expression)new Local(parameter,_type);
      return actual.addTypes(this).setExtent(this);
    }

  /**
   * This is a no-op since a Dummy never gets to invoke this.
   */
  public final void sanitizeSorts (Enclosure enclosure)
    {
    }

  /**
   * This is a no-op since a Dummy never gets to invoke this.
   */
  public final void typeCheck (TypeChecker typeChecker) throws TypingErrorException
    {
      if (typeCheckLocked()) return;

    }

  /**
   * This is a no-op since a Dummy never gets to invoke this.
   */
  public final void compile (Compiler compiler)
    {
    }

  public String toString ()
    {
      return "dummy_"+_name;
    }

  // Added by PV
  public String toTypedString ()
    {
        return typed(toString());
    }
}
