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 is an IF instruction. If the
13 * expression matches the value, then the if will pass and the ip
14 * should point to the follow instruction (which should be a SCOPE).
15 * Otherwise the ip will be changed to point to the instruction
16 * following the if block (one beyond the associated RSCOPE).
17 * <p>
18 * <pre>
19 * ip (Instruction Pointer) Flow
20 *
21 * $e$ != value
22 * -------------------------------------------
23 * | |
24 * | V
25 * [IF] [SCOPE]..code block.. [RSCOPE] ... more code..
26 *
27 *
28 * </pre>
29 *
30 *
31 * @see autohit.vm.VMInstruction
32 * @see autohit.vm.VMIScope
33 *
34 * @author Erich P. Gatejen
35 * @version 1.0
36 * <i>Version History</i>
37 * <code>EPG - Initial - 14Jan99</code>
38 *
39 */
40 public class VMIIf extends VMInstruction {
41
42 // --- FINAL FIELDS ------------------------------------------------------
43
44 // --- FIELDS ------------------------------------------------------------
45
46 /**
47 * Expression.
48 * @serial
49 */
50 public String e;
51
52 /**
53 * Value.
54 * @serial
55 */
56 public String value;
57
58 /**
59 * False target. Jump here is expression resolves as false
60 * @serial
61 */
62 public int target;
63
64 // --- PUBLIC METHODS ----------------------------------------------------
65
66 /**
67 * Default constructor.
68 */
69 public VMIIf() {
70 nToken = VMInstruction.IF;
71 }
72
73 /**
74 * Dump this Instruction. Mostly for debugging.
75 *
76 * @return a String containing the dump.
77 */
78 public String toString() {
79 StringBuffer d = new StringBuffer();
80 d.append(" VMIIf ---------------------------- \n");
81 d.append(" expression = " + e + "\n");
82 d.append(" value = " + value + "\n");
83 d.append(" target= " + target + "\n");
84 return d.toString();
85 }
86
87 // --- PRIVATE METHODS ---------------------------------------------------
88
89 }
|