Source code for /engineering/autohit-1998/autohit/vm/VMIFor.javaOriginal file VMIFor.java
   1 /**
   2  * .
   3  * Copyright � 1999 Erich P G.
   4  *
   5  */
   6  
   7 package autohit.vm;
   8 
   9 import java.io.Serializable;
  10 
  11 /**
  12  * A Virtual Machine instruction.  This impliments the head of a FOR loop.
  13  * The loop should resolve to a RSCOPE immeadiately following a JUMP
  14  * instruction.  (The JUMP instruction should point back to THIS
  15  * instruction).  
  16  *
  17  * <pre>
  18  * ip (Instruction Pointer) Flow
  19  *
  20  *                         $count$ == 0
  21  *                   -----------------------------
  22  *                   |                           |
  23  *                   |                           V
  24  *     [SCOPE][SET][FOR] ..code block.. [JUMP][RSCOPE]
  25  *                   ^                    |
  26  *                   |---------------------
  27  *                        always
  28  *
  29  * SET should only be emitted if the init attribute is present.
  30  *
  31  * </pre>
  32  * @see autohit.vm.VMInstruction
  33  * @see autohit.vm.VMIJump
  34  *
  35  * @author Erich P. Gatejen
  36  * @version 1.0
  37  * <i>Version History</i>
  38  * <code>EPG - Initial - 5Jan99</code> 
  39  * 
  40  */
  41 public class VMIFor extends VMInstruction {
  42 	
  43 	// --- FINAL FIELDS ------------------------------------------------------	
  44 
  45 	// --- FIELDS ------------------------------------------------------------
  46 
  47     /**
  48      * Count variable.  Will contain a variable reference.  Should
  49      * the referenced variable = "0", the for should break.
  50      * @serial
  51      */ 
  52     public String   count;
  53 
  54 
  55     /**
  56      * Target for when the FOR is broken.
  57      * @serial
  58      */ 
  59     public int      target;
  60 
  61 	// --- PUBLIC METHODS ----------------------------------------------------	
  62 
  63     /**
  64      *  Default constructor.
  65      */ 
  66     public VMIFor() {
  67         nToken = VMInstruction.FOR;   
  68     }
  69     
  70 
  71     /**
  72      *  Dump this Instruction.  Mostly for debugging.
  73      *
  74      *  @return a String containing the dump.
  75      */
  76     public String toString() {
  77         StringBuffer d = new StringBuffer();        
  78         d.append(" VMIFor ---------------------------- \n");
  79         d.append("    count = " + count + "\n");
  80         d.append("    target = " + target + "\n");
  81         return d.toString();                
  82     }
  83 	// --- PRIVATE METHODS ---------------------------------------------------	
  84 
  85 
  86 }