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