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

package ilog.language.design.base;

/**
 * @version     Last modified on Wed Apr 10 17:56:58 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.backend.IntMap;
import ilog.language.design.backend.Indexable;
import ilog.language.design.backend.Runtime;
import ilog.language.design.backend.SizeMatchException;

public class MakeIntMap extends Instruction
{
  public MakeIntMap ()
    {
      setName("MAKE_MAP_I");
    }

  public final void execute (Runtime r) throws SizeMatchException
    {
      Indexable indexable = (Indexable)r.popObject();
      int size = r.popInt();
      if (indexable.size() != size)
        throw new SizeMatchException("indexable size ("+indexable.size()+
                                     ") does not match array size ("+size+")");

      int[] array = new int[size];
      for (int i=0; i<size; i++)
        array[i] = r.popInt();
      r.pushObject(new IntMap(array,indexable));
      r.incIP();
    }
}
