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

Side by Side Diff: src/preparser.cc

Issue 1195163007: Revert of [destructuring] Implement parameter pattern matching. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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/preparser.h ('k') | src/scopes.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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 <cmath> 5 #include <cmath>
6 6
7 #include "src/allocation.h" 7 #include "src/allocation.h"
8 #include "src/base/logging.h" 8 #include "src/base/logging.h"
9 #include "src/conversions-inl.h" 9 #include "src/conversions-inl.h"
10 #include "src/conversions.h" 10 #include "src/conversions.h"
(...skipping 1020 matching lines...) Expand 10 before | Expand all | Expand 10 after
1031 1031
1032 // Parse function body. 1032 // Parse function body.
1033 bool outer_is_script_scope = scope_->is_script_scope(); 1033 bool outer_is_script_scope = scope_->is_script_scope();
1034 Scope* function_scope = NewScope(scope_, FUNCTION_SCOPE, kind); 1034 Scope* function_scope = NewScope(scope_, FUNCTION_SCOPE, kind);
1035 PreParserFactory factory(NULL); 1035 PreParserFactory factory(NULL);
1036 FunctionState function_state(&function_state_, &scope_, function_scope, kind, 1036 FunctionState function_state(&function_state_, &scope_, function_scope, kind,
1037 &factory); 1037 &factory);
1038 DuplicateFinder duplicate_finder(scanner()->unicode_cache()); 1038 DuplicateFinder duplicate_finder(scanner()->unicode_cache());
1039 ExpressionClassifier formals_classifier(&duplicate_finder); 1039 ExpressionClassifier formals_classifier(&duplicate_finder);
1040 1040
1041 bool has_rest = false;
1041 Expect(Token::LPAREN, CHECK_OK); 1042 Expect(Token::LPAREN, CHECK_OK);
1042 int start_position = scanner()->location().beg_pos; 1043 int start_position = scanner()->location().beg_pos;
1043 function_scope->set_start_position(start_position); 1044 function_scope->set_start_position(start_position);
1044 PreParserFormalParameterParsingState parsing_state(nullptr); 1045 int num_parameters = ParseFormalParameterList(nullptr, &has_rest,
1045 int num_parameters = 1046 &formals_classifier, CHECK_OK);
1046 ParseFormalParameterList(&parsing_state, &formals_classifier, CHECK_OK);
1047 Expect(Token::RPAREN, CHECK_OK); 1047 Expect(Token::RPAREN, CHECK_OK);
1048 int formals_end_position = scanner()->location().end_pos; 1048 int formals_end_position = scanner()->location().end_pos;
1049 1049
1050 CheckArityRestrictions(num_parameters, arity_restriction, 1050 CheckArityRestrictions(num_parameters, arity_restriction, has_rest,
1051 parsing_state.has_rest, start_position, 1051 start_position, formals_end_position, CHECK_OK);
1052 formals_end_position, CHECK_OK);
1053 1052
1054 // See Parser::ParseFunctionLiteral for more information about lazy parsing 1053 // See Parser::ParseFunctionLiteral for more information about lazy parsing
1055 // and lazy compilation. 1054 // and lazy compilation.
1056 bool is_lazily_parsed = 1055 bool is_lazily_parsed =
1057 (outer_is_script_scope && allow_lazy() && !parenthesized_function_); 1056 (outer_is_script_scope && allow_lazy() && !parenthesized_function_);
1058 parenthesized_function_ = false; 1057 parenthesized_function_ = false;
1059 1058
1060 Expect(Token::LBRACE, CHECK_OK); 1059 Expect(Token::LBRACE, CHECK_OK);
1061 if (is_lazily_parsed) { 1060 if (is_lazily_parsed) {
1062 ParseLazyFunctionLiteralBody(CHECK_OK); 1061 ParseLazyFunctionLiteralBody(CHECK_OK);
1063 } else { 1062 } else {
1064 ParseStatementList(Token::RBRACE, CHECK_OK); 1063 ParseStatementList(Token::RBRACE, CHECK_OK);
1065 } 1064 }
1066 Expect(Token::RBRACE, CHECK_OK); 1065 Expect(Token::RBRACE, CHECK_OK);
1067 1066
1068 // Validate name and parameter names. We can do this only after parsing the 1067 // Validate name and parameter names. We can do this only after parsing the
1069 // function, since the function can declare itself strict. 1068 // function, since the function can declare itself strict.
1070 CheckFunctionName(language_mode(), kind, function_name, 1069 CheckFunctionName(language_mode(), kind, function_name,
1071 name_is_strict_reserved, function_name_location, CHECK_OK); 1070 name_is_strict_reserved, function_name_location, CHECK_OK);
1072 const bool strict_formal_parameters = 1071 const bool strict_formal_parameters = has_rest || IsConciseMethod(kind);
1073 !parsing_state.is_simple_parameter_list || IsConciseMethod(kind);
1074 const bool allow_duplicate_parameters = 1072 const bool allow_duplicate_parameters =
1075 is_sloppy(language_mode()) && !strict_formal_parameters; 1073 is_sloppy(language_mode()) && !strict_formal_parameters;
1076 ValidateFormalParameters(&formals_classifier, language_mode(), 1074 ValidateFormalParameters(&formals_classifier, language_mode(),
1077 allow_duplicate_parameters, CHECK_OK); 1075 allow_duplicate_parameters, CHECK_OK);
1078 1076
1079 if (is_strict(language_mode())) { 1077 if (is_strict(language_mode())) {
1080 int end_position = scanner()->location().end_pos; 1078 int end_position = scanner()->location().end_pos;
1081 CheckStrictOctalLiteral(start_position, end_position, CHECK_OK); 1079 CheckStrictOctalLiteral(start_position, end_position, CHECK_OK);
1082 } 1080 }
1083 1081
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
1188 1186
1189 DCHECK(!spread_pos.IsValid()); 1187 DCHECK(!spread_pos.IsValid());
1190 1188
1191 return Expression::Default(); 1189 return Expression::Default();
1192 } 1190 }
1193 1191
1194 #undef CHECK_OK 1192 #undef CHECK_OK
1195 1193
1196 1194
1197 } } // v8::internal 1195 } } // v8::internal
OLDNEW
« no previous file with comments | « src/preparser.h ('k') | src/scopes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698