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

Side by Side Diff: src/parser.h

Issue 1311163002: [es6] Correct length for functions with default parameters (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Comment Created 5 years, 3 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 | src/scopes.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_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 1323 matching lines...) Expand 10 before | Expand all | Expand 10 after
1334 1334
1335 1335
1336 void ParserTraits::DeclareFormalParameter( 1336 void ParserTraits::DeclareFormalParameter(
1337 Scope* scope, const ParserFormalParameters::Parameter& parameter, 1337 Scope* scope, const ParserFormalParameters::Parameter& parameter,
1338 bool is_simple, ExpressionClassifier* classifier) { 1338 bool is_simple, ExpressionClassifier* classifier) {
1339 bool is_duplicate = false; 1339 bool is_duplicate = false;
1340 // TODO(caitp): Remove special handling for rest once desugaring is in. 1340 // TODO(caitp): Remove special handling for rest once desugaring is in.
1341 auto name = is_simple || parameter.is_rest 1341 auto name = is_simple || parameter.is_rest
1342 ? parameter.name : parser_->ast_value_factory()->empty_string(); 1342 ? parameter.name : parser_->ast_value_factory()->empty_string();
1343 auto mode = is_simple || parameter.is_rest ? VAR : TEMPORARY; 1343 auto mode = is_simple || parameter.is_rest ? VAR : TEMPORARY;
1344 Variable* var = 1344 bool is_optional = parameter.initializer != nullptr;
1345 scope->DeclareParameter(name, mode, parameter.is_rest, &is_duplicate); 1345 Variable* var = scope->DeclareParameter(
1346 name, mode, is_optional, parameter.is_rest, &is_duplicate);
1346 if (is_duplicate) { 1347 if (is_duplicate) {
1347 classifier->RecordDuplicateFormalParameterError( 1348 classifier->RecordDuplicateFormalParameterError(
1348 parser_->scanner()->location()); 1349 parser_->scanner()->location());
1349 } 1350 }
1350 if (is_sloppy(scope->language_mode())) { 1351 if (is_sloppy(scope->language_mode())) {
1351 // TODO(sigurds) Mark every parameter as maybe assigned. This is a 1352 // TODO(sigurds) Mark every parameter as maybe assigned. This is a
1352 // conservative approximation necessary to account for parameters 1353 // conservative approximation necessary to account for parameters
1353 // that are assigned via the arguments array. 1354 // that are assigned via the arguments array.
1354 var->set_maybe_assigned(); 1355 var->set_maybe_assigned();
1355 } 1356 }
1356 } 1357 }
1357 1358
1358 1359
1359 void ParserTraits::AddParameterInitializationBlock( 1360 void ParserTraits::AddParameterInitializationBlock(
1360 const ParserFormalParameters& parameters, 1361 const ParserFormalParameters& parameters,
1361 ZoneList<v8::internal::Statement*>* body, bool* ok) { 1362 ZoneList<v8::internal::Statement*>* body, bool* ok) {
1362 if (!parameters.is_simple) { 1363 if (!parameters.is_simple) {
1363 auto* init_block = 1364 auto* init_block =
1364 parser_->BuildParameterInitializationBlock(parameters, ok); 1365 parser_->BuildParameterInitializationBlock(parameters, ok);
1365 if (!*ok) return; 1366 if (!*ok) return;
1366 if (init_block != nullptr) { 1367 if (init_block != nullptr) {
1367 body->Add(init_block, parser_->zone()); 1368 body->Add(init_block, parser_->zone());
1368 } 1369 }
1369 } 1370 }
1370 } 1371 }
1371 } } // namespace v8::internal 1372 } } // namespace v8::internal
1372 1373
1373 #endif // V8_PARSER_H_ 1374 #endif // V8_PARSER_H_
OLDNEW
« no previous file with comments | « no previous file | src/scopes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698