proto = NULL;
parentProto = NULL;
fun_resolve(JSContext *cx, JSObject *obj, jsval id, uintN flags,            JSObject **objp){    JSFunction *fun;    JSString *str;    JSAtom *prototypeAtom;    if (!JSVAL_IS_STRING(id))        return JS_TRUE;    /* No valid function object should lack private data, but check anyway. */    fun = (JSFunction *) JS_GetPrivate(cx, obj);    if (!fun || !fun->object)        return JS_TRUE;    /* No need to reflect fun.prototype in 'fun.prototype = ...'. */    if (flags & JSRESOLVE_ASSIGNING)        return JS_TRUE;    str = JSVAL_TO_STRING(id);    prototypeAtom = cx->runtime->atomState.classPrototypeAtom;    if (str == ATOM_TO_STRING(prototypeAtom)) {        JSObject *proto;        jsval pval;        proto = NULL;        if (fun->object != obj && fun->object) {            /*             * Clone of a function: make its prototype property value have the             * same class as the clone-parent's prototype.             */            if (!OBJ_GET_PROPERTY(cx, fun->object, (jsid)prototypeAtom, &pval))                return JS_FALSE;            if (JSVAL_IS_OBJECT(pval))                proto = JSVAL_TO_OBJECT(pval);        }        /* If resolving "prototype" in a clone, clone the parent's prototype. */        if (proto) {            proto = js_NewObject(cx, OBJ_GET_CLASS(cx, proto), proto, NULL);        } else {            /*             * Handle the wacky case of a user function Object() -- trying to             * build a prototype for that will recur back here ad perniciem.             */            if (fun->atom != cx->runtime->atomState.ObjectAtom)                proto = js_NewObject(cx, &js_ObjectClass, NULL, NULL);        }        if (!proto)            return JS_FALSE;        /*         * ECMA says that constructor.prototype is DontEnum | DontDelete for         * user-defined functions, but DontEnum | ReadOnly | DontDelete for         * native "system" constructors such as Object or Function.  So lazily         * set the former here in fun_resolve, but eagerly define the latter         * in JS_InitClass, with the right attributes.         */        if (!js_SetClassPrototype(cx, obj, proto, JSPROP_PERMANENT)) {            cx->newborn[GCX_OBJECT] = NULL;            return JS_FALSE;        }        *objp = obj;    }    return JS_TRUE;}