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; the
8 * arithmetic Tokens are also valid. They are: BITOR, BITXOR, BITAND,
9 * ADD, INC, DEC, SUB, MUL, DIV, MOD, LSH, RSH, URSH, LT, LE, GT, GE,
14 /** push the literal onto the stack */
15 public static final byte LITERAL = -2;
17 /** push a new array onto the stack with length equal to the literal */
18 public static final byte ARRAY = -3;
20 /** push an empty object onto the stack */
21 public static final byte OBJECT = -4;
23 /** create a new instance; literal is a reference to the corresponding ForthBlock */
24 public static final byte NEWFUNCTION = -5;
26 /** pop a string off the stack and declare it in the current scope */
27 public static final byte DECLARE = -6;
29 /** push a reference to the current scope onto the stack */
30 public static final byte TOPSCOPE = -7;
32 /** pop two elements off the stack; push stack[-1].get(stack[top]) */
33 public static final byte GET = -8;
35 /** push stack[-1].get(stack[top]) */
36 public static final byte GET_PRESERVE = -80;
38 /** pop two elements off the stack; stack[-2].put(stack[-1], stack[top]); push stack[top] */
39 public static final byte PUT = -9;
41 /** literal is a relative address; pop stacktop and jump if the value is true */
42 public static final byte JT = -13;
44 /** literal is a relative address; pop stacktop and jump if the value is false */
45 public static final byte JF = -21;
47 /** literal is a relative address; jump to it */
48 public static final byte JMP = -22;
50 /** discard the top stack element */
51 static public final byte POP = -14;
53 /** pop two elements; call stack[-1](stack[top]) where stacktop is a JS.Array */
54 public static final byte CALL = -15;
56 /** pop an element; push a JS.Array containing the keys of the popped element */
57 public static final byte PUSHKEYS = -19;
59 /** swap the top two elements on the stack */
60 public static final byte SWAP = -23;
62 /** execute the ForthBlock pointed to by the literal in a fresh scope with parentScope==THIS */
63 public static final byte SCOPE = -30;
65 /** push a copy of the top stack element */
66 public static final byte DUP = -50;
68 /** declare a label */
69 public static final byte LABEL = -60;
71 /** execute the ForthBlock pointed to by the literal until BREAK encountered; push TRUE onto the stack for the first iteration
72 * and FALSE for all subsequent iterations */
73 public static final byte LOOP = -40;