Пример #1
0
JSObject *
js_FindVariableScope(JSContext *cx, JSFunction **funp)
{
    JSStackFrame *fp;
    JSObject *obj, *parent, *withobj;
    JSClass *clasp;
    JSFunction *fun;

    PR_ASSERT(JS_IS_LOCKED(cx));

    fp = cx->fp;
    for (obj = fp->scopeChain, withobj = NULL; ; obj = parent) {
	parent = OBJ_GET_PARENT(obj);
	clasp = obj->map->clasp;
	if (!parent || clasp != &js_WithClass)
	    break;
	withobj = obj;
    }

    fun = (clasp == &js_FunctionClass) ? JS_GetPrivate(cx, obj) : NULL;
#if JS_HAS_CALL_OBJECT
    if (fun && fun->script) {
	for (; fp && fp->fun != fun; fp = fp->down)
	    ;
	if (fp) {
	    obj = js_GetCallObject(cx, fp, parent);
	    if (withobj)
		OBJ_SET_PARENT(withobj, obj);
	}
    }
#endif

    *funp = fun;
    return obj;
}
Пример #2
0
JS_GetFrameCallObject(JSContext *cx, JSStackFrame *fp)
{
    if (! fp->fun)
        return NULL;
#if JS_HAS_ARGS_OBJECT
    /* Force creation of argument object if not yet created */
    (void) js_GetArgsObject(cx, fp);
#endif
#if JS_HAS_CALL_OBJECT
    /*
     * XXX ill-defined: null return here means error was reported, unlike a
     *     null returned above or in the #else
     */
    return js_GetCallObject(cx, fp, NULL);
#else
    return NULL;
#endif /* JS_HAS_CALL_OBJECT */
}