Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Functions | Variables
jsfun.h File Reference
#include "jsprvtd.h"
#include "jspubtd.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  JSFunction
union  JSFunction.u
struct  JSFunction.u.n
struct  JSFunction.u.i

Defines

#define JSFUN_INTERPRETED   0x8000 /* use u.i if set, u.n if unset */
#define FUN_INTERPRETED(fun)   ((fun)->flags & JSFUN_INTERPRETED)
#define FUN_NATIVE(fun)   (FUN_INTERPRETED(fun) ? NULL : (fun)->u.n.native)
#define FUN_SCRIPT(fun)   (FUN_INTERPRETED(fun) ? (fun)->u.i.script : NULL)
#define VALUE_IS_FUNCTION(cx, v)
#define JSV2F_CONSTRUCT   JSINVOKE_CONSTRUCT
#define JSV2F_ITERATOR   JSINVOKE_ITERATOR
#define JSV2F_SEARCH_STACK   0x10000

Functions

 JS_FRIEND_DATA (JSClass) js_FunctionClass
JSBool js_fun_toString (JSContext *cx, JSObject *obj, uint32 indent, uintN argc, jsval *argv, jsval *rval)
JSBool js_IsIdentifier (JSString *str)
JSObjectjs_InitFunctionClass (JSContext *cx, JSObject *obj)
JSObjectjs_InitArgumentsClass (JSContext *cx, JSObject *obj)
JSObjectjs_InitCallClass (JSContext *cx, JSObject *obj)
JSFunctionjs_NewFunction (JSContext *cx, JSObject *funobj, JSNative native, uintN nargs, uintN flags, JSObject *parent, JSAtom *atom)
JSObjectjs_CloneFunctionObject (JSContext *cx, JSObject *funobj, JSObject *parent)
JSBool js_LinkFunctionObject (JSContext *cx, JSFunction *fun, JSObject *object)
JSFunctionjs_DefineFunction (JSContext *cx, JSObject *obj, JSAtom *atom, JSNative native, uintN nargs, uintN flags)
JSFunctionjs_ValueToFunction (JSContext *cx, jsval *vp, uintN flags)
JSObjectjs_ValueToFunctionObject (JSContext *cx, jsval *vp, uintN flags)
JSObjectjs_ValueToCallableObject (JSContext *cx, jsval *vp, uintN flags)
void js_ReportIsNotFunction (JSContext *cx, jsval *vp, uintN flags)
JSObjectjs_GetCallObject (JSContext *cx, JSStackFrame *fp, JSObject *parent)
JSBool js_PutCallObject (JSContext *cx, JSStackFrame *fp)
JSBool js_GetCallVariable (JSContext *cx, JSObject *obj, jsval id, jsval *vp)
JSBool js_SetCallVariable (JSContext *cx, JSObject *obj, jsval id, jsval *vp)
JSBool js_GetArgsValue (JSContext *cx, JSStackFrame *fp, jsval *vp)
JSBool js_GetArgsProperty (JSContext *cx, JSStackFrame *fp, jsid id, JSObject **objp, jsval *vp)
JSObjectjs_GetArgsObject (JSContext *cx, JSStackFrame *fp)
JSBool js_PutArgsObject (JSContext *cx, JSStackFrame *fp)
JSBool js_XDRFunction (JSXDRState *xdr, JSObject **objp)

Variables

JSClass js_ArgumentsClass
JSClass js_CallClass

Class Documentation

struct JSFunction

Definition at line 50 of file jsfun.h.

Collaboration diagram for JSFunction:
Class Members
JSAtom * atom
JSClass * clasp
uint16 flags
uint16 nargs
JSObject * object
union JSFunction u
union JSFunction.u

Definition at line 54 of file jsfun.h.

Class Members
u i
u n
struct JSFunction.u.n

Definition at line 55 of file jsfun.h.

Class Members
uint16 extra
JSNative native
uint16 spare
struct JSFunction.u.i

Definition at line 60 of file jsfun.h.

Class Members
uint16 nregexps
uint16 nvars
JSScript * script

Define Documentation

Definition at line 72 of file jsfun.h.

#define FUN_NATIVE (   fun)    (FUN_INTERPRETED(fun) ? NULL : (fun)->u.n.native)

Definition at line 73 of file jsfun.h.

Definition at line 74 of file jsfun.h.

#define JSFUN_INTERPRETED   0x8000 /* use u.i if set, u.n if unset */

Definition at line 70 of file jsfun.h.

Definition at line 124 of file jsfun.h.

Definition at line 125 of file jsfun.h.

#define JSV2F_SEARCH_STACK   0x10000

Definition at line 126 of file jsfun.h.

#define VALUE_IS_FUNCTION (   cx,
  v 
)
Value:
(!JSVAL_IS_PRIMITIVE(v) &&                                                \
     OBJ_GET_CLASS(cx, JSVAL_TO_OBJECT(v)) == &js_FunctionClass)

Definition at line 85 of file jsfun.h.


Function Documentation

JSObject* js_CloneFunctionObject ( JSContext cx,
JSObject funobj,
JSObject parent 
)

Definition at line 2170 of file jsfun.c.

{
    JSObject *newfunobj;
    JSFunction *fun;

    JS_ASSERT(OBJ_GET_CLASS(cx, funobj) == &js_FunctionClass);
    newfunobj = js_NewObject(cx, &js_FunctionClass, funobj, parent);
    if (!newfunobj)
        return NULL;
    fun = (JSFunction *) JS_GetPrivate(cx, funobj);
    if (!js_LinkFunctionObject(cx, fun, newfunobj)) {
        cx->weakRoots.newborn[GCX_OBJECT] = NULL;
        return NULL;
    }
    return newfunobj;
}

Here is the call graph for this function:

Here is the caller graph for this function:

JSFunction* js_DefineFunction ( JSContext cx,
JSObject obj,
JSAtom atom,
JSNative  native,
uintN  nargs,
uintN  flags 
)

Definition at line 2196 of file jsfun.c.

{
    JSFunction *fun;

    fun = js_NewFunction(cx, NULL, native, nargs, attrs, obj, atom);
    if (!fun)
        return NULL;
    if (!OBJ_DEFINE_PROPERTY(cx, obj, ATOM_TO_JSID(atom),
                             OBJECT_TO_JSVAL(fun->object),
                             NULL, NULL,
                             attrs & ~JSFUN_FLAGS_MASK, NULL)) {
        return NULL;
    }
    return fun;
}

Here is the call graph for this function:

Here is the caller graph for this function:

JSBool js_fun_toString ( JSContext cx,
JSObject obj,
uint32  indent,
uintN  argc,
jsval argv,
jsval rval 
)

Definition at line 1491 of file jsfun.c.

{
    jsval fval;
    JSFunction *fun;
    JSString *str;

    if (!argv) {
        JS_ASSERT(JS_ObjectIsFunction(cx, obj));
    } else {
        fval = argv[-1];
        if (!VALUE_IS_FUNCTION(cx, fval)) {
            /*
             * If we don't have a function to start off with, try converting
             * the object to a function.  If that doesn't work, complain.
             */
            if (JSVAL_IS_OBJECT(fval)) {
                obj = JSVAL_TO_OBJECT(fval);
                if (!OBJ_GET_CLASS(cx, obj)->convert(cx, obj, JSTYPE_FUNCTION,
                                                     &fval)) {
                    return JS_FALSE;
                }
                argv[-1] = fval;
            }
            if (!VALUE_IS_FUNCTION(cx, fval)) {
                JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
                                     JSMSG_INCOMPATIBLE_PROTO,
                                     js_Function_str, js_toString_str,
                                     JS_GetTypeName(cx,
                                                    JS_TypeOfValue(cx, fval)));
                return JS_FALSE;
            }
        }

        obj = JSVAL_TO_OBJECT(fval);
    }

    fun = (JSFunction *) JS_GetPrivate(cx, obj);
    if (!fun)
        return JS_TRUE;
    if (argc && !js_ValueToECMAUint32(cx, argv[0], &indent))
        return JS_FALSE;
    str = JS_DecompileFunction(cx, fun, (uintN)indent);
    if (!str)
        return JS_FALSE;
    *rval = STRING_TO_JSVAL(str);
    return JS_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 237 of file jsfun.c.

{
    JSObject *argsobj, *global, *parent;

    /*
     * We must be in a function activation; the function must be lightweight
     * or else fp must have a variable object.
     */
    JS_ASSERT(fp->fun && (!(fp->fun->flags & JSFUN_HEAVYWEIGHT) || fp->varobj));

    /* Skip eval and debugger frames. */
    while (fp->flags & JSFRAME_SPECIAL)
        fp = fp->down;

    /* Create an arguments object for fp only if it lacks one. */
    argsobj = fp->argsobj;
    if (argsobj)
        return argsobj;

    /* Link the new object to fp so it can get actual argument values. */
    argsobj = js_NewObject(cx, &js_ArgumentsClass, NULL, NULL);
    if (!argsobj || !JS_SetPrivate(cx, argsobj, fp)) {
        cx->weakRoots.newborn[GCX_OBJECT] = NULL;
        return NULL;
    }

    /*
     * Give arguments an intrinsic scope chain link to fp's global object.
     * Since the arguments object lacks a prototype because js_ArgumentsClass
     * is not initialized, js_NewObject won't assign a default parent to it.
     *
     * Therefore if arguments is used as the head of an eval scope chain (via
     * a direct or indirect call to eval(program, arguments)), any reference
     * to a standard class object in the program will fail to resolve due to
     * js_GetClassPrototype not being able to find a global object containing
     * the standard prototype by starting from arguments and following parent.
     */
    global = fp->scopeChain;
    while ((parent = OBJ_GET_PARENT(cx, global)) != NULL)
        global = parent;
    argsobj->slots[JSSLOT_PARENT] = OBJECT_TO_JSVAL(global);
    fp->argsobj = argsobj;
    return argsobj;
}

Here is the call graph for this function:

Here is the caller graph for this function:

JSBool js_GetArgsProperty ( JSContext cx,
JSStackFrame fp,
jsid  id,
JSObject **  objp,
jsval vp 
)

Definition at line 176 of file jsfun.c.

{
    jsval val;
    JSObject *obj;
    uintN slot;

    if (TEST_OVERRIDE_BIT(fp, CALL_ARGUMENTS)) {
        JS_ASSERT(fp->callobj);
        if (!OBJ_GET_PROPERTY(cx, fp->callobj,
                              ATOM_TO_JSID(cx->runtime->atomState
                                           .argumentsAtom),
                              &val)) {
            return JS_FALSE;
        }
        if (JSVAL_IS_PRIMITIVE(val)) {
            obj = js_ValueToNonNullObject(cx, val);
            if (!obj)
                return JS_FALSE;
        } else {
            obj = JSVAL_TO_OBJECT(val);
        }
        *objp = obj;
        return OBJ_GET_PROPERTY(cx, obj, id, vp);
    }

    *objp = NULL;
    *vp = JSVAL_VOID;
    if (JSID_IS_INT(id)) {
        slot = (uintN) JSID_TO_INT(id);
        if (slot < fp->argc) {
            if (fp->argsobj && ArgWasDeleted(cx, fp, slot))
                return OBJ_GET_PROPERTY(cx, fp->argsobj, id, vp);
            *vp = fp->argv[slot];
        } else {
            /*
             * Per ECMA-262 Ed. 3, 10.1.8, last bulleted item, do not share
             * storage between the formal parameter and arguments[k] for all
             * k >= fp->argc && k < fp->fun->nargs.  For example, in
             *
             *   function f(x) { x = 42; return arguments[0]; }
             *   f();
             *
             * the call to f should return undefined, not 42.  If fp->argsobj
             * is null at this point, as it would be in the example, return
             * undefined in *vp.
             */
            if (fp->argsobj)
                return OBJ_GET_PROPERTY(cx, fp->argsobj, id, vp);
        }
    } else {
        if (id == ATOM_TO_JSID(cx->runtime->atomState.lengthAtom)) {
            if (fp->argsobj && TEST_OVERRIDE_BIT(fp, ARGS_LENGTH))
                return OBJ_GET_PROPERTY(cx, fp->argsobj, id, vp);
            *vp = INT_TO_JSVAL((jsint) fp->argc);
        }
    }
    return JS_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

JSBool js_GetArgsValue ( JSContext cx,
JSStackFrame fp,
jsval vp 
)

Definition at line 95 of file jsfun.c.

{
    JSObject *argsobj;

    if (TEST_OVERRIDE_BIT(fp, CALL_ARGUMENTS)) {
        JS_ASSERT(fp->callobj);
        return OBJ_GET_PROPERTY(cx, fp->callobj,
                                ATOM_TO_JSID(cx->runtime->atomState
                                             .argumentsAtom),
                                vp);
    }
    argsobj = js_GetArgsObject(cx, fp);
    if (!argsobj)
        return JS_FALSE;
    *vp = OBJECT_TO_JSVAL(argsobj);
    return JS_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

JSObject* js_GetCallObject ( JSContext cx,
JSStackFrame fp,
JSObject parent 
)

Definition at line 590 of file jsfun.c.

{
    JSObject *callobj, *funobj;

    /* Create a call object for fp only if it lacks one. */
    JS_ASSERT(fp->fun);
    callobj = fp->callobj;
    if (callobj)
        return callobj;
    JS_ASSERT(fp->fun);

    /* The default call parent is its function's parent (static link). */
    if (!parent) {
        funobj = fp->argv ? JSVAL_TO_OBJECT(fp->argv[-2]) : fp->fun->object;
        if (funobj)
            parent = OBJ_GET_PARENT(cx, funobj);
    }

    /* Create the call object and link it to its stack frame. */
    callobj = js_NewObject(cx, &js_CallClass, NULL, parent);
    if (!callobj || !JS_SetPrivate(cx, callobj, fp)) {
        cx->weakRoots.newborn[GCX_OBJECT] = NULL;
        return NULL;
    }
    fp->callobj = callobj;

    /* Make callobj be the scope chain and the variables object. */
    JS_ASSERT(fp->scopeChain == parent);
    fp->scopeChain = callobj;
    fp->varobj = callobj;
    return callobj;
}

Here is the call graph for this function:

Here is the caller graph for this function:

JSBool js_GetCallVariable ( JSContext cx,
JSObject obj,
jsval  id,
jsval vp 
)

Definition at line 735 of file jsfun.c.

{
    JSStackFrame *fp;

    JS_ASSERT(JSVAL_IS_INT(id));
    fp = (JSStackFrame *) JS_GetPrivate(cx, obj);
    if (fp) {
        /* XXX no jsint slot commoning here to avoid MSVC1.52 crashes */
        if ((uintN)JSVAL_TO_INT(id) < fp->nvars)
            *vp = fp->vars[JSVAL_TO_INT(id)];
    }
    return JS_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

JSObject* js_InitCallClass ( JSContext cx,
JSObject obj 
)

Definition at line 2104 of file jsfun.c.

{
    JSObject *proto;

    proto = JS_InitClass(cx, obj, NULL, &js_CallClass, NULL, 0,
                         call_props, NULL, NULL, NULL);
    if (!proto)
        return NULL;

    /*
     * Null Call.prototype's proto slot so that Object.prototype.* does not
     * pollute the scope of heavyweight functions.
     */
    OBJ_SET_PROTO(cx, proto, NULL);
    return proto;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 2079 of file jsfun.c.

{
    JSObject *proto;
    JSFunction *fun;

    proto = JS_InitClass(cx, obj, NULL, &js_FunctionClass, Function, 1,
                         function_props, function_methods, NULL, NULL);
    if (!proto)
        return NULL;
    fun = js_NewFunction(cx, proto, NULL, 0, 0, obj, NULL);
    if (!fun)
        goto bad;
    fun->u.i.script = js_NewScript(cx, 1, 0, 0);
    if (!fun->u.i.script)
        goto bad;
    fun->u.i.script->code[0] = JSOP_STOP;
    fun->flags |= JSFUN_INTERPRETED;
    return proto;

bad:
    cx->weakRoots.newborn[GCX_OBJECT] = NULL;
    return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1777 of file jsfun.c.

{
    size_t length;
    jschar c, *chars, *end, *s;

    length = JSSTRING_LENGTH(str);
    if (length == 0)
        return JS_FALSE;
    chars = JSSTRING_CHARS(str);
    c = *chars;
    if (!JS_ISIDSTART(c))
        return JS_FALSE;
    end = chars + length;
    for (s = chars + 1; s != end; ++s) {
        c = *s;
        if (!JS_ISIDENT(c))
            return JS_FALSE;
    }
    return !js_IsKeyword(chars, length);
}

Here is the caller graph for this function:

JSBool js_LinkFunctionObject ( JSContext cx,
JSFunction fun,
JSObject object 
)

Definition at line 2188 of file jsfun.c.

{
    if (!fun->object)
        fun->object = funobj;
    return JS_SetPrivate(cx, funobj, fun);
}

Here is the call graph for this function:

Here is the caller graph for this function:

JSFunction* js_NewFunction ( JSContext cx,
JSObject funobj,
JSNative  native,
uintN  nargs,
uintN  flags,
JSObject parent,
JSAtom atom 
)

Definition at line 2122 of file jsfun.c.

{
    JSFunction *fun;
    JSTempValueRooter tvr;

    /* If funobj is null, allocate an object for it. */
    if (funobj) {
        OBJ_SET_PARENT(cx, funobj, parent);
    } else {
        funobj = js_NewObject(cx, &js_FunctionClass, NULL, parent);
        if (!funobj)
            return NULL;
    }

    /* Protect fun from any potential GC callback. */
    JS_PUSH_SINGLE_TEMP_ROOT(cx, OBJECT_TO_JSVAL(funobj), &tvr);

    /*
     * Allocate fun after allocating funobj so slot allocation in js_NewObject
     * does not wipe out fun from newborn[GCX_PRIVATE].
     */
    fun = (JSFunction *) js_NewGCThing(cx, GCX_PRIVATE, sizeof(JSFunction));
    if (!fun)
        goto out;

    /* Initialize all function members. */
    fun->object = NULL;
    fun->nargs = nargs;
    fun->flags = flags & JSFUN_FLAGS_MASK;
    fun->u.n.native = native;
    fun->u.n.extra = 0;
    fun->u.n.spare = 0;
    fun->atom = atom;
    fun->clasp = NULL;

    /* Link fun to funobj and vice versa. */
    if (!js_LinkFunctionObject(cx, fun, funobj)) {
        cx->weakRoots.newborn[GCX_OBJECT] = NULL;
        fun = NULL;
    }

out:
    JS_POP_TEMP_ROOT(cx, &tvr);
    return fun;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 286 of file jsfun.c.

{
    JSObject *argsobj;
    jsval bmapval, rval;
    JSBool ok;
    JSRuntime *rt;

    /*
     * Reuse args_enumerate here to reflect fp's actual arguments as indexed
     * elements of argsobj.  Do this first, before clearing and freeing the
     * deleted argument slot bitmap, because args_enumerate depends on that.
     */
    argsobj = fp->argsobj;
    ok = args_enumerate(cx, argsobj);

    /*
     * Now clear the deleted argument number bitmap slot and free the bitmap,
     * if one was actually created due to 'delete arguments[0]' or similar.
     */
    (void) JS_GetReservedSlot(cx, argsobj, 0, &bmapval);
    if (!JSVAL_IS_VOID(bmapval)) {
        JS_SetReservedSlot(cx, argsobj, 0, JSVAL_VOID);
        if (fp->argc > JSVAL_INT_BITS)
            JS_free(cx, JSVAL_TO_PRIVATE(bmapval));
    }

    /*
     * Now get the prototype properties so we snapshot fp->fun and fp->argc
     * before fp goes away.
     */
    rt = cx->runtime;
    ok &= js_GetProperty(cx, argsobj, ATOM_TO_JSID(rt->atomState.calleeAtom),
                         &rval);
    ok &= js_SetProperty(cx, argsobj, ATOM_TO_JSID(rt->atomState.calleeAtom),
                         &rval);
    ok &= js_GetProperty(cx, argsobj, ATOM_TO_JSID(rt->atomState.lengthAtom),
                         &rval);
    ok &= js_SetProperty(cx, argsobj, ATOM_TO_JSID(rt->atomState.lengthAtom),
                         &rval);

    /*
     * Clear the private pointer to fp, which is about to go away (js_Invoke).
     * Do this last because the args_enumerate and js_GetProperty calls above
     * need to follow the private slot to find fp.
     */
    ok &= JS_SetPrivate(cx, argsobj, NULL);
    fp->argsobj = NULL;
    return ok;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 627 of file jsfun.c.

{
    JSObject *callobj;
    JSBool ok;
    jsid argsid;
    jsval aval;

    /*
     * Reuse call_enumerate here to reflect all actual args and vars into the
     * call object from fp.
     */
    callobj = fp->callobj;
    if (!callobj)
        return JS_TRUE;
    ok = call_enumerate(cx, callobj);

    /*
     * Get the arguments object to snapshot fp's actual argument values.
     */
    if (fp->argsobj) {
        argsid = ATOM_TO_JSID(cx->runtime->atomState.argumentsAtom);
        ok &= js_GetProperty(cx, callobj, argsid, &aval);
        ok &= js_SetProperty(cx, callobj, argsid, &aval);
        ok &= js_PutArgsObject(cx, fp);
    }

    /*
     * Clear the private pointer to fp, which is about to go away (js_Invoke).
     * Do this last because the call_enumerate and js_GetProperty calls above
     * need to follow the private slot to find fp.
     */
    ok &= JS_SetPrivate(cx, callobj, NULL);
    fp->callobj = NULL;
    return ok;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void js_ReportIsNotFunction ( JSContext cx,
jsval vp,
uintN  flags 
)

Definition at line 2292 of file jsfun.c.

{
    JSStackFrame *fp;
    JSString *str;
    JSTempValueRooter tvr;
    const char *bytes, *source;

    for (fp = cx->fp; fp && !fp->spbase; fp = fp->down)
        continue;
    str = js_DecompileValueGenerator(cx,
                                     (fp && fp->spbase <= vp && vp < fp->sp)
                                     ? vp - fp->sp
                                     : (flags & JSV2F_SEARCH_STACK)
                                     ? JSDVG_SEARCH_STACK
                                     : JSDVG_IGNORE_STACK,
                                     *vp,
                                     NULL);
    if (str) {
        JS_PUSH_TEMP_ROOT_STRING(cx, str, &tvr);
        bytes = JS_GetStringBytes(str);
        if (flags & JSV2F_ITERATOR) {
            source = js_ValueToPrintableSource(cx, *vp);
            if (source) {
                JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
                                     JSMSG_BAD_ITERATOR,
                                     bytes, js_iterator_str, source);
            }
        } else {
            JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
                                 (uintN)((flags & JSV2F_CONSTRUCT)
                                         ? JSMSG_NOT_CONSTRUCTOR
                                         : JSMSG_NOT_FUNCTION),
                                 bytes);
        }
        JS_POP_TEMP_ROOT(cx, &tvr);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

JSBool js_SetCallVariable ( JSContext cx,
JSObject obj,
jsval  id,
jsval vp 
)

Definition at line 750 of file jsfun.c.

{
    JSStackFrame *fp;

    JS_ASSERT(JSVAL_IS_INT(id));
    fp = (JSStackFrame *) JS_GetPrivate(cx, obj);
    if (fp) {
        /* XXX jsint slot is block-local here to avoid MSVC1.52 crashes */
        jsint slot = JSVAL_TO_INT(id);
        if ((uintN)slot < fp->nvars)
            fp->vars[slot] = *vp;
    }
    return JS_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

JSObject* js_ValueToCallableObject ( JSContext cx,
jsval vp,
uintN  flags 
)

Definition at line 2275 of file jsfun.c.

{
    JSObject *callable;

    callable = JSVAL_IS_PRIMITIVE(*vp) ? NULL : JSVAL_TO_OBJECT(*vp);
    if (callable &&
        ((callable->map->ops == &js_ObjectOps)
         ? OBJ_GET_CLASS(cx, callable)->call
         : callable->map->ops->call)) {
        *vp = OBJECT_TO_JSVAL(callable);
    } else {
        callable = js_ValueToFunctionObject(cx, vp, flags);
    }
    return callable;
}

Here is the call graph for this function:

Here is the caller graph for this function:

JSFunction* js_ValueToFunction ( JSContext cx,
jsval vp,
uintN  flags 
)

Definition at line 2218 of file jsfun.c.

{
    jsval v;
    JSObject *obj;

    v = *vp;
    obj = NULL;
    if (JSVAL_IS_OBJECT(v)) {
        obj = JSVAL_TO_OBJECT(v);
        if (obj && OBJ_GET_CLASS(cx, obj) != &js_FunctionClass) {
            if (!OBJ_DEFAULT_VALUE(cx, obj, JSTYPE_FUNCTION, &v))
                return NULL;
            obj = VALUE_IS_FUNCTION(cx, v) ? JSVAL_TO_OBJECT(v) : NULL;
        }
    }
    if (!obj) {
        js_ReportIsNotFunction(cx, vp, flags);
        return NULL;
    }
    return (JSFunction *) JS_GetPrivate(cx, obj);
}

Here is the call graph for this function:

Here is the caller graph for this function:

JSObject* js_ValueToFunctionObject ( JSContext cx,
jsval vp,
uintN  flags 
)

Definition at line 2241 of file jsfun.c.

{
    JSFunction *fun;
    JSObject *funobj;
    JSStackFrame *caller;
    JSPrincipals *principals;

    if (VALUE_IS_FUNCTION(cx, *vp))
        return JSVAL_TO_OBJECT(*vp);

    fun = js_ValueToFunction(cx, vp, flags);
    if (!fun)
        return NULL;
    funobj = fun->object;
    *vp = OBJECT_TO_JSVAL(funobj);

    caller = JS_GetScriptedCaller(cx, cx->fp);
    if (caller) {
        principals = JS_StackFramePrincipals(cx, caller);
    } else {
        /* No scripted caller, don't allow access. */
        principals = NULL;
    }

    if (!js_CheckPrincipalsAccess(cx, funobj, principals,
                                  fun->atom
                                  ? fun->atom
                                  : cx->runtime->atomState.anonymousAtom)) {
        return NULL;
    }
    return funobj;
}

Here is the call graph for this function:

Here is the caller graph for this function:

JSBool js_XDRFunction ( JSXDRState xdr,
JSObject **  objp 
)

Variable Documentation

Definition at line 575 of file jsfun.c.

Definition at line 939 of file jsfun.c.