From 723812d679ea309d46ca34a98837efb2187daa97 Mon Sep 17 00:00:00 2001 From: Shu-yu Guo Date: Thu, 12 Jun 2014 00:27:46 -0700 Subject: [PATCH] Bug 1023686 - Fix JSOP of definition nodes of non-hoisted declarations. (r=luke) --- js/src/frontend/BytecodeEmitter.cpp | 2 +- js/src/frontend/Parser.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/js/src/frontend/BytecodeEmitter.cpp b/js/src/frontend/BytecodeEmitter.cpp index a4b0f1f6f835..44798959b1c0 100644 --- a/js/src/frontend/BytecodeEmitter.cpp +++ b/js/src/frontend/BytecodeEmitter.cpp @@ -3061,7 +3061,7 @@ EmitDestructuringLHS(ExclusiveContext *cx, BytecodeEmitter *bce, ParseNode *pn, } else if (emitOption == PushInitialValues) { // The lhs is a simple name so the to-be-destructured value is // its initial value and there is nothing to do. - JS_ASSERT(pn->getOp() == JSOP_GETLOCAL); + JS_ASSERT(pn->getOp() == JSOP_SETLOCAL); JS_ASSERT(pn->pn_dflags & PND_BOUND); } else { switch (pn->getKind()) { diff --git a/js/src/frontend/Parser.cpp b/js/src/frontend/Parser.cpp index 18a69415997a..278a0530805b 100644 --- a/js/src/frontend/Parser.cpp +++ b/js/src/frontend/Parser.cpp @@ -150,7 +150,7 @@ ParseContext::define(TokenStream &ts, switch (kind) { case Definition::ARG: JS_ASSERT(sc->isFunctionBox()); - dn->setOp(JSOP_GETARG); + dn->setOp((js_CodeSpec[dn->getOp()].format & JOF_SET) ? JSOP_SETARG : JSOP_GETARG); dn->pn_dflags |= PND_BOUND; if (!dn->pn_cookie.set(ts, staticLevel, args_.length())) return false; @@ -169,7 +169,7 @@ ParseContext::define(TokenStream &ts, case Definition::CONST: case Definition::VAR: if (sc->isFunctionBox()) { - dn->setOp(JSOP_GETLOCAL); + dn->setOp((js_CodeSpec[dn->getOp()].format & JOF_SET) ? JSOP_SETLOCAL : JSOP_GETLOCAL); dn->pn_dflags |= PND_BOUND; if (!dn->pn_cookie.set(ts, staticLevel, vars_.length())) return false; @@ -185,7 +185,7 @@ ParseContext::define(TokenStream &ts, break; case Definition::LET: - dn->setOp(JSOP_GETLOCAL); + dn->setOp((js_CodeSpec[dn->getOp()].format & JOF_SET) ? JSOP_SETLOCAL : JSOP_GETLOCAL); dn->pn_dflags |= (PND_LET | PND_BOUND); JS_ASSERT(dn->pn_cookie.level() == staticLevel); /* see bindLet */ if (!decls_.addShadow(name, dn))