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

package ilog.language.design.kernel;

/**
 * @version     Last modified on Fri Oct 18 17:51:46 2002 by hak
 * @version          modified on Wed Jul 24 12:19:14 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.*;

public class Parameter extends ProtoExpression
{
  private String _name;

  final static Parameter VOID = new Parameter("");
  static { VOID.setType(Type.VOID); }

  public Parameter ()
    {
    }

  public Parameter (String name)
    {
      _name = name.intern();
    }

  public final Expression sanitizeNames (ParameterStack parameters, 
                                         ClassTypeHandle handle)
    {
      return this;
    }

  public final void sanitizeSorts (Enclosure enclosure)
    {
    }

  public final Expression shiftOffsets (int intShift, int realShift, int objectShift,
                                        int intDepth, int realDepth, int objectDepth)
    {
      return this;
    }
  
  private static int _nameCounter;

  public final String name ()
    {
        return (_name != null ? _name : (_name = ("?"+(_nameCounter++)).intern()));
    }

  public final void setCheckedType ()
    {
      if (isSetCheckedType()) return;
      _checkedType = type().copy();
    }

  public final void typeCheck (TypeChecker typeChecker) throws TypingErrorException
    {
      if (typeCheckLocked()) return;

      typeChecker.typeCheck(this,_type);
    }

  public final void compile (Compiler compiler)
    {
    }

  final public String toString ()
    {
      return name() + " : " + (checkedType() == null ?  type() : checkedType());
    }

  // Added by PV
  public final String toTypedString ()
    {
      return toString() + (checkedType() == null ? "" : (" : " + checkedType()));
    }
}
