X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fxwt%2Fjs%2FByteCodes.java;h=7ba54b4f0297ea6b6eeb9a8b3d8bcc266d36ef24;hb=de378041d5ca2aca1a2b5a31ef15ae90a86c977f;hp=c74c5640efb7f6ccb78309692f0111b12ec8e7c3;hpb=b5b84ec73713b8ff40e177d4122dda19bd84bf8e;p=org.ibex.core.git diff --git a/src/org/xwt/js/ByteCodes.java b/src/org/xwt/js/ByteCodes.java index c74c564..7ba54b4 100644 --- a/src/org/xwt/js/ByteCodes.java +++ b/src/org/xwt/js/ByteCodes.java @@ -1,4 +1,4 @@ -// Copyright 2003 Adam Megacz, see the COPYING file for licensing [GPL] +// Copyright 2004 Adam Megacz, see the COPYING file for licensing [GPL] package org.xwt.js; /** @@ -21,13 +21,16 @@ interface ByteCodes { /** 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 */ + /** if given a non-null argument declare its argument in the current scope and push + it to the stack, else, declares the element on the top of the stack and leaves it + there */ 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]) */ + /** if given a null literal pop two elements off the stack; push stack[-1].get(stack[top]) + else pop one element off the stack, push stack[top].get(literal) */ public static final byte GET = -8; /** push stack[-1].get(stack[top]) */ @@ -48,19 +51,19 @@ interface ByteCodes { /** discard the top stack element */ static public final byte POP = -14; - /** pop two elements; call stack[-1](stack[top]) where stacktop is a JS.JS.Array */ + /** pop element; call stack[top](stack[-n], stack[-n+1]...) where n is the number of args to the function */ public static final byte CALL = -15; - /** pop an element; push a JS.JS.Array containing the keys of the popped element */ + /** pop an element; push a JS.JSArray containing the keys of the popped element */ public static final byte PUSHKEYS = -16; - /** swap the top two elements on the stack */ + /** push the top element down so that (arg) elements are on top of it; all other elements retain ordering */ public static final byte SWAP = -17; - /** execute the ForthBlock pointed to by the literal in a fresh scope with parentScope==THIS */ + /** execute the bytecode block pointed to by the literal in a fresh scope with parentScope==THIS */ public static final byte NEWSCOPE = -18; - /** execute the ForthBlock pointed to by the literal in a fresh scope with parentScope==THIS */ + /** execute the bytecode block pointed to by the literal in a fresh scope with parentScope==THIS */ public static final byte OLDSCOPE = -19; /** push a copy of the top stack element */ @@ -71,12 +74,21 @@ interface ByteCodes { /** 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 = -22; - - + public static final byte LOOP = -22; + + /** similar effect a a GET followed by a CALL */ + public static final byte CALLMETHOD = -23; + + /** finish a finally block and carry out whatever instruction initiated the finally block */ + public static final byte FINALLY_DONE = -24; + + /** finish a finally block and carry out whatever instruction initiated the finally block */ + public static final byte MAKE_GRAMMAR = -25; + public static final String[] bytecodeToString = new String[] { "", "", "LITERAL", "ARRAY", "OBJECT", "NEWFUNCTION", "DECLARE", "TOPSCOPE", "GET", "GET_PRESERVE", "PUT", "JT", "JF", "JMP", "POP", "CALL", "PUSHKEYS", - "SWAP", "NEWSCOPE", "OLDSCOPE", "DUP", "LABEL", "LOOP" + "SWAP", "NEWSCOPE", "OLDSCOPE", "DUP", "LABEL", "LOOP", "CALLMETHOD", + "FINALLY_DONE", "MAKE_GRAMMAR" }; }