Nit-picks, mainly localizing and initializing the oldAttrs var, on patchwork for bug 599009 (r=bz).

This commit is contained in:
Brendan Eich 2010-10-07 11:33:23 -07:00
Родитель c3c6f4378f
Коммит c4ead6da5c
2 изменённых файлов: 31 добавлений и 31 удалений

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

@ -5379,23 +5379,24 @@ BEGIN_CASE(JSOP_DEFFUN)
bool doSet = false; bool doSet = false;
if (prop) { if (prop) {
JS_ASSERT((attrs == JSPROP_ENUMERATE) == regs.fp->isEvalFrame()); JS_ASSERT((attrs == JSPROP_ENUMERATE) == regs.fp->isEvalFrame());
uint32 old; if (attrs == JSPROP_ENUMERATE || (parent == pobj && parent->isCall())) {
if (attrs == JSPROP_ENUMERATE || JS_ASSERT(pobj->isNative());
(parent == pobj && uintN oldAttrs = ((Shape *) prop)->attributes();
parent->isCall() &&
(old = ((Shape *) prop)->attributes(), if (!(oldAttrs & (JSPROP_GETTER|JSPROP_SETTER)) &&
!(old & (JSPROP_GETTER|JSPROP_SETTER)) && (oldAttrs & (JSPROP_ENUMERATE|JSPROP_PERMANENT)) == attrs) {
(old & (JSPROP_ENUMERATE|JSPROP_PERMANENT)) == attrs))) { /*
/* * js_CheckRedeclaration must reject attempts to add a getter or
* js_CheckRedeclaration must reject attempts to add a getter or * setter to an existing property without a getter or setter.
* setter to an existing property without a getter or setter. */
*/ JS_ASSERT(!(attrs & ~(JSPROP_ENUMERATE|JSPROP_PERMANENT)));
JS_ASSERT(!(attrs & ~(JSPROP_ENUMERATE|JSPROP_PERMANENT))); JS_ASSERT(!(oldAttrs & JSPROP_READONLY));
JS_ASSERT_IF(attrs != JSPROP_ENUMERATE, !(old & JSPROP_READONLY)); doSet = true;
doSet = true; }
} }
pobj->dropProperty(cx, prop); pobj->dropProperty(cx, prop);
} }
Value rval = ObjectValue(*obj); Value rval = ObjectValue(*obj);
ok = doSet ok = doSet
? parent->setProperty(cx, id, &rval, script->strictModeCode) ? parent->setProperty(cx, id, &rval, script->strictModeCode)

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

@ -914,9 +914,6 @@ stubs::DefFun(VMFrame &f, JSFunction *fun)
*/ */
JSObject *parent = &fp->varobj(cx); JSObject *parent = &fp->varobj(cx);
uint32 old;
bool doSet;
/* /*
* Check for a const property of the same name -- or any kind of property * Check for a const property of the same name -- or any kind of property
* if executing with the strict option. We check here at runtime as well * if executing with the strict option. We check here at runtime as well
@ -940,25 +937,27 @@ stubs::DefFun(VMFrame &f, JSFunction *fun)
* setters that store the value of the property in the interpreter frame, * setters that store the value of the property in the interpreter frame,
* see bug 467495. * see bug 467495.
*/ */
doSet = false; bool doSet = false;
if (prop) { if (prop) {
JS_ASSERT((attrs == JSPROP_ENUMERATE) == fp->isEvalFrame()); JS_ASSERT((attrs == JSPROP_ENUMERATE) == fp->isEvalFrame());
if (attrs == JSPROP_ENUMERATE || if (attrs == JSPROP_ENUMERATE || (parent == pobj && parent->isCall())) {
(parent == pobj && JS_ASSERT(pobj->isNative());
parent->isCall() && uintN oldAttrs = ((Shape *) prop)->attributes();
(old = ((Shape *) prop)->attributes(),
!(old & (JSPROP_GETTER|JSPROP_SETTER)) && if (!(oldAttrs & (JSPROP_GETTER|JSPROP_SETTER)) &&
(old & (JSPROP_ENUMERATE|JSPROP_PERMANENT)) == attrs))) { (oldAttrs & (JSPROP_ENUMERATE|JSPROP_PERMANENT)) == attrs) {
/* /*
* js_CheckRedeclaration must reject attempts to add a getter or * js_CheckRedeclaration must reject attempts to add a getter or
* setter to an existing property without a getter or setter. * setter to an existing property without a getter or setter.
*/ */
JS_ASSERT(!(attrs & ~(JSPROP_ENUMERATE|JSPROP_PERMANENT))); JS_ASSERT(!(attrs & ~(JSPROP_ENUMERATE|JSPROP_PERMANENT)));
JS_ASSERT_IF(attrs != JSPROP_ENUMERATE, !(old & JSPROP_READONLY)); JS_ASSERT(!(oldAttrs & JSPROP_READONLY));
doSet = true; doSet = true;
}
} }
pobj->dropProperty(cx, prop); pobj->dropProperty(cx, prop);
} }
Value rval = ObjectValue(*obj); Value rval = ObjectValue(*obj);
ok = doSet ok = doSet
? parent->setProperty(cx, id, &rval, strict) ? parent->setProperty(cx, id, &rval, strict)