// Push into a "with" scope and return the converted object. public static Object JScriptWith(Object withOb, VsaEngine engine) { withOb = Convert.ToObject(withOb, engine); if (withOb != null) { engine.PushScriptObjectChecked (new WithScope(engine.ScriptObjectStackTop(), withOb)); return(withOb); } else { throw new JScriptException(JSError.ObjectExpected); } }
// Perform a call on this object. internal override Object Call (VsaEngine engine, Object thisob, Object[] args) { // Create a new scope object and initialize the parameters. ScriptObject scope; if (thisob is JSObject) { scope = new FunctionScope ((JSObject)thisob, defn.fparams, thisob, args); } else { scope = new FunctionScope (declaringScope, defn.fparams, thisob, args); } // Push the scope onto the stack. engine.PushScriptObjectChecked(scope); // Call the function and pop the scope afterwards. Object result = Empty.Value; try { if (defn.body != null) { defn.body.Eval(engine); } } catch (ReturnJumpOut r) { return(r.value); } finally { engine.PopScriptObject(); } // Return the function result to the caller. return(result); }