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

package hlt.language.design.instructions;

/**
 * @version     Last modified on Wed Jun 20 14:29:51 2012 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>
 * @copyright   &copy; 2000-2002 <a href="http://www.hlt.fr/">HLT, S.A.</a>
 */

import hlt.language.design.backend.Runtime;
import hlt.language.design.backend.RuntimeSet;

public class PrevIntCircOffSet extends Instruction
{
  public PrevIntCircOffSet ()
    {
      setName("PREV_C_I_OFFSET");
    }

  public final void execute (Runtime r)
    {
      RuntimeSet set = (RuntimeSet)r.popObject("can't access the element of a null set");
      int value = r.popInt();
      int cpt = r.popInt();      
      int i = 0;
      while (i < cpt) {       
        value = set.prevc(value); 
        i++;
      }
      r.pushInt(value);
      r.incIP();
    }
}
