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

package ilog.language.design.kernel;

/**
 * @version     Last modified on Wed Jul 24 12:17:55 2002 by pviry
 * @version          modified on Fri Mar 08 12:36:35 2002 by hak
 * @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.*;

/**
 * This is the class of native java objects that are built-in constants.
 */
public class BuiltinObjectConstant extends Constant
{
  protected Object _value;

  public BuiltinObjectConstant (Type type)
    {
      super(type);
    }

  public BuiltinObjectConstant (Object value, Type type)
    {
      super(type);
      _setValue(value);
    }

  public final Object value ()
    {
      return _value;
    }

  private void _setValue (Object value)
    {
      _value = value;
      if (value == null) setIsNull();
    }

  public final void compile (Compiler compiler)
    {
      compiler.generate(new PushValueObject(_value));
    }

  public boolean equals (Object other)
    {
      if (!(other instanceof BuiltinObjectConstant))
        return false;
      
      return _value.equals(((BuiltinObjectConstant)other).value());
    }

  public String toString ()
    {
      return _value.toString();
    }

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