1 // Copyright 2003 Adam Megacz, see the COPYING file for licensing [GPL]
5 * Constants for the various JavaScript ByteCode operations.
7 * Each instruction is an opcode and an optional literal literal;
8 * some Tokens are also valid; see Tokens.java
12 /** push the literal onto the stack */
13 public static final byte LITERAL = -2;
15 /** push a new array onto the stack with length equal to the literal */
16 public static final byte ARRAY = -3;
18 /** push an empty object onto the stack */
19 public static final byte OBJECT = -4;
21 /** create a new instance; literal is a reference to the corresponding ForthBlock */
22 public static final byte NEWFUNCTION = -5;
24 /** pop a string off the stack and declare it in the current scope */
25 public static final byte DECLARE = -6;
27 /** push a reference to the current scope onto the stack */
28 public static final byte TOPSCOPE = -7;
30 /** pop two elements off the stack; push stack[-1].get(stack[top]) */
31 public static final byte GET = -8;
33 /** push stack[-1].get(stack[top]) */
34 public static final byte GET_PRESERVE = -9;
36 /** pop two elements off the stack; stack[-2].put(stack[-1], stack[top]); push stack[top] */
37 public static final byte PUT = -10;
39 /** literal is a relative address; pop stacktop and jump if the value is true */
40 public static final byte JT = -11;
42 /** literal is a relative address; pop stacktop and jump if the value is false */
43 public static final byte JF = -12;
45 /** literal is a relative address; jump to it */
46 public static final byte JMP = -13;
48 /** discard the top stack element */
49 static public final byte POP = -14;
51 /** pop two elements; call stack[-1](stack[top]) where stacktop is a JS.Array */
52 public static final byte CALL = -15;
54 /** pop an element; push a JS.Array containing the keys of the popped element */
55 public static final byte PUSHKEYS = -16;
57 /** swap the top two elements on the stack */
58 public static final byte SWAP = -17;
60 /** execute the ForthBlock pointed to by the literal in a fresh scope with parentScope==THIS */
61 public static final byte NEWSCOPE = -18;
63 /** execute the ForthBlock pointed to by the literal in a fresh scope with parentScope==THIS */
64 public static final byte OLDSCOPE = -19;
66 /** push a copy of the top stack element */
67 public static final byte DUP = -20;
69 /** a NOP; confers a label upon the following instruction */
70 public static final byte LABEL = -21;
72 /** execute the ForthBlock pointed to by the literal until BREAK encountered; push TRUE onto the stack for the first iteration
73 * and FALSE for all subsequent iterations */
74 public static final byte LOOP = -22;