Example #1
0
JSObject* FASTCALL
js_NewNullClosure(JSContext* cx, JSObject* funobj, JSObject* proto, JSObject* parent)
{
    JS_ASSERT(funobj->isFunction());
    JS_ASSERT(proto->isFunction());
    JS_ASSERT(JS_ON_TRACE(cx));

    JSFunction *fun = (JSFunction*) funobj;
    JS_ASSERT(GET_FUNCTION_PRIVATE(cx, funobj) == fun);

    JSObject* closure = js_NewGCObject(cx);
    if (!closure)
        return NULL;

    closure->initSharingEmptyShape(&js_FunctionClass, proto, parent, fun, cx);
    return closure;
}
Example #2
0
JSObject* FASTCALL
js_NewNullClosure(JSContext* cx, JSObject* funobj, JSObject* proto, JSObject* parent)
{
    JS_ASSERT(funobj->isFunction());
    JS_ASSERT(proto->isFunction());
    JS_ASSERT(JS_ON_TRACE(cx));

    JSFunction *fun = (JSFunction*) funobj;
    JS_ASSERT(funobj->getFunctionPrivate() == fun);

    types::TypeObject *type = proto->getNewType(cx);
    if (!type)
        return NULL;

    JSObject* closure = js_NewGCObject(cx, gc::FINALIZE_OBJECT2);
    if (!closure)
        return NULL;

    if (!closure->initSharingEmptyShape(cx, &FunctionClass, type, parent,
                                        fun, gc::FINALIZE_OBJECT2)) {
        return NULL;
    }
    return closure;
}