Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(761)

Side by Side Diff: src/parser.cc

Issue 3109002: Removed support for object literal get/set with number/string property name. (Closed)
Patch Set: Addressed review comment. Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/runtime.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 3569 matching lines...) Expand 10 before | Expand all | Expand 10 after
3580 *depth = depth_acc; 3580 *depth = depth_acc;
3581 } 3581 }
3582 3582
3583 3583
3584 ObjectLiteral::Property* Parser::ParseObjectLiteralGetSet(bool is_getter, 3584 ObjectLiteral::Property* Parser::ParseObjectLiteralGetSet(bool is_getter,
3585 bool* ok) { 3585 bool* ok) {
3586 // Special handling of getter and setter syntax: 3586 // Special handling of getter and setter syntax:
3587 // { ... , get foo() { ... }, ... , set foo(v) { ... v ... } , ... } 3587 // { ... , get foo() { ... }, ... , set foo(v) { ... v ... } , ... }
3588 // We have already read the "get" or "set" keyword. 3588 // We have already read the "get" or "set" keyword.
3589 Token::Value next = Next(); 3589 Token::Value next = Next();
3590 if (next == Token::IDENTIFIER || 3590 // TODO(820): Allow NUMBER and STRING as well (and handle array indices).
3591 next == Token::STRING || 3591 if (next == Token::IDENTIFIER || Token::IsKeyword(next)) {
3592 next == Token::NUMBER ||
3593 Token::IsKeyword(next)) {
3594 Handle<String> name = 3592 Handle<String> name =
3595 factory()->LookupSymbol(scanner_.literal_string(), 3593 factory()->LookupSymbol(scanner_.literal_string(),
3596 scanner_.literal_length()); 3594 scanner_.literal_length());
3597 FunctionLiteral* value = 3595 FunctionLiteral* value =
3598 ParseFunctionLiteral(name, 3596 ParseFunctionLiteral(name,
3599 RelocInfo::kNoPosition, 3597 RelocInfo::kNoPosition,
3600 DECLARATION, 3598 DECLARATION,
3601 CHECK_OK); 3599 CHECK_OK);
3602 ObjectLiteral::Property* property = 3600 ObjectLiteral::Property* property =
3603 NEW(ObjectLiteral::Property(is_getter, value)); 3601 NEW(ObjectLiteral::Property(is_getter, value));
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
3645 // called "get" or "set". 3643 // called "get" or "set".
3646 key = NEW(Literal(id)); 3644 key = NEW(Literal(id));
3647 break; 3645 break;
3648 } 3646 }
3649 case Token::STRING: { 3647 case Token::STRING: {
3650 Consume(Token::STRING); 3648 Consume(Token::STRING);
3651 Handle<String> string = 3649 Handle<String> string =
3652 factory()->LookupSymbol(scanner_.literal_string(), 3650 factory()->LookupSymbol(scanner_.literal_string(),
3653 scanner_.literal_length()); 3651 scanner_.literal_length());
3654 uint32_t index; 3652 uint32_t index;
3655 if (!string.is_null() && 3653 if (!string.is_null() && string->AsArrayIndex(&index)) {
3656 string->AsArrayIndex(&index)) {
3657 key = NewNumberLiteral(index); 3654 key = NewNumberLiteral(index);
3658 break; 3655 break;
3659 } 3656 }
3660 key = NEW(Literal(string)); 3657 key = NEW(Literal(string));
3661 break; 3658 break;
3662 } 3659 }
3663 case Token::NUMBER: { 3660 case Token::NUMBER: {
3664 Consume(Token::NUMBER); 3661 Consume(Token::NUMBER);
3665 double value = 3662 double value =
3666 StringToDouble(scanner_.literal_string(), ALLOW_HEX | ALLOW_OCTALS); 3663 StringToDouble(scanner_.literal_string(), ALLOW_HEX | ALLOW_OCTALS);
(...skipping 1574 matching lines...) Expand 10 before | Expand all | Expand 10 after
5241 parser.ParseLazy(script_source, name, 5238 parser.ParseLazy(script_source, name,
5242 start_position, end_position, is_expression); 5239 start_position, end_position, is_expression);
5243 return result; 5240 return result;
5244 } 5241 }
5245 5242
5246 5243
5247 #undef NEW 5244 #undef NEW
5248 5245
5249 5246
5250 } } // namespace v8::internal 5247 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/runtime.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698