From: adam Date: Mon, 27 Sep 2004 07:54:24 +0000 (+0000) Subject: added new invocation that does not create a call frame X-Git-Url: http://git.megacz.com/?p=org.ibex.js.git;a=commitdiff_plain;h=667c62a82febcf946918c3a4fc09bb644b288b54 added new invocation that does not create a call frame darcs-hash:20040927075424-5007d-9644b8a4d76f908ff83b4fe097cec351aa5849d6.gz --- diff --git a/src/org/ibex/js/Interpreter.java b/src/org/ibex/js/Interpreter.java index 504bbd2..94ccab5 100644 --- a/src/org/ibex/js/Interpreter.java +++ b/src/org/ibex/js/Interpreter.java @@ -22,11 +22,12 @@ class Interpreter implements ByteCodes, Tokens { Vec stack = new Vec(); ///< the object stack int pc = 0; ///< the program counter - Interpreter(JSFunction f, boolean pauseable, JSArray args) { + Interpreter(JSFunction f, boolean pauseable, JSArray args) { this(f, pauseable, args, true); } + Interpreter(JSFunction f, boolean pauseable, JSArray args, boolean wrap) { stack.push(new Interpreter.CallMarker(this)); // the "root function returned" marker -- f==null this.f = f; this.pausecount = pauseable ? 0 : -1; - this.scope = new JSScope(f.parentScope); + this.scope = wrap ? new JSScope(f.parentScope) : f.parentScope; stack.push(args); } diff --git a/src/org/ibex/js/JS.java b/src/org/ibex/js/JS.java index 3a11127..7cd1fc7 100644 --- a/src/org/ibex/js/JS.java +++ b/src/org/ibex/js/JS.java @@ -187,6 +187,11 @@ public class JS /*extends org.ibex.util.BalancedTree*/ implements Serializable { return ((JSFunction)j)._cloneWithNewParentScope(s); } + public static Object eval(JS j) throws JSExn { + Interpreter cx = new Interpreter((JSFunction)j, false, new JSArray(), false); + return cx.resume(); + } + // Trap support //////////////////////////////////////////////////////////////////////////////