package ilog.language.design.types;

import ilog.language.design.base.Instruction;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;

/**
 * Objects of this class encapsulate the additional information needed by a
 * a <a href="./DefinedEntry.html"><tt>DefinedEntry</tt></a> when it is that
 * of a class field.
 *
 * @version     Last modified on Wed Oct 16 15:11:06 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>
 */

public class FieldInfo
{
  private DefinedEntry _entry;           // the code entry using this info
  private int _fieldOffset = -1;         // the field's offset in the object
  private Type _fieldType;               // the type of the field's values
  private ClassType _objectType;         // the type of the object with this field
  private Instruction[] _initCode;       // the initialization code for this field
  
  FieldInfo (DefinedEntry entry)
    {
      _entry = entry;
      FunctionType type = (FunctionType)entry.type();
      _objectType = (ClassType)type.domain(0);
      _fieldType = type.curryedRange();
      _fieldOffset = _objectType.nextOffset(sort());
    }

  final ClassType objectType ()
    {
      return _objectType;
    }

  final Type fieldType ()
    {
      return _fieldType.value();
    }

  final byte sort ()
    {
      return fieldType().boxSort();
    }

  final int fieldOffset ()
    {
      return _fieldOffset;
    }

  final Instruction[] initCode ()
    {
      return _initCode;
    }

  final void setInitCode (Instruction[] code)
    {
      _initCode = code;
    }
}








