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

Side by Side Diff: src/parser.h

Issue 1468143004: [es6] Self-assignment in a default parameter initializer should throw (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Change less behavior, add TODO Created 5 years 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/parser.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 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_PARSER_H_ 5 #ifndef V8_PARSER_H_
6 #define V8_PARSER_H_ 6 #define V8_PARSER_H_
7 7
8 #include "src/allocation.h" 8 #include "src/allocation.h"
9 #include "src/ast.h" 9 #include "src/ast.h"
10 #include "src/compiler.h" // TODO(titzer): remove this include dependency 10 #include "src/compiler.h" // TODO(titzer): remove this include dependency
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 // ---------------------------------------------------------------------------- 544 // ----------------------------------------------------------------------------
545 // JAVASCRIPT PARSING 545 // JAVASCRIPT PARSING
546 546
547 class Parser; 547 class Parser;
548 class SingletonLogger; 548 class SingletonLogger;
549 549
550 550
551 struct ParserFormalParameters : FormalParametersBase { 551 struct ParserFormalParameters : FormalParametersBase {
552 struct Parameter { 552 struct Parameter {
553 Parameter(const AstRawString* name, Expression* pattern, 553 Parameter(const AstRawString* name, Expression* pattern,
554 Expression* initializer, bool is_rest) 554 Expression* initializer, int initializer_end_position,
555 : name(name), pattern(pattern), initializer(initializer), 555 bool is_rest)
556 : name(name),
557 pattern(pattern),
558 initializer(initializer),
559 initializer_end_position(initializer_end_position),
556 is_rest(is_rest) {} 560 is_rest(is_rest) {}
557 const AstRawString* name; 561 const AstRawString* name;
558 Expression* pattern; 562 Expression* pattern;
559 Expression* initializer; 563 Expression* initializer;
564 int initializer_end_position;
560 bool is_rest; 565 bool is_rest;
561 bool is_simple() const { 566 bool is_simple() const {
562 return pattern->IsVariableProxy() && initializer == nullptr && !is_rest; 567 return pattern->IsVariableProxy() && initializer == nullptr && !is_rest;
563 } 568 }
564 }; 569 };
565 570
566 explicit ParserFormalParameters(Scope* scope) 571 explicit ParserFormalParameters(Scope* scope)
567 : FormalParametersBase(scope), params(4, scope->zone()) {} 572 : FormalParametersBase(scope), params(4, scope->zone()) {}
568 ZoneList<Parameter> params; 573 ZoneList<Parameter> params;
569 574
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
786 return new(zone) ZoneList<v8::internal::Statement*>(size, zone); 791 return new(zone) ZoneList<v8::internal::Statement*>(size, zone);
787 } 792 }
788 793
789 V8_INLINE void AddParameterInitializationBlock( 794 V8_INLINE void AddParameterInitializationBlock(
790 const ParserFormalParameters& parameters, 795 const ParserFormalParameters& parameters,
791 ZoneList<v8::internal::Statement*>* body, bool* ok); 796 ZoneList<v8::internal::Statement*>* body, bool* ok);
792 797
793 V8_INLINE Scope* NewScope(Scope* parent_scope, ScopeType scope_type, 798 V8_INLINE Scope* NewScope(Scope* parent_scope, ScopeType scope_type,
794 FunctionKind kind = kNormalFunction); 799 FunctionKind kind = kNormalFunction);
795 800
796 V8_INLINE void AddFormalParameter( 801 V8_INLINE void AddFormalParameter(ParserFormalParameters* parameters,
797 ParserFormalParameters* parameters, Expression* pattern, 802 Expression* pattern,
798 Expression* initializer, bool is_rest); 803 Expression* initializer,
804 int initializer_end_position, bool is_rest);
799 V8_INLINE void DeclareFormalParameter( 805 V8_INLINE void DeclareFormalParameter(
800 Scope* scope, const ParserFormalParameters::Parameter& parameter, 806 Scope* scope, const ParserFormalParameters::Parameter& parameter,
801 ExpressionClassifier* classifier); 807 ExpressionClassifier* classifier);
802 void ParseArrowFunctionFormalParameters(ParserFormalParameters* parameters, 808 void ParseArrowFunctionFormalParameters(ParserFormalParameters* parameters,
803 Expression* params, 809 Expression* params,
804 const Scanner::Location& params_loc, 810 const Scanner::Location& params_loc,
805 bool* ok); 811 bool* ok);
806 void ParseArrowFunctionFormalParameterList( 812 void ParseArrowFunctionFormalParameterList(
807 ParserFormalParameters* parameters, Expression* params, 813 ParserFormalParameters* parameters, Expression* params,
808 const Scanner::Location& params_loc, 814 const Scanner::Location& params_loc,
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after
1331 return parser_->SpreadCall(function, args, pos); 1337 return parser_->SpreadCall(function, args, pos);
1332 } 1338 }
1333 1339
1334 1340
1335 Expression* ParserTraits::SpreadCallNew( 1341 Expression* ParserTraits::SpreadCallNew(
1336 Expression* function, ZoneList<v8::internal::Expression*>* args, int pos) { 1342 Expression* function, ZoneList<v8::internal::Expression*>* args, int pos) {
1337 return parser_->SpreadCallNew(function, args, pos); 1343 return parser_->SpreadCallNew(function, args, pos);
1338 } 1344 }
1339 1345
1340 1346
1341 void ParserTraits::AddFormalParameter( 1347 void ParserTraits::AddFormalParameter(ParserFormalParameters* parameters,
1342 ParserFormalParameters* parameters, 1348 Expression* pattern,
1343 Expression* pattern, Expression* initializer, bool is_rest) { 1349 Expression* initializer,
1350 int initializer_end_position,
1351 bool is_rest) {
1344 bool is_simple = 1352 bool is_simple =
1345 !is_rest && pattern->IsVariableProxy() && initializer == nullptr; 1353 !is_rest && pattern->IsVariableProxy() && initializer == nullptr;
1346 DCHECK(parser_->allow_harmony_destructuring_bind() || 1354 DCHECK(parser_->allow_harmony_destructuring_bind() ||
1347 parser_->allow_harmony_rest_parameters() || 1355 parser_->allow_harmony_rest_parameters() ||
1348 parser_->allow_harmony_default_parameters() || is_simple); 1356 parser_->allow_harmony_default_parameters() || is_simple);
1349 const AstRawString* name = is_simple 1357 const AstRawString* name = is_simple
1350 ? pattern->AsVariableProxy()->raw_name() 1358 ? pattern->AsVariableProxy()->raw_name()
1351 : parser_->ast_value_factory()->empty_string(); 1359 : parser_->ast_value_factory()->empty_string();
1352 parameters->params.Add( 1360 parameters->params.Add(
1353 ParserFormalParameters::Parameter(name, pattern, initializer, is_rest), 1361 ParserFormalParameters::Parameter(name, pattern, initializer,
1362 initializer_end_position, is_rest),
1354 parameters->scope->zone()); 1363 parameters->scope->zone());
1355 } 1364 }
1356 1365
1357 1366
1358 void ParserTraits::DeclareFormalParameter( 1367 void ParserTraits::DeclareFormalParameter(
1359 Scope* scope, const ParserFormalParameters::Parameter& parameter, 1368 Scope* scope, const ParserFormalParameters::Parameter& parameter,
1360 ExpressionClassifier* classifier) { 1369 ExpressionClassifier* classifier) {
1361 bool is_duplicate = false; 1370 bool is_duplicate = false;
1362 bool is_simple = classifier->is_simple_parameter_list(); 1371 bool is_simple = classifier->is_simple_parameter_list();
1363 auto name = parameter.name; 1372 auto name = parameter.name;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1395 1404
1396 DoExpression* ParserTraits::ParseDoExpression(bool* ok) { 1405 DoExpression* ParserTraits::ParseDoExpression(bool* ok) {
1397 return parser_->ParseDoExpression(ok); 1406 return parser_->ParseDoExpression(ok);
1398 } 1407 }
1399 1408
1400 1409
1401 } // namespace internal 1410 } // namespace internal
1402 } // namespace v8 1411 } // namespace v8
1403 1412
1404 #endif // V8_PARSER_H_ 1413 #endif // V8_PARSER_H_
OLDNEW
« no previous file with comments | « no previous file | src/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698