Bug 769132 - Add a receiver argument to all the set-property APIs. r=luke

This commit is contained in:
Jeff Walden 2012-06-27 20:21:39 -07:00
Родитель c21829def3
Коммит 48d3ba0aaf
18 изменённых файлов: 99 добавлений и 95 удалений

Просмотреть файл

@ -4161,25 +4161,28 @@ JS_GetMethod(JSContext *cx, JSObject *obj, const char *name, JSObject **objp, js
}
JS_PUBLIC_API(JSBool)
JS_SetPropertyById(JSContext *cx, JSObject *obj, jsid id_, jsval *vp)
JS_SetPropertyById(JSContext *cx, JSObject *objArg, jsid id_, jsval *vp)
{
RootedId id(cx, id_);
Rooted<JSObject*> obj(cx, objArg);
AssertNoGC(cx);
CHECK_REQUEST(cx);
assertSameCompartment(cx, obj, id);
JSAutoResolveFlags rf(cx, JSRESOLVE_QUALIFIED | JSRESOLVE_ASSIGNING);
return obj->setGeneric(cx, id, vp, false);
return obj->setGeneric(cx, obj, id, vp, false);
}
JS_PUBLIC_API(JSBool)
JS_SetElement(JSContext *cx, JSObject *obj, uint32_t index, jsval *vp)
JS_SetElement(JSContext *cx, JSObject *obj_, uint32_t index, jsval *vp)
{
RootedObject obj(cx, obj_);
AssertNoGC(cx);
CHECK_REQUEST(cx);
assertSameCompartment(cx, obj, *vp);
JSAutoResolveFlags rf(cx, JSRESOLVE_QUALIFIED | JSRESOLVE_ASSIGNING);
return obj->setElement(cx, index, vp, false);
return obj->setElement(cx, obj, index, vp, false);
}
JS_PUBLIC_API(JSBool)

Просмотреть файл

@ -486,7 +486,7 @@ SetArrayElement(JSContext *cx, HandleObject obj, double index, const Value &v)
JS_ASSERT(!JSID_IS_VOID(id));
RootedValue tmp(cx, v);
return obj->setGeneric(cx, id, tmp.address(), true);
return obj->setGeneric(cx, obj, id, tmp.address(), true);
}
/*
@ -549,12 +549,13 @@ SetOrDeleteArrayElement(JSContext *cx, HandleObject obj, double index,
}
JSBool
js_SetLengthProperty(JSContext *cx, JSObject *obj, double length)
js_SetLengthProperty(JSContext *cx, JSObject *objArg, double length)
{
Value v = NumberValue(length);
/* We don't support read-only array length yet. */
return obj->setProperty(cx, cx->runtime->atomState.lengthAtom, &v, false);
Rooted<JSObject*> obj(cx, objArg);
return obj->setProperty(cx, obj, cx->runtime->atomState.lengthAtom, &v, false);
}
/*
@ -874,7 +875,7 @@ array_setGeneric(JSContext *cx, HandleObject obj, HandleId id, Value *vp, JSBool
return array_length_setter(cx, obj, id, strict, vp);
if (!obj->isDenseArray())
return baseops::SetPropertyHelper(cx, obj, id, 0, vp, strict);
return baseops::SetPropertyHelper(cx, obj, obj, id, 0, vp, strict);
do {
uint32_t i;
@ -899,7 +900,7 @@ array_setGeneric(JSContext *cx, HandleObject obj, HandleId id, Value *vp, JSBool
if (!JSObject::makeDenseArraySlow(cx, obj))
return false;
return baseops::SetPropertyHelper(cx, obj, id, 0, vp, strict);
return baseops::SetPropertyHelper(cx, obj, obj, id, 0, vp, strict);
}
static JSBool
@ -917,7 +918,7 @@ array_setElement(JSContext *cx, HandleObject obj, uint32_t index, Value *vp, JSB
return false;
if (!obj->isDenseArray())
return baseops::SetPropertyHelper(cx, obj, id, 0, vp, strict);
return baseops::SetPropertyHelper(cx, obj, obj, id, 0, vp, strict);
do {
/*
@ -945,7 +946,7 @@ array_setElement(JSContext *cx, HandleObject obj, uint32_t index, Value *vp, JSB
if (!JSObject::makeDenseArraySlow(cx, obj))
return false;
return baseops::SetPropertyHelper(cx, obj, id, 0, vp, strict);
return baseops::SetPropertyHelper(cx, obj, obj, id, 0, vp, strict);
}
static JSBool
@ -1798,7 +1799,7 @@ InitArrayElements(JSContext *cx, HandleObject obj, uint32_t start, uint32_t coun
do {
value = *vector++;
if (!ValueToId(cx, idval, id.address()) ||
!obj->setGeneric(cx, id, value.address(), true)) {
!obj->setGeneric(cx, obj, id, value.address(), true)) {
return false;
}
idval.getDoubleRef() += 1;

Просмотреть файл

@ -2415,7 +2415,7 @@ BEGIN_CASE(JSOP_ENUMELEM)
RootedId &id = rootId0;
FETCH_ELEMENT_ID(obj, -1, id);
rval = regs.sp[-3];
if (!obj->setGeneric(cx, id, rval.address(), script->strictModeCode))
if (!obj->setGeneric(cx, obj, id, rval.address(), script->strictModeCode))
goto error;
regs.sp -= 3;
}
@ -2965,7 +2965,7 @@ BEGIN_CASE(JSOP_DEFFUN)
*/
/* Step 5f. */
if (!parent->setProperty(cx, name, rval.address(), script->strictModeCode))
if (!parent->setProperty(cx, parent, name, rval.address(), script->strictModeCode))
goto error;
} while (false);
}
@ -3172,7 +3172,7 @@ BEGIN_CASE(JSOP_INITPROP)
id = NameToId(name);
if (JS_UNLIKELY(name == cx->runtime->atomState.protoAtom)
? !baseops::SetPropertyHelper(cx, obj, id, 0, &rval, script->strictModeCode)
? !baseops::SetPropertyHelper(cx, obj, obj, id, 0, &rval, script->strictModeCode)
: !DefineNativeProperty(cx, obj, id, rval, NULL, NULL,
JSPROP_ENUMERATE, 0, 0, 0)) {
goto error;
@ -3491,11 +3491,11 @@ BEGIN_CASE(JSOP_SETXMLNAME)
{
JS_ASSERT(!script->strictModeCode);
JSObject *obj = &regs.sp[-3].toObject();
Rooted<JSObject*> obj(cx, &regs.sp[-3].toObject());
Value rval = regs.sp[-1];
RootedId &id = rootId0;
FETCH_ELEMENT_ID(obj, -2, id);
if (!obj->setGeneric(cx, id, &rval, script->strictModeCode))
if (!obj->setGeneric(cx, obj, id, &rval, script->strictModeCode))
goto error;
rval = regs.sp[-1];
regs.sp -= 2;

Просмотреть файл

@ -328,7 +328,7 @@ SetPropertyOperation(JSContext *cx, jsbytecode *pc, const Value &lval, const Val
} else {
RootedValue rref(cx, rval);
bool strict = cx->stack.currentScript()->strictModeCode;
if (!js_NativeSet(cx, obj, shape, false, strict, rref.address()))
if (!js_NativeSet(cx, obj, obj, shape, false, strict, rref.address()))
return false;
}
return true;
@ -347,10 +347,10 @@ SetPropertyOperation(JSContext *cx, jsbytecode *pc, const Value &lval, const Val
unsigned defineHow = (op == JSOP_SETNAME)
? DNP_CACHE_RESULT | DNP_UNQUALIFIED
: DNP_CACHE_RESULT;
if (!baseops::SetPropertyHelper(cx, obj, id, defineHow, rref.address(), strict))
if (!baseops::SetPropertyHelper(cx, obj, obj, id, defineHow, rref.address(), strict))
return false;
} else {
if (!obj->setGeneric(cx, id, rref.address(), strict))
if (!obj->setGeneric(cx, obj, id, rref.address(), strict))
return false;
}
@ -743,7 +743,7 @@ GetElementOperation(JSContext *cx, JSOp op, Value &lref, const Value &rref, Valu
}
static JS_ALWAYS_INLINE bool
SetObjectElementOperation(JSContext *cx, JSObject *obj, HandleId id, const Value &value, bool strict)
SetObjectElementOperation(JSContext *cx, Handle<JSObject*> obj, HandleId id, const Value &value, bool strict)
{
types::TypeScript::MonitorAssign(cx, obj, id);
@ -772,7 +772,7 @@ SetObjectElementOperation(JSContext *cx, JSObject *obj, HandleId id, const Value
} while (0);
RootedValue tmp(cx, value);
return obj->setGeneric(cx, id, tmp.address(), strict);
return obj->setGeneric(cx, obj, id, tmp.address(), strict);
}
#define RELATIONAL_OP(OP) \

Просмотреть файл

@ -5025,8 +5025,8 @@ js_NativeGet(JSContext *cx, Handle<JSObject*> obj, Handle<JSObject*> pobj, const
}
JSBool
js_NativeSet(JSContext *cx, Handle<JSObject*> obj, const Shape *shape, bool added, bool strict,
Value *vp)
js_NativeSet(JSContext *cx, Handle<JSObject*> obj, Handle<JSObject*> receiver,
const Shape *shape, bool added, bool strict, Value *vp)
{
AddTypePropertyId(cx, obj, shape->propid(), *vp);
@ -5054,7 +5054,7 @@ js_NativeSet(JSContext *cx, Handle<JSObject*> obj, const Shape *shape, bool adde
Rooted<const Shape *> shapeRoot(cx, shape);
int32_t sample = cx->runtime->propertyRemovals;
if (!shapeRoot->set(cx, obj, strict, vp))
if (!shapeRoot->set(cx, obj, receiver, strict, vp))
return false;
/*
@ -5278,8 +5278,8 @@ JSObject::callMethod(JSContext *cx, HandleId id, unsigned argc, Value *argv, Val
}
JSBool
baseops::SetPropertyHelper(JSContext *cx, HandleObject obj, HandleId id, unsigned defineHow,
Value *vp, JSBool strict)
baseops::SetPropertyHelper(JSContext *cx, HandleObject obj, HandleObject receiver, HandleId id,
unsigned defineHow, Value *vp, JSBool strict)
{
JSObject *pobj;
JSProperty *prop;
@ -5310,7 +5310,8 @@ baseops::SetPropertyHelper(JSContext *cx, HandleObject obj, HandleId id, unsigne
if ((pd.attrs & (JSPROP_SHARED | JSPROP_SHADOWABLE)) == JSPROP_SHARED) {
return !pd.setter ||
CallSetter(cx, obj, id, pd.setter, pd.attrs, pd.shortid, strict, vp);
CallSetter(cx, receiver, id, pd.setter, pd.attrs, pd.shortid, strict,
vp);
}
if (pd.attrs & JSPROP_READONLY) {
@ -5378,7 +5379,7 @@ baseops::SetPropertyHelper(JSContext *cx, HandleObject obj, HandleId id, unsigne
if (shape->hasDefaultSetter() && !shape->hasGetterValue())
return JS_TRUE;
return shape->set(cx, obj, strict, vp);
return shape->set(cx, obj, receiver, strict, vp);
}
/*
@ -5459,17 +5460,17 @@ baseops::SetPropertyHelper(JSContext *cx, HandleObject obj, HandleId id, unsigne
if ((defineHow & DNP_CACHE_RESULT) && !added)
JS_PROPERTY_CACHE(cx).fill(cx, obj, 0, obj, shape);
return js_NativeSet(cx, obj, shape, added, strict, vp);
return js_NativeSet(cx, obj, receiver, shape, added, strict, vp);
}
JSBool
baseops::SetElementHelper(JSContext *cx, HandleObject obj, uint32_t index, unsigned defineHow,
Value *vp, JSBool strict)
baseops::SetElementHelper(JSContext *cx, HandleObject obj, HandleObject receiver, uint32_t index,
unsigned defineHow, Value *vp, JSBool strict)
{
RootedId id(cx);
if (!IndexToId(cx, index, id.address()))
return false;
return baseops::SetPropertyHelper(cx, obj, id, defineHow, vp, strict);
return baseops::SetPropertyHelper(cx, obj, receiver, id, defineHow, vp, strict);
}
JSBool

Просмотреть файл

@ -151,20 +151,20 @@ extern JSBool
GetPropertyDefault(JSContext *cx, HandleObject obj, HandleId id, const Value &def, Value *vp);
extern JSBool
SetPropertyHelper(JSContext *cx, HandleObject obj, HandleId id, unsigned defineHow,
Value *vp, JSBool strict);
SetPropertyHelper(JSContext *cx, HandleObject obj, HandleObject receiver, HandleId id,
unsigned defineHow, Value *vp, JSBool strict);
inline bool
SetPropertyHelper(JSContext *cx, HandleObject obj, PropertyName *name, unsigned defineHow,
Value *vp, JSBool strict)
SetPropertyHelper(JSContext *cx, HandleObject obj, HandleObject receiver, PropertyName *name,
unsigned defineHow, Value *vp, JSBool strict)
{
Rooted<jsid> id(cx, NameToId(name));
return SetPropertyHelper(cx, obj, id, defineHow, vp, strict);
return SetPropertyHelper(cx, obj, receiver, id, defineHow, vp, strict);
}
extern JSBool
SetElementHelper(JSContext *cx, HandleObject obj, uint32_t index, unsigned defineHow,
Value *vp, JSBool strict);
SetElementHelper(JSContext *cx, HandleObject obj, HandleObject Receiver, uint32_t index,
unsigned defineHow, Value *vp, JSBool strict);
extern JSType
TypeOf(JSContext *cx, HandleObject obj);
@ -825,10 +825,14 @@ struct JSObject : public js::ObjectImpl
inline JSBool getElement(JSContext *cx, uint32_t index, js::Value *vp);
inline JSBool getSpecial(JSContext *cx, js::SpecialId sid, js::Value *vp);
inline JSBool setGeneric(JSContext *cx, js::HandleId id, js::Value *vp, JSBool strict);
inline JSBool setProperty(JSContext *cx, js::PropertyName *name, js::Value *vp, JSBool strict);
inline JSBool setElement(JSContext *cx, uint32_t index, js::Value *vp, JSBool strict);
inline JSBool setSpecial(JSContext *cx, js::SpecialId sid, js::Value *vp, JSBool strict);
inline JSBool setGeneric(JSContext *cx, js::Handle<JSObject*> receiver, js::HandleId id,
js::Value *vp, JSBool strict);
inline JSBool setProperty(JSContext *cx, js::Handle<JSObject*> receiver,
js::PropertyName *name, js::Value *vp, JSBool strict);
inline JSBool setElement(JSContext *cx, js::Handle<JSObject*> receiver, uint32_t index,
js::Value *vp, JSBool strict);
inline JSBool setSpecial(JSContext *cx, js::Handle<JSObject*> receiver, js::SpecialId sid,
js::Value *vp, JSBool strict);
JSBool nonNativeSetProperty(JSContext *cx, js::HandleId id, js::Value *vp, JSBool strict);
JSBool nonNativeSetElement(JSContext *cx, uint32_t index, js::Value *vp, JSBool strict);
@ -1236,8 +1240,8 @@ js_NativeGet(JSContext *cx, js::Handle<JSObject*> obj, js::Handle<JSObject*> pob
const js::Shape *shape, unsigned getHow, js::Value *vp);
extern JSBool
js_NativeSet(JSContext *cx, js::Handle<JSObject*> obj, const js::Shape *shape, bool added,
bool strict, js::Value *vp);
js_NativeSet(JSContext *cx, js::Handle<JSObject*> obj, js::Handle<JSObject*> receiver,
const js::Shape *shape, bool added, bool strict, js::Value *vp);
namespace js {

Просмотреть файл

@ -91,35 +91,39 @@ JSObject::thisObject(JSContext *cx)
}
inline JSBool
JSObject::setGeneric(JSContext *cx, js::HandleId id, js::Value *vp, JSBool strict)
JSObject::setGeneric(JSContext *cx, js::Handle<JSObject*> receiver, js::HandleId id, js::Value *vp,
JSBool strict)
{
if (getOps()->setGeneric)
return nonNativeSetProperty(cx, id, vp, strict);
js::Rooted<JSObject*> obj(cx, this);
return js::baseops::SetPropertyHelper(cx, obj, id, 0, vp, strict);
return js::baseops::SetPropertyHelper(cx, obj, receiver, id, 0, vp, strict);
}
inline JSBool
JSObject::setProperty(JSContext *cx, js::PropertyName *name, js::Value *vp, JSBool strict)
JSObject::setProperty(JSContext *cx, js::Handle<JSObject*> receiver, js::PropertyName *name,
js::Value *vp, JSBool strict)
{
js::Rooted<jsid> id(cx, js::NameToId(name));
return setGeneric(cx, id, vp, strict);
return setGeneric(cx, receiver, id, vp, strict);
}
inline JSBool
JSObject::setElement(JSContext *cx, uint32_t index, js::Value *vp, JSBool strict)
JSObject::setElement(JSContext *cx, js::Handle<JSObject*> receiver, uint32_t index, js::Value *vp,
JSBool strict)
{
if (getOps()->setElement)
return nonNativeSetElement(cx, index, vp, strict);
js::Rooted<JSObject*> obj(cx, this);
return js::baseops::SetElementHelper(cx, obj, index, 0, vp, strict);
return js::baseops::SetElementHelper(cx, obj, receiver, index, 0, vp, strict);
}
inline JSBool
JSObject::setSpecial(JSContext *cx, js::SpecialId sid, js::Value *vp, JSBool strict)
JSObject::setSpecial(JSContext *cx, js::HandleObject receiver, js::SpecialId sid, js::Value *vp,
JSBool strict)
{
js::Rooted<jsid> id(cx, SPECIALID_TO_JSID(sid));
return setGeneric(cx, id, vp, strict);
return setGeneric(cx, receiver, id, vp, strict);
}
inline JSBool

Просмотреть файл

@ -569,11 +569,12 @@ DirectProxyHandler::get(JSContext *cx, JSObject *proxy, JSObject *receiver_,
}
bool
DirectProxyHandler::set(JSContext *cx, JSObject *proxy, JSObject *receiver,
DirectProxyHandler::set(JSContext *cx, JSObject *proxy, JSObject *receiverArg,
jsid id_, bool strict, Value *vp)
{
RootedId id(cx, id_);
return GetProxyTargetObject(proxy)->setGeneric(cx, id, vp, strict);
Rooted<JSObject*> receiver(cx, receiverArg);
return GetProxyTargetObject(proxy)->setGeneric(cx, receiver, id, vp, strict);
}
bool

Просмотреть файл

@ -641,7 +641,7 @@ NodeBuilder::newArray(NodeVector &elts, Value *dst)
js_ReportAllocationOverflow(cx);
return false;
}
JSObject *array = NewDenseAllocatedArray(cx, uint32_t(len));
Rooted<JSObject*> array(cx, NewDenseAllocatedArray(cx, uint32_t(len)));
if (!array)
return false;
@ -654,7 +654,7 @@ NodeBuilder::newArray(NodeVector &elts, Value *dst)
if (val.isMagic(JS_SERIALIZE_NO_NODE))
continue;
if (!array->setElement(cx, i, &val, false))
if (!array->setElement(cx, array, i, &val, false))
return false;
}

Просмотреть файл

@ -701,7 +701,7 @@ struct Shape : public js::gc::Cell
int ashortid) const;
bool get(JSContext* cx, HandleObject receiver, JSObject *obj, JSObject *pobj, js::Value* vp) const;
bool set(JSContext* cx, HandleObject obj, bool strict, js::Value* vp) const;
bool set(JSContext* cx, HandleObject obj, HandleObject receiver, bool strict, js::Value* vp) const;
BaseShape *base() const { return base_; }

Просмотреть файл

@ -283,13 +283,13 @@ Shape::get(JSContext* cx, HandleObject receiver, JSObject* obj, JSObject *pobj,
}
inline bool
Shape::set(JSContext* cx, HandleObject obj, bool strict, Value* vp) const
Shape::set(JSContext* cx, HandleObject obj, HandleObject receiver, bool strict, Value* vp) const
{
JS_ASSERT_IF(hasDefaultSetter(), hasGetterValue());
if (attrs & JSPROP_SETTER) {
Value fval = setterValue();
return InvokeGetterOrSetter(cx, obj, fval, 1, vp, vp);
return InvokeGetterOrSetter(cx, receiver, fval, 1, vp, vp);
}
if (attrs & JSPROP_GETTER)

Просмотреть файл

@ -546,7 +546,7 @@ ArrayBufferObject::obj_setGeneric(JSContext *cx, HandleObject obj, HandleId id,
RootedObject oldDelegateProto(cx, delegate->getProto());
if (!baseops::SetPropertyHelper(cx, delegate, id, 0, vp, strict))
if (!baseops::SetPropertyHelper(cx, delegate, delegate, id, 0, vp, strict))
return false;
if (delegate->getProto() != oldDelegateProto) {
@ -567,7 +567,7 @@ ArrayBufferObject::obj_setGeneric(JSContext *cx, HandleObject obj, HandleId id,
return true;
}
return baseops::SetPropertyHelper(cx, delegate, id, 0, vp, strict);
return baseops::SetPropertyHelper(cx, delegate, obj, id, 0, vp, strict);
}
JSBool
@ -586,7 +586,7 @@ ArrayBufferObject::obj_setElement(JSContext *cx, HandleObject obj,
if (!delegate)
return false;
return baseops::SetElementHelper(cx, delegate, index, 0, vp, strict);
return baseops::SetElementHelper(cx, delegate, obj, index, 0, vp, strict);
}
JSBool

Просмотреть файл

@ -4217,7 +4217,7 @@ PutProperty(JSContext *cx, HandleObject obj_, HandleId id_, JSBool strict, jsval
if (!nameqn)
goto bad;
if (!JSID_IS_VOID(funid)) {
ok = baseops::SetPropertyHelper(cx, obj, funid, 0, vp, false);
ok = baseops::SetPropertyHelper(cx, obj, obj, funid, 0, vp, false);
goto out;
}
nameobj = nameqn;
@ -6068,7 +6068,7 @@ FindInScopeNamespaces(JSContext *cx, JSXML *xml, JSXMLArray<JSObject> *nsarray)
static bool
NamespacesToJSArray(JSContext *cx, JSXMLArray<JSObject> *array, jsval *rval)
{
JSObject *arrayobj = NewDenseEmptyArray(cx);
Rooted<JSObject*> arrayobj(cx, NewDenseEmptyArray(cx));
if (!arrayobj)
return false;
*rval = OBJECT_TO_JSVAL(arrayobj);
@ -6079,7 +6079,7 @@ NamespacesToJSArray(JSContext *cx, JSXMLArray<JSObject> *array, jsval *rval)
if (!ns)
continue;
tvr.set(ObjectValue(*ns));
if (!arrayobj->setElement(cx, i, tvr.addr(), false))
if (!arrayobj->setElement(cx, arrayobj, i, tvr.addr(), false))
return false;
}
return true;

Просмотреть файл

@ -29,19 +29,6 @@ ReportAtomNotDefined(JSContext *cx, JSAtom *atom)
js_ReportIsNotDefined(cx, printable.ptr());
}
#define NATIVE_SET(cx,obj,shape,entry,strict,vp) \
JS_BEGIN_MACRO \
if (shape->hasDefaultSetter() && \
(shape)->hasSlot() && \
!(shape)->isMethod()) { \
/* Fast path for, e.g., plain Object instance properties. */ \
(obj)->nativeSetSlotWithType(cx, shape, *vp); \
} else { \
if (!js_NativeSet(cx, obj, shape, false, strict, vp)) \
THROW(); \
} \
JS_END_MACRO
#define NATIVE_GET(cx,obj,pobj,shape,getHow,vp,onerr) \
JS_BEGIN_MACRO \
if (shape->isDataDescriptor() && shape->hasDefaultGetter()) { \

Просмотреть файл

@ -125,10 +125,9 @@ stubs::SetElem(VMFrame &f)
Value &idval = regs.sp[-2];
Value rval = regs.sp[-1];
JSObject *obj;
RootedId id(cx);
obj = ValueToObject(cx, objval);
Rooted<JSObject*> obj(cx, ValueToObject(cx, objval));
if (!obj)
THROW();
@ -156,7 +155,7 @@ stubs::SetElem(VMFrame &f)
}
}
} while (0);
if (!obj->setGeneric(cx, id, &rval, strict))
if (!obj->setGeneric(cx, obj, id, &rval, strict))
THROW();
end_setelem:
/* :FIXME: Moving the assigned object into the lowest stack slot
@ -335,7 +334,7 @@ stubs::DefFun(VMFrame &f, JSFunction *fun_)
* current scope chain even for the case of function expression statements
* and functions defined by eval inside let or with blocks.
*/
JSObject *parent = &fp->varObj();
Rooted<JSObject*> parent(cx, &fp->varObj());
/* ES5 10.5 (NB: with subsequent errata). */
PropertyName *name = fun->atom->asPropertyName();
@ -388,7 +387,7 @@ stubs::DefFun(VMFrame &f, JSFunction *fun_)
*/
/* Step 5f. */
if (!parent->setProperty(cx, name, &rval, strict))
if (!parent->setProperty(cx, parent, name, &rval, strict))
THROW();
} while (false);
}
@ -1035,7 +1034,7 @@ InitPropOrMethod(VMFrame &f, PropertyName *name, JSOp op)
RootedId id(cx, NameToId(name));
if (JS_UNLIKELY(name == cx->runtime->atomState.protoAtom)
? !baseops::SetPropertyHelper(cx, obj, id, 0, &rval, false)
? !baseops::SetPropertyHelper(cx, obj, obj, id, 0, &rval, false)
: !DefineNativeProperty(cx, obj, id, rval, NULL, NULL,
JSPROP_ENUMERATE, 0, 0, 0)) {
THROW();

Просмотреть файл

@ -316,7 +316,7 @@ StrictArgSetter(JSContext *cx, HandleObject obj, HandleId id, JSBool strict, Val
*/
RootedValue value(cx);
return baseops::DeleteGeneric(cx, argsobj, id, value.address(), strict) &&
baseops::SetPropertyHelper(cx, argsobj, id, 0, vp, strict);
baseops::SetPropertyHelper(cx, argsobj, argsobj, id, 0, vp, strict);
}
static JSBool

Просмотреть файл

@ -4490,7 +4490,7 @@ DebuggerEnv_setVariable(JSContext *cx, unsigned argc, Value *vp)
}
/* Just set the property. */
if (!env->setGeneric(cx, id, v.address(), true))
if (!env->setGeneric(cx, env, id, v.address(), true))
return false;
}

Просмотреть файл

@ -411,25 +411,29 @@ with_GetSpecial(JSContext *cx, HandleObject obj, HandleObject receiver, HandleSp
static JSBool
with_SetGeneric(JSContext *cx, HandleObject obj, HandleId id, Value *vp, JSBool strict)
{
return obj->asWith().object().setGeneric(cx, id, vp, strict);
Rooted<JSObject*> actual(cx, &obj->asWith().object());
return actual->setGeneric(cx, actual, id, vp, strict);
}
static JSBool
with_SetProperty(JSContext *cx, HandleObject obj, HandlePropertyName name, Value *vp, JSBool strict)
{
return obj->asWith().object().setProperty(cx, name, vp, strict);
Rooted<JSObject*> actual(cx, &obj->asWith().object());
return actual->setProperty(cx, actual, name, vp, strict);
}
static JSBool
with_SetElement(JSContext *cx, HandleObject obj, uint32_t index, Value *vp, JSBool strict)
{
return obj->asWith().object().setElement(cx, index, vp, strict);
Rooted<JSObject*> actual(cx, &obj->asWith().object());
return actual->setElement(cx, actual, index, vp, strict);
}
static JSBool
with_SetSpecial(JSContext *cx, HandleObject obj, HandleSpecialId sid, Value *vp, JSBool strict)
{
return obj->asWith().object().setSpecial(cx, sid, vp, strict);
Rooted<JSObject*> actual(cx, &obj->asWith().object());
return actual->setSpecial(cx, actual, sid, vp, strict);
}
static JSBool
@ -1342,13 +1346,13 @@ class DebugScopeProxy : public BaseProxyHandler
bool set(JSContext *cx, JSObject *proxy, JSObject *receiver, jsid id_, bool strict,
Value *vp) MOZ_OVERRIDE
{
ScopeObject &scope = proxy->asDebugScope().scope();
Rooted<ScopeObject*> scope(cx, &proxy->asDebugScope().scope());
if (handleUnaliasedAccess(cx, scope, id_, SET, vp))
if (handleUnaliasedAccess(cx, *scope, id_, SET, vp))
return true;
Rooted<jsid> id(cx, id_);
return scope.setGeneric(cx, id, vp, strict);
return scope->setGeneric(cx, scope, id, vp, strict);
}
bool defineProperty(JSContext *cx, JSObject *proxy, jsid id, PropertyDescriptor *desc) MOZ_OVERRIDE