2003/06/07 11:04:13
[org.ibex.core.git] / src / org / xwt / js / ByteCodes.java
1 // Copyright 2003 Adam Megacz, see the COPYING file for licensing [GPL]
2 package org.xwt.js;
3
4 /**
5  *  Constants for the various JavaScript ByteCode operations.
6  *
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,
10  *  EQ, NE
11  */
12 interface ByteCodes {
13
14     /** push the literal onto the stack */
15     public static final byte LITERAL = -2;       
16
17     /** push a new array onto the stack with length equal to the literal */
18     public static final byte ARRAY = -3;         
19
20     /** push an empty object onto the stack */
21     public static final byte OBJECT = -4;        
22
23     /** create a new instance; literal is a reference to the corresponding ForthBlock */
24     public static final byte NEWFUNCTION = -5;      
25
26     /** pop a string off the stack and declare it in the current scope */
27     public static final byte DECLARE = -6;       
28
29     /** push a reference to the current scope onto the stack */
30     public static final byte TOPSCOPE = -7;
31
32     /** pop two elements off the stack; push stack[-1].get(stack[top]) */
33     public static final byte GET = -8;           
34
35     /** push stack[-1].get(stack[top]) */
36     public static final byte GET_PRESERVE = -80; 
37
38     /** pop two elements off the stack; stack[-2].put(stack[-1], stack[top]); push stack[top] */
39     public static final byte PUT = -9;           
40
41     /** literal is a relative address; pop stacktop and jump if the value is true */
42     public static final byte JT = -13;           
43
44     /** literal is a relative address; pop stacktop and jump if the value is false */
45     public static final byte JF = -21;           
46
47     /** literal is a relative address; jump to it */
48     public static final byte JMP = -22;          
49
50     /** discard the top stack element */
51     static public final byte POP = -14;          
52
53     /** pop two elements; call stack[-1](stack[top]) where stacktop is a JS.Array */
54     public static final byte CALL = -15;         
55
56     /** pop an element; push a JS.Array containing the keys of the popped element */
57     public static final byte PUSHKEYS = -19;     
58
59     /** swap the top two elements on the stack */
60     public static final byte SWAP = -23;         
61
62     /** execute the ForthBlock pointed to by the literal in a fresh scope with parentScope==THIS */
63     public static final byte SCOPE = -30;        
64
65     /** push a copy of the top stack element */
66     public static final byte DUP = -50;          
67
68     /** declare a label */
69     public static final byte LABEL = -60;        
70
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;         
74
75 }