Bug 1122209 - Change some uses of LookupProperty to HasProperty. r=evilpie.

--HG--
extra : rebase_source : f56fe7da945b0c08b9cbb9fcf9bb65a277cc1dc2
This commit is contained in:
Jason Orendorff 2014-12-20 10:22:46 -06:00
Родитель 7b38f74598
Коммит a775a5666a
5 изменённых файлов: 19 добавлений и 33 удалений

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

@ -561,16 +561,8 @@ bool
OperatorIn(JSContext *cx, HandleValue key, HandleObject obj, bool *out)
{
RootedId id(cx);
if (!ValueToId<CanGC>(cx, key, &id))
return false;
RootedObject obj2(cx);
RootedShape prop(cx);
if (!LookupProperty(cx, obj, id, &obj2, &prop))
return false;
*out = !!prop;
return true;
return ValueToId<CanGC>(cx, key, &id) &&
HasProperty(cx, obj, id, out);
}
bool

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

@ -179,19 +179,17 @@ DoGetElement(JSContext *cx, HandleObject obj, HandleObject receiver,
if (!ToId(cx, index, &id))
return false;
RootedObject obj2(cx);
RootedShape prop(cx);
if (!LookupProperty(cx, obj, id, &obj2, &prop))
bool found;
if (!HasProperty(cx, obj, id, &found))
return false;
if (!prop) {
vp.setUndefined();
*hole = true;
} else {
if (found) {
if (!GetProperty(cx, obj, receiver, id, vp))
return false;
*hole = false;
} else {
vp.setUndefined();
}
*hole = !found;
return true;
}

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

@ -7371,12 +7371,11 @@ DebuggerEnv_find(JSContext *cx, unsigned argc, Value *vp)
/* This can trigger resolve hooks. */
ErrorCopier ec(ac);
RootedShape prop(cx);
RootedObject pobj(cx);
for (; env && !prop; env = env->enclosingScope()) {
if (!LookupProperty(cx, env, id, &pobj, &prop))
bool found;
for (; env; env = env->enclosingScope()) {
if (!HasProperty(cx, env, id, &found))
return false;
if (prop)
if (found)
break;
}
}

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

@ -1881,15 +1881,12 @@ CASE(JSOP_IN)
obj = &rref.toObject();
RootedId &id = rootId0;
FETCH_ELEMENT_ID(-2, id);
RootedObject &obj2 = rootObject1;
RootedShape &prop = rootShape0;
if (!LookupProperty(cx, obj, id, &obj2, &prop))
bool found;
if (!HasProperty(cx, obj, id, &found))
goto error;
bool cond = prop != nullptr;
prop = nullptr;
TRY_BRANCH_AFTER_COND(cond, 2);
TRY_BRANCH_AFTER_COND(found, 2);
REGS.sp--;
REGS.sp[-1].setBoolean(cond);
REGS.sp[-1].setBoolean(found);
}
END_CASE(JSOP_IN)

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

@ -2149,10 +2149,10 @@ js::NativeSetProperty(JSContext *cx, HandleNativeObject obj, HandleObject receiv
// at all, but they do go through this function. So check for
// unqualified assignment to a nonexistent global (a strict error).
if (!qualified) {
RootedObject pobj(cx);
if (!LookupProperty(cx, proto, id, &pobj, &shape))
bool found;
if (!HasProperty(cx, proto, id, &found))
return false;
if (!shape)
if (!found)
return SetNonexistentProperty(cx, obj, receiver, id, qualified, vp, strict);
}