mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 790247 - Reflect.parse should treat x["y"] as a computed MemberExpression. r=jorendorff.
This commit is contained in:
parent
11a62b651b
commit
f6de4fab9b
@ -5664,22 +5664,24 @@ Parser::memberExpr(bool allowCallSyntax)
|
||||
*/
|
||||
uint32_t index;
|
||||
PropertyName *name = NULL;
|
||||
if (propExpr->isKind(PNK_STRING)) {
|
||||
JSAtom *atom = propExpr->pn_atom;
|
||||
if (atom->isIndex(&index)) {
|
||||
propExpr->setKind(PNK_NUMBER);
|
||||
propExpr->setOp(JSOP_DOUBLE);
|
||||
propExpr->pn_dval = index;
|
||||
} else {
|
||||
name = atom->asPropertyName();
|
||||
}
|
||||
} else if (propExpr->isKind(PNK_NUMBER)) {
|
||||
double number = propExpr->pn_dval;
|
||||
if (number != ToUint32(number)) {
|
||||
JSAtom *atom = ToAtom(context, DoubleValue(number));
|
||||
if (!atom)
|
||||
return NULL;
|
||||
name = atom->asPropertyName();
|
||||
if (foldConstants) {
|
||||
if (propExpr->isKind(PNK_STRING)) {
|
||||
JSAtom *atom = propExpr->pn_atom;
|
||||
if (atom->isIndex(&index)) {
|
||||
propExpr->setKind(PNK_NUMBER);
|
||||
propExpr->setOp(JSOP_DOUBLE);
|
||||
propExpr->pn_dval = index;
|
||||
} else {
|
||||
name = atom->asPropertyName();
|
||||
}
|
||||
} else if (propExpr->isKind(PNK_NUMBER)) {
|
||||
double number = propExpr->pn_dval;
|
||||
if (number != ToUint32(number)) {
|
||||
JSAtom *atom = ToAtom(context, DoubleValue(number));
|
||||
if (!atom)
|
||||
return NULL;
|
||||
name = atom->asPropertyName();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -261,6 +261,8 @@ assertExpr("this", thisExpr);
|
||||
assertExpr("foo", ident("foo"));
|
||||
assertExpr("foo.bar", dotExpr(ident("foo"), ident("bar")));
|
||||
assertExpr("foo[bar]", memExpr(ident("foo"), ident("bar")));
|
||||
assertExpr("foo['bar']", memExpr(ident("foo"), lit("bar")));
|
||||
assertExpr("foo[42]", memExpr(ident("foo"), lit(42)));
|
||||
assertExpr("(function(){})", funExpr(null, [], blockStmt([])));
|
||||
assertExpr("(function f() {})", funExpr(ident("f"), [], blockStmt([])));
|
||||
assertExpr("(function f(x,y,z) {})", funExpr(ident("f"), [ident("x"),ident("y"),ident("z")], blockStmt([])));
|
||||
|
Loading…
Reference in New Issue
Block a user