Bug 379566: keywords are no special with get/set getters. r=brendan
authorigor@mir2.org
Tue, 15 May 2007 08:17:14 -0700
changeset 1478 864c627e1594407805f775e0a87389391e659321
parent 1477 36f4f56a7a10d9f64033a8d3198a588ea082adc7
child 1479 8cc10194e16fc4318a7013e5426b456b92dabf6e
push idunknown
push userunknown
push dateunknown
reviewersbrendan
bugs379566
milestone1.9a5pre
Bug 379566: keywords are no special with get/set getters. r=brendan
js/src/jsparse.c
--- a/js/src/jsparse.c
+++ b/js/src/jsparse.c
@@ -5478,44 +5478,48 @@ PrimaryExpr(JSContext *cx, JSTokenStream
                 pn3 = NewParseNode(cx, ts, PN_NULLARY, tc);
                 if (pn3)
                     pn3->pn_dval = CURRENT_TOKEN(ts).t_dval;
                 break;
               case TOK_NAME:
 #if JS_HAS_GETTER_SETTER
                 {
                     JSAtom *atom;
-                    JSRuntime *rt;
 
                     atom = CURRENT_TOKEN(ts).t_atom;
-                    rt = cx->runtime;
-                    if (atom == rt->atomState.getAtom ||
-                        atom == rt->atomState.setAtom) {
-                        op = (atom == rt->atomState.getAtom)
-                            ? JSOP_GETTER
-                            : JSOP_SETTER;
-                        if (js_MatchToken(cx, ts, TOK_NAME)) {
-                            pn3 = NewParseNode(cx, ts, PN_NAME, tc);
-                            if (!pn3)
-                                return NULL;
-                            pn3->pn_atom = CURRENT_TOKEN(ts).t_atom;
-                            pn3->pn_expr = NULL;
-                            pn3->pn_slot = -1;
-                            pn3->pn_attrs = 0;
-
-                            /* We have to fake a 'function' token here. */
-                            CURRENT_TOKEN(ts).t_op = JSOP_NOP;
-                            CURRENT_TOKEN(ts).type = TOK_FUNCTION;
-                            pn2 = FunctionExpr(cx, ts, tc);
-                            pn2 = NewBinary(cx, TOK_COLON, op, pn3, pn2, tc);
-                            goto skip;
-                        }
+                    if (atom == cx->runtime->atomState.getAtom)
+                        op = JSOP_GETTER;
+                    else if (atom == cx->runtime->atomState.setAtom)
+                        op = JSOP_SETTER;
+                    else
+                        goto property_name;
+                        
+                    ts->flags |= TSF_KEYWORD_IS_NAME;
+                    tt = js_GetToken(cx, ts);
+                    ts->flags &= ~TSF_KEYWORD_IS_NAME;
+                    if (tt != TOK_NAME) {
+                        js_UngetToken(ts);
+                        goto property_name;
                     }
-                    /* else fall thru ... */
+                    pn3 = NewParseNode(cx, ts, PN_NAME, tc);
+                    if (!pn3)
+                        return NULL;
+                    pn3->pn_atom = CURRENT_TOKEN(ts).t_atom;
+                    pn3->pn_expr = NULL;
+                    pn3->pn_slot = -1;
+                    pn3->pn_attrs = 0;
+                    
+                    /* We have to fake a 'function' token here. */
+                    CURRENT_TOKEN(ts).t_op = JSOP_NOP;
+                    CURRENT_TOKEN(ts).type = TOK_FUNCTION;
+                    pn2 = FunctionExpr(cx, ts, tc);
+                    pn2 = NewBinary(cx, TOK_COLON, op, pn3, pn2, tc);
+                    goto skip;
                 }
+              property_name:
 #endif
               case TOK_STRING:
                 pn3 = NewParseNode(cx, ts, PN_NULLARY, tc);
                 if (pn3)
                     pn3->pn_atom = CURRENT_TOKEN(ts).t_atom;
                 break;
               case TOK_RC:
                 if (afterComma &&