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);
}
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 //////////////////////////////////////////////////////////////////////////////