ida = NULL; if (!OBJ_LOOKUP_PROPERTY(cx, obj, id, &obj2, &prop)) return JS_FALSE; if (!prop) { str = js_DecompileValueGenerator(cx, js_IdToValue(id), NULL); if (str) js_ReportIsNotDefined(cx, JS_GetStringBytes(str)); return JS_FALSE; } ok = OBJ_GET_ATTRIBUTES(cx, obj, id, prop, &attrs); OBJ_DROP_PROPERTY(cx, obj2, prop); if (!ok) return JS_FALSE; if (!(attrs & JSPROP_EXPORTED)) { str = js_DecompileValueGenerator(cx, js_IdToValue(id), NULL); if (str) { JS_ReportError(cx, "%s is not exported", JS_GetStringBytes(str)); } return JS_FALSE; }
ida = NULL; if (!OBJ_LOOKUP_PROPERTY(cx, obj, id, &obj2, &prop)) return JS_FALSE; if (!prop) { str = js_DecompileValueGenerator(cx, js_IdToValue(id), NULL); if (str) js_ReportIsNotDefined(cx, JS_GetStringBytes(str)); return JS_FALSE; } ok = OBJ_GET_ATTRIBUTES(cx, obj, id, prop, &attrs); OBJ_DROP_PROPERTY(cx, obj2, prop); if (!ok) return JS_FALSE; if (!(attrs & JSPROP_EXPORTED)) { str = js_DecompileValueGenerator(cx, js_IdToValue(id), NULL); if (str) { JS_ReportErrorNumber(cx, NULL, JSMSG_NOT_EXPORTED, JS_GetStringBytes(str)); } return JS_FALSE; }
ImportProperty(JSContext *cx, JSObject *obj, jsid id){    JSBool ok;    JSIdArray *ida;    JSProperty *prop;    JSObject *obj2, *target, *funobj, *closure;    JSString *str;    uintN attrs;    jsint i;    JSFunction *fun;    jsval value;    if (JSVAL_IS_VOID(id)) {	ida = JS_Enumerate(cx, obj);	if (!ida)	    return JS_FALSE;	if (ida->length == 0)	    goto out;	ok = JS_TRUE;    } else {	ida = NULL;	if (!OBJ_LOOKUP_PROPERTY(cx, obj, id, &obj2, &prop))	    return JS_FALSE;	if (!prop) {	    str = js_DecompileValueGenerator(cx, js_IdToValue(id), NULL);	    if (str)		js_ReportIsNotDefined(cx, JS_GetStringBytes(str));	    return JS_FALSE;	}	ok = OBJ_GET_ATTRIBUTES(cx, obj, id, prop, &attrs);	OBJ_DROP_PROPERTY(cx, obj2, prop);	if (!ok)	    return JS_FALSE;	if (!(attrs & JSPROP_EXPORTED)) {	    str = js_DecompileValueGenerator(cx, js_IdToValue(id), NULL);	    if (str) {		JS_ReportError(cx, "%s is not exported",			       JS_GetStringBytes(str));	    }	    return JS_FALSE;	}    }    target = js_FindVariableScope(cx, &fun);    if (!target) {	ok = JS_FALSE;	goto out;    }    i = 0;    do {	if (ida) {	    id = ida->vector[i];	    ok = OBJ_GET_ATTRIBUTES(cx, obj, id, NULL, &attrs);	    if (!ok)		goto out;	    if (!(attrs & JSPROP_EXPORTED))	    	continue;	}	ok = OBJ_CHECK_ACCESS(cx, obj, id, JSACC_IMPORT, &value, &attrs);	if (!ok)	    goto out;	if (JSVAL_IS_FUNCTION(cx, value)) {	    funobj = JSVAL_TO_OBJECT(value);	    closure = js_ConstructObject(cx, &js_ClosureClass, funobj, obj);	    if (!closure) {		ok = JS_FALSE;		goto out;	    }            /*             * The Closure() constructor resets the closure object's parent             * to be the current scope chain.  Set it to the object that the             * imported function is being defined in.             */            OBJ_SET_PARENT(cx, closure, obj);	    value = OBJECT_TO_JSVAL(closure);	}        /*         * Handle the case of importing a property that refers to a local         * variable or formal parameter of a function activation.  Those         * properties are accessed by opcodes using stack slot numbers         * generated by the compiler rather than runtime name-lookup. These         * local references, therefore, bypass the normal scope chain lookup.         * So, instead of defining a new property in the activation object,         * modify the existing value in the stack slot.         */        if (OBJ_GET_CLASS(cx, target) == &js_CallClass) {            ok = OBJ_LOOKUP_PROPERTY(cx, target, id, &obj2, &prop);            if (!ok)                goto out;        } else {            prop = NULL;        }        if (prop && (target == obj2)) {            ok = OBJ_SET_PROPERTY(cx, target, id, &value);        } else {            ok = OBJ_DEFINE_PROPERTY(cx, target, id, value, NULL, NULL,                                     attrs & ~JSPROP_EXPORTED,                                     NULL);        }        if (prop)            OBJ_DROP_PROPERTY(cx, obj2, prop);        if (!ok)            goto out;    } while (ida && ++i < ida->length);out:    if (ida)    	JS_DestroyIdArray(cx, ida);    return ok;}