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

Side by Side Diff: src/parser.cc

Issue 1170153003: [destructuring] Refactor duplicate parameter name detection. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Removed FormalParameterScope trait Created 5 years, 6 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/parser.h ('k') | src/preparser.h » ('j') | src/preparser.h » ('J')
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 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/api.h" 7 #include "src/api.h"
8 #include "src/ast.h" 8 #include "src/ast.h"
9 #include "src/bailout-reason.h" 9 #include "src/bailout-reason.h"
10 #include "src/base/platform/platform.h" 10 #include "src/base/platform/platform.h"
(...skipping 3775 matching lines...) Expand 10 before | Expand all | Expand 10 after
3786 const AstRawString* raw_name = expr->AsVariableProxy()->raw_name(); 3786 const AstRawString* raw_name = expr->AsVariableProxy()->raw_name();
3787 Scanner::Location param_location(expr->position(), 3787 Scanner::Location param_location(expr->position(),
3788 expr->position() + raw_name->length()); 3788 expr->position() + raw_name->length());
3789 3789
3790 // When the formal parameter was originally seen, it was parsed as a 3790 // When the formal parameter was originally seen, it was parsed as a
3791 // VariableProxy and recorded as unresolved in the scope. Here we undo that 3791 // VariableProxy and recorded as unresolved in the scope. Here we undo that
3792 // parse-time side-effect. 3792 // parse-time side-effect.
3793 parser_->scope_->RemoveUnresolved(expr->AsVariableProxy()); 3793 parser_->scope_->RemoveUnresolved(expr->AsVariableProxy());
3794 3794
3795 bool is_rest = false; 3795 bool is_rest = false;
3796 bool is_duplicate = DeclareFormalParameter(scope, raw_name, is_rest); 3796 ExpressionClassifier classifier;
3797 3797 DeclareFormalParameter(scope, raw_name, &classifier, is_rest);
3798 if (is_duplicate && !duplicate_loc->IsValid()) { 3798 *duplicate_loc = classifier.duplicate_formal_parameter_error().location;
3799 *duplicate_loc = param_location;
3800 }
3801 } 3799 }
3802 3800
3803 3801
3804 void ParserTraits::ParseArrowFunctionFormalParameters( 3802 void ParserTraits::ParseArrowFunctionFormalParameters(
3805 Scope* scope, Expression* params, const Scanner::Location& params_loc, 3803 Scope* scope, Expression* params, const Scanner::Location& params_loc,
3806 bool* is_rest, Scanner::Location* duplicate_loc, bool* ok) { 3804 bool* is_rest, Scanner::Location* duplicate_loc, bool* ok) {
3807 DeclareArrowFunctionParameters(scope, params, params_loc, duplicate_loc, ok); 3805 DeclareArrowFunctionParameters(scope, params, params_loc, duplicate_loc, ok);
3808 } 3806 }
3809 3807
3810 3808
(...skipping 2002 matching lines...) Expand 10 before | Expand all | Expand 10 after
5813 Expression* Parser::SpreadCallNew(Expression* function, 5811 Expression* Parser::SpreadCallNew(Expression* function,
5814 ZoneList<v8::internal::Expression*>* args, 5812 ZoneList<v8::internal::Expression*>* args,
5815 int pos) { 5813 int pos) {
5816 args->InsertAt(0, function, zone()); 5814 args->InsertAt(0, function, zone());
5817 5815
5818 return factory()->NewCallRuntime( 5816 return factory()->NewCallRuntime(
5819 ast_value_factory()->reflect_construct_string(), NULL, args, pos); 5817 ast_value_factory()->reflect_construct_string(), NULL, args, pos);
5820 } 5818 }
5821 } // namespace internal 5819 } // namespace internal
5822 } // namespace v8 5820 } // namespace v8
OLDNEW
« no previous file with comments | « src/parser.h ('k') | src/preparser.h » ('j') | src/preparser.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698