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

Side by Side Diff: src/parsing/parser-base.h

Issue 2646333002: [parser] Delete has_seen_proto in ObjectLiteral. (Closed)
Patch Set: Created 3 years, 11 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 | « src/ast/ast.cc ('k') | src/parsing/preparser.h » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_PARSING_PARSER_BASE_H 5 #ifndef V8_PARSING_PARSER_BASE_H
6 #define V8_PARSING_PARSER_BASE_H 6 #define V8_PARSING_PARSER_BASE_H
7 7
8 #include "src/ast/ast.h" 8 #include "src/ast/ast.h"
9 #include "src/ast/scopes.h" 9 #include "src/ast/scopes.h"
10 #include "src/bailout-reason.h" 10 #include "src/bailout-reason.h"
(...skipping 2534 matching lines...) Expand 10 before | Expand all | Expand 10 after
2545 template <typename Impl> 2545 template <typename Impl>
2546 typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseObjectLiteral( 2546 typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseObjectLiteral(
2547 bool* ok) { 2547 bool* ok) {
2548 // ObjectLiteral :: 2548 // ObjectLiteral ::
2549 // '{' (PropertyDefinition (',' PropertyDefinition)* ','? )? '}' 2549 // '{' (PropertyDefinition (',' PropertyDefinition)* ','? )? '}'
2550 2550
2551 int pos = peek_position(); 2551 int pos = peek_position();
2552 typename Types::ObjectPropertyList properties = 2552 typename Types::ObjectPropertyList properties =
2553 impl()->NewObjectPropertyList(4); 2553 impl()->NewObjectPropertyList(4);
2554 int number_of_boilerplate_properties = 0; 2554 int number_of_boilerplate_properties = 0;
2555 bool has_seen_proto = false;
2556 2555
2557 bool has_computed_names = false; 2556 bool has_computed_names = false;
2558 bool has_rest_property = false; 2557 bool has_rest_property = false;
2559 ObjectLiteralChecker checker(this); 2558 ObjectLiteralChecker checker(this);
2560 2559
2561 Expect(Token::LBRACE, CHECK_OK); 2560 Expect(Token::LBRACE, CHECK_OK);
2562 2561
2563 while (peek() != Token::RBRACE) { 2562 while (peek() != Token::RBRACE) {
2564 FuncNameInferrer::State fni_state(fni_); 2563 FuncNameInferrer::State fni_state(fni_);
2565 2564
2566 bool is_computed_name = false; 2565 bool is_computed_name = false;
2567 bool is_rest_property = false; 2566 bool is_rest_property = false;
2568 ObjectLiteralPropertyT property = ParseObjectPropertyDefinition( 2567 ObjectLiteralPropertyT property = ParseObjectPropertyDefinition(
2569 &checker, &is_computed_name, &is_rest_property, CHECK_OK); 2568 &checker, &is_computed_name, &is_rest_property, CHECK_OK);
2570 2569
2571 if (is_computed_name) { 2570 if (is_computed_name) {
2572 has_computed_names = true; 2571 has_computed_names = true;
2573 } 2572 }
2574 2573
2575 if (is_rest_property) { 2574 if (is_rest_property) {
2576 has_rest_property = true; 2575 has_rest_property = true;
2577 } 2576 }
2578 2577
2579 if (!impl()->IsBoilerplateProperty(property)) { 2578 if (impl()->IsBoilerplateProperty(property) && !has_computed_names) {
2580 has_seen_proto = true;
2581 } else if (!has_computed_names) {
2582 // Count CONSTANT or COMPUTED properties to maintain the enumeration 2579 // Count CONSTANT or COMPUTED properties to maintain the enumeration
2583 // order. 2580 // order.
2584 number_of_boilerplate_properties++; 2581 number_of_boilerplate_properties++;
2585 } 2582 }
2586 2583
2587 properties->Add(property, zone()); 2584 properties->Add(property, zone());
2588 2585
2589 if (peek() != Token::RBRACE) { 2586 if (peek() != Token::RBRACE) {
2590 // Need {} because of the CHECK_OK macro. 2587 // Need {} because of the CHECK_OK macro.
2591 Expect(Token::COMMA, CHECK_OK); 2588 Expect(Token::COMMA, CHECK_OK);
2592 } 2589 }
2593 2590
2594 if (fni_ != nullptr) fni_->Infer(); 2591 if (fni_ != nullptr) fni_->Infer();
2595 } 2592 }
2596 Expect(Token::RBRACE, CHECK_OK); 2593 Expect(Token::RBRACE, CHECK_OK);
2597 2594
2598 // Computation of literal_index must happen before pre parse bailout. 2595 // Computation of literal_index must happen before pre parse bailout.
2599 int literal_index = function_state_->NextMaterializedLiteralIndex(); 2596 int literal_index = function_state_->NextMaterializedLiteralIndex();
2600 2597
2601 return factory()->NewObjectLiteral(properties, literal_index, 2598 return factory()->NewObjectLiteral(properties, literal_index,
2602 number_of_boilerplate_properties, 2599 number_of_boilerplate_properties, pos,
2603 has_seen_proto, pos, has_rest_property); 2600 has_rest_property);
2604 } 2601 }
2605 2602
2606 template <typename Impl> 2603 template <typename Impl>
2607 typename ParserBase<Impl>::ExpressionListT ParserBase<Impl>::ParseArguments( 2604 typename ParserBase<Impl>::ExpressionListT ParserBase<Impl>::ParseArguments(
2608 Scanner::Location* first_spread_arg_loc, bool maybe_arrow, bool* ok) { 2605 Scanner::Location* first_spread_arg_loc, bool maybe_arrow, bool* ok) {
2609 // Arguments :: 2606 // Arguments ::
2610 // '(' (AssignmentExpression)*[','] ')' 2607 // '(' (AssignmentExpression)*[','] ')'
2611 2608
2612 Scanner::Location spread_arg = Scanner::Location::invalid(); 2609 Scanner::Location spread_arg = Scanner::Location::invalid();
2613 ExpressionListT result = impl()->NewExpressionList(4); 2610 ExpressionListT result = impl()->NewExpressionList(4);
(...skipping 3067 matching lines...) Expand 10 before | Expand all | Expand 10 after
5681 return; 5678 return;
5682 } 5679 }
5683 } 5680 }
5684 5681
5685 #undef CHECK_OK_VOID 5682 #undef CHECK_OK_VOID
5686 5683
5687 } // namespace internal 5684 } // namespace internal
5688 } // namespace v8 5685 } // namespace v8
5689 5686
5690 #endif // V8_PARSING_PARSER_BASE_H 5687 #endif // V8_PARSING_PARSER_BASE_H
OLDNEW
« no previous file with comments | « src/ast/ast.cc ('k') | src/parsing/preparser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698