// FILE. . . . . /home/hak/hlt/src/hlt/osfv2/base/ConstantSortExpression.java
// EDIT BY . . . Hassan Ait-Kaci
// ON MACHINE. . Hak-Laptop
// STARTED ON. . Mon Sep 09 09:15:40 2013

/**
 * This is the class of built-in atomic sort symbols carrying a constant value.
 *
 * @version     Last modified on Tue Jan 21 08:05:43 2014 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>
 */

package hlt.osf.base;

import hlt.osf.exec.Context;

/**
 * This is the class of constants of built-in sorts.
 */
public class ConstantSortExpression extends SortExpression
  {
    /**
     * Constructs a symbol sort expression with the given name.
     */
    public ConstantSortExpression (Constant constant)
    {
      _constant = constant;
    }

    private Constant _constant;

    public Constant constant ()
    {
      return _constant;
    }

    public Sort sort ()
    {
      return _constant.sort();
    }

    public byte type ()
    {
      return _context.CON();
    }

    public String displayForm ()
    {
      return sort()+"("+_constant.displayForm()+")";
    }    

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

    public boolean equals (Object other)
    {
      if (!(other instanceof ConstantSortExpression))
	return false;

      ConstantSortExpression c = (ConstantSortExpression)other;

      return type() == c.type() && _constant.equals(c.constant());
    }
  }
