X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fxwt%2Fjs%2FByteCodes.java;fp=src%2Forg%2Fxwt%2Fjs%2FByteCodes.java;h=8e79a9acff7dab085febb1f616aeb5567dfc10eb;hb=1bd9bc0c2100ba4a1dc2a5f4ca25ec9e0d1b2265;hp=0000000000000000000000000000000000000000;hpb=b032d1c2f1aacd938b4a823bd400937f8fee0e42;p=org.ibex.core.git diff --git a/src/org/xwt/js/ByteCodes.java b/src/org/xwt/js/ByteCodes.java new file mode 100644 index 0000000..8e79a9a --- /dev/null +++ b/src/org/xwt/js/ByteCodes.java @@ -0,0 +1,75 @@ +// Copyright 2003 Adam Megacz, see the COPYING file for licensing [GPL] +package org.xwt.js; + +/** + * Constants for the various JavaScript ByteCode operations. + * + * Each instruction is an opcode and an optional literal literal; the + * arithmetic Tokens are also valid. They are: BITOR, BITXOR, BITAND, + * ADD, INC, DEC, SUB, MUL, DIV, MOD, LSH, RSH, URSH, LT, LE, GT, GE, + * EQ, NE + */ +interface ByteCodes { + + /** push the literal onto the stack */ + public static final byte LITERAL = -2; + + /** push a new array onto the stack with length equal to the literal */ + public static final byte ARRAY = -3; + + /** push an empty object onto the stack */ + public static final byte OBJECT = -4; + + /** create a new instance; literal is a reference to the corresponding ForthBlock */ + public static final byte NEWFUNCTION = -5; + + /** pop a string off the stack and declare it in the current scope */ + public static final byte DECLARE = -6; + + /** push a reference to the current scope onto the stack */ + public static final byte TOPSCOPE = -7; + + /** pop two elements off the stack; push stack[-1].get(stack[top]) */ + public static final byte GET = -8; + + /** push stack[-1].get(stack[top]) */ + public static final byte GET_PRESERVE = -80; + + /** pop two elements off the stack; stack[-2].put(stack[-1], stack[top]); push stack[top] */ + public static final byte PUT = -9; + + /** literal is a relative address; pop stacktop and jump if the value is true */ + public static final byte JT = -13; + + /** literal is a relative address; pop stacktop and jump if the value is false */ + public static final byte JF = -21; + + /** literal is a relative address; jump to it */ + public static final byte JMP = -22; + + /** discard the top stack element */ + static public final byte POP = -14; + + /** pop two elements; call stack[-1](stack[top]) where stacktop is a JS.Array */ + public static final byte CALL = -15; + + /** pop an element; push a JS.Array containing the keys of the popped element */ + public static final byte PUSHKEYS = -19; + + /** swap the top two elements on the stack */ + public static final byte SWAP = -23; + + /** execute the ForthBlock pointed to by the literal in a fresh scope with parentScope==THIS */ + public static final byte SCOPE = -30; + + /** push a copy of the top stack element */ + public static final byte DUP = -50; + + /** declare a label */ + public static final byte LABEL = -60; + + /** execute the ForthBlock pointed to by the literal until BREAK encountered; push TRUE onto the stack for the first iteration + * and FALSE for all subsequent iterations */ + public static final byte LOOP = -40; + +}