| Index: src/parser.cc
|
| ===================================================================
|
| --- src/parser.cc (revision 5181)
|
| +++ src/parser.cc (working copy)
|
| @@ -265,7 +265,6 @@
|
| Literal* GetLiteralNumber(double value);
|
|
|
| Handle<String> ParseIdentifier(bool* ok);
|
| - Handle<String> ParseIdentifierName(bool* ok);
|
| Handle<String> ParseIdentifierOrGetOrSet(bool* is_get,
|
| bool* is_set,
|
| bool* ok);
|
| @@ -3122,7 +3121,7 @@
|
| case Token::PERIOD: {
|
| Consume(Token::PERIOD);
|
| int pos = scanner().location().beg_pos;
|
| - Handle<String> name = ParseIdentifierName(CHECK_OK);
|
| + Handle<String> name = ParseIdentifier(CHECK_OK);
|
| result = factory()->NewProperty(result, NEW(Literal(name)), pos);
|
| break;
|
| }
|
| @@ -3208,7 +3207,7 @@
|
| case Token::PERIOD: {
|
| Consume(Token::PERIOD);
|
| int pos = scanner().location().beg_pos;
|
| - Handle<String> name = ParseIdentifierName(CHECK_OK);
|
| + Handle<String> name = ParseIdentifier(CHECK_OK);
|
| result = factory()->NewProperty(result, NEW(Literal(name)), pos);
|
| break;
|
| }
|
| @@ -3587,8 +3586,8 @@
|
| Expression* Parser::ParseObjectLiteral(bool* ok) {
|
| // ObjectLiteral ::
|
| // '{' (
|
| - // ((IdentifierName | String | Number) ':' AssignmentExpression)
|
| - // | (('get' | 'set') (IdentifierName | String | Number) FunctionLiteral)
|
| + // ((Identifier | String | Number) ':' AssignmentExpression)
|
| + // | (('get' | 'set') FunctionLiteral)
|
| // )*[','] '}'
|
|
|
| ZoneListWrapper<ObjectLiteral::Property> properties =
|
| @@ -3598,8 +3597,7 @@
|
| Expect(Token::LBRACE, CHECK_OK);
|
| while (peek() != Token::RBRACE) {
|
| Literal* key = NULL;
|
| - Token::Value next = peek();
|
| - switch (next) {
|
| + switch (peek()) {
|
| case Token::IDENTIFIER: {
|
| // Store identifier keys as literal symbols to avoid
|
| // resolving them when compiling code for the object
|
| @@ -3610,26 +3608,15 @@
|
| ParseIdentifierOrGetOrSet(&is_getter, &is_setter, CHECK_OK);
|
| if (is_getter || is_setter) {
|
| // Special handling of getter and setter syntax.
|
| - Handle<String> name;
|
| - next = peek();
|
| - if (next == Token::IDENTIFIER ||
|
| - next == Token::STRING ||
|
| - next == Token::NUMBER ||
|
| - Token::IsKeyword(next)) {
|
| - Consume(next);
|
| - Handle<String> name =
|
| - factory()->LookupSymbol(scanner_.literal_string(),
|
| - scanner_.literal_length());
|
| + if (peek() == Token::IDENTIFIER) {
|
| + Handle<String> name = ParseIdentifier(CHECK_OK);
|
| FunctionLiteral* value =
|
| - ParseFunctionLiteral(name,
|
| - RelocInfo::kNoPosition,
|
| - DECLARATION,
|
| - CHECK_OK);
|
| + ParseFunctionLiteral(name, RelocInfo::kNoPosition,
|
| + DECLARATION, CHECK_OK);
|
| ObjectLiteral::Property* property =
|
| NEW(ObjectLiteral::Property(is_getter, value));
|
| - if (IsBoilerplateProperty(property)) {
|
| + if (IsBoilerplateProperty(property))
|
| number_of_boilerplate_properties++;
|
| - }
|
| properties.Add(property);
|
| if (peek() != Token::RBRACE) Expect(Token::COMMA, CHECK_OK);
|
| continue; // restart the while
|
| @@ -3638,20 +3625,14 @@
|
| key = NEW(Literal(id));
|
| break;
|
| }
|
| -#define CASE_KEYWORD(name, ignore1, ignore2) \
|
| - case Token::name:
|
| - TOKEN_LIST(IGNORE_TOKEN, CASE_KEYWORD, IGNORE_TOKEN)
|
| -#undef CASE_KEYWORD
|
| - // FALLTHROUGH - keyword tokens fall through to the same code as strings.
|
| +
|
| case Token::STRING: {
|
| - Consume(next);
|
| + Consume(Token::STRING);
|
| Handle<String> string =
|
| factory()->LookupSymbol(scanner_.literal_string(),
|
| scanner_.literal_length());
|
| uint32_t index;
|
| - if (next == Token::STRING &&
|
| - !string.is_null() &&
|
| - string->AsArrayIndex(&index)) {
|
| + if (!string.is_null() && string->AsArrayIndex(&index)) {
|
| key = NewNumberLiteral(index);
|
| } else {
|
| key = NEW(Literal(string));
|
| @@ -4027,19 +4008,6 @@
|
| scanner_.literal_length());
|
| }
|
|
|
| -
|
| -Handle<String> Parser::ParseIdentifierName(bool* ok) {
|
| - Token::Value next = Next();
|
| - if (next != Token::IDENTIFIER && !Token::IsKeyword(next)) {
|
| - ReportUnexpectedToken(next);
|
| - *ok = false;
|
| - return Handle<String>();
|
| - }
|
| - return factory()->LookupSymbol(scanner_.literal_string(),
|
| - scanner_.literal_length());
|
| -}
|
| -
|
| -
|
| // This function reads an identifier and determines whether or not it
|
| // is 'get' or 'set'. The reason for not using ParseIdentifier and
|
| // checking on the output is that this involves heap allocation which
|
|
|