From 0c542e57d5c7dbc07a8970d3bff6a819767db4d8 Mon Sep 17 00:00:00 2001 From: brian Date: Fri, 30 Jan 2004 07:03:25 +0000 Subject: [PATCH] 2003/07/07 01:47:36 darcs-hash:20040130070325-aa32f-02bab3e918961cb6555ea8ec239ddf502430f9bf.gz --- src/org/xwt/js/ByteCodes.java | 7 +++++-- src/org/xwt/js/CompiledFunctionImpl.java | 6 ++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/org/xwt/js/ByteCodes.java b/src/org/xwt/js/ByteCodes.java index 5dc2aff..2e39d6f 100644 --- a/src/org/xwt/js/ByteCodes.java +++ b/src/org/xwt/js/ByteCodes.java @@ -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]) */ diff --git a/src/org/xwt/js/CompiledFunctionImpl.java b/src/org/xwt/js/CompiledFunctionImpl.java index e8fa95f..217a613 100644 --- a/src/org/xwt/js/CompiledFunctionImpl.java +++ b/src/org/xwt/js/CompiledFunctionImpl.java @@ -81,8 +81,10 @@ class CompiledFunctionImpl extends JSCallable implements ByteCodes, Tokens { // Adding and Altering Bytecodes /////////////////////////////////////////////////// int get(int pos) { return op[pos]; } + Object getArg(int pos) { return arg[pos]; } void set(int pos, int op_, Object arg_) { op[pos] = op_; arg[pos] = arg_; } void set(int pos, Object arg_) { arg[pos] = arg_; } + int pop() { size--; arg[size] = null; return op[size]; } void paste(CompiledFunctionImpl other) { for(int i=0; i