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

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

Issue 2650863002: [parser] Throw error when there are too many excluded properties (Closed)
Patch Set: skip test in debug 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 | « no previous file | test/cctest/cctest.status » ('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 2116 matching lines...) Expand 10 before | Expand all | Expand 10 after
2127 *name = impl()->EmptyIdentifier(); 2127 *name = impl()->EmptyIdentifier();
2128 Consume(Token::ELLIPSIS); 2128 Consume(Token::ELLIPSIS);
2129 expression = ParseAssignmentExpression(true, CHECK_OK); 2129 expression = ParseAssignmentExpression(true, CHECK_OK);
2130 *kind = PropertyKind::kSpreadProperty; 2130 *kind = PropertyKind::kSpreadProperty;
2131 2131
2132 if (expression->IsAssignment()) { 2132 if (expression->IsAssignment()) {
2133 classifier()->RecordPatternError( 2133 classifier()->RecordPatternError(
2134 scanner()->location(), 2134 scanner()->location(),
2135 MessageTemplate::kInvalidDestructuringTarget); 2135 MessageTemplate::kInvalidDestructuringTarget);
2136 } else { 2136 } else {
2137 // TODO(gsathya): Throw error if number of properties >
2138 // Code::kMaxArguments
2139 CheckDestructuringElement(expression, pos, 2137 CheckDestructuringElement(expression, pos,
2140 scanner()->location().end_pos); 2138 scanner()->location().end_pos);
2141 } 2139 }
2142 2140
2143 if (peek() != Token::RBRACE) { 2141 if (peek() != Token::RBRACE) {
2144 classifier()->RecordPatternError(scanner()->location(), 2142 classifier()->RecordPatternError(scanner()->location(),
2145 MessageTemplate::kElementAfterRest); 2143 MessageTemplate::kElementAfterRest);
2146 } 2144 }
2147 return expression; 2145 return expression;
2148 } 2146 }
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
2588 Expect(Token::COMMA, CHECK_OK); 2586 Expect(Token::COMMA, CHECK_OK);
2589 } 2587 }
2590 2588
2591 if (fni_ != nullptr) fni_->Infer(); 2589 if (fni_ != nullptr) fni_->Infer();
2592 } 2590 }
2593 Expect(Token::RBRACE, CHECK_OK); 2591 Expect(Token::RBRACE, CHECK_OK);
2594 2592
2595 // Computation of literal_index must happen before pre parse bailout. 2593 // Computation of literal_index must happen before pre parse bailout.
2596 int literal_index = function_state_->NextMaterializedLiteralIndex(); 2594 int literal_index = function_state_->NextMaterializedLiteralIndex();
2597 2595
2596 // In pattern rewriter, we rewrite rest property to call out to a
2597 // runtime function passing all the other properties as arguments to
2598 // this runtime function. Here, we make sure that the number of
2599 // properties is less than number of arguments allowed for a runtime
2600 // call.
2601 if (has_rest_property && properties->length() > Code::kMaxArguments) {
2602 this->classifier()->RecordPatternError(Scanner::Location(pos, position()),
2603 MessageTemplate::kTooManyArguments);
2604 }
2605
2598 return factory()->NewObjectLiteral(properties, literal_index, 2606 return factory()->NewObjectLiteral(properties, literal_index,
2599 number_of_boilerplate_properties, pos, 2607 number_of_boilerplate_properties, pos,
2600 has_rest_property); 2608 has_rest_property);
2601 } 2609 }
2602 2610
2603 template <typename Impl> 2611 template <typename Impl>
2604 typename ParserBase<Impl>::ExpressionListT ParserBase<Impl>::ParseArguments( 2612 typename ParserBase<Impl>::ExpressionListT ParserBase<Impl>::ParseArguments(
2605 Scanner::Location* first_spread_arg_loc, bool maybe_arrow, bool* ok) { 2613 Scanner::Location* first_spread_arg_loc, bool maybe_arrow, bool* ok) {
2606 // Arguments :: 2614 // Arguments ::
2607 // '(' (AssignmentExpression)*[','] ')' 2615 // '(' (AssignmentExpression)*[','] ')'
(...skipping 3076 matching lines...) Expand 10 before | Expand all | Expand 10 after
5684 return; 5692 return;
5685 } 5693 }
5686 } 5694 }
5687 5695
5688 #undef CHECK_OK_VOID 5696 #undef CHECK_OK_VOID
5689 5697
5690 } // namespace internal 5698 } // namespace internal
5691 } // namespace v8 5699 } // namespace v8
5692 5700
5693 #endif // V8_PARSING_PARSER_BASE_H 5701 #endif // V8_PARSING_PARSER_BASE_H
OLDNEW
« no previous file with comments | « no previous file | test/cctest/cctest.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698