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

Side by Side Diff: runtime/vm/parser.cc

Issue 2452623002: Avoid parsing formal type parameters a second time from inside an async body, (Closed)
Patch Set: remove leftover debugging code Created 4 years, 1 month 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 | tests/language/regress_27659_test.dart » ('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 (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/parser.h" 5 #include "vm/parser.h"
6 #include "vm/flags.h" 6 #include "vm/flags.h"
7 7
8 #ifndef DART_PRECOMPILED_RUNTIME 8 #ifndef DART_PRECOMPILED_RUNTIME
9 9
10 #include "lib/invocation_mirror.h" 10 #include "lib/invocation_mirror.h"
(...skipping 3486 matching lines...) Expand 10 before | Expand all | Expand 10 after
3497 // Populate function scope with the formal parameters. Since in this case 3497 // Populate function scope with the formal parameters. Since in this case
3498 // we are compiling a getter this will at most populate the receiver. 3498 // we are compiling a getter this will at most populate the receiver.
3499 AddFormalParamsToScope(&params, current_block_->scope); 3499 AddFormalParamsToScope(&params, current_block_->scope);
3500 } else if (func.IsAsyncClosure()) { 3500 } else if (func.IsAsyncClosure()) {
3501 AddAsyncClosureParameters(&params); 3501 AddAsyncClosureParameters(&params);
3502 SetupDefaultsForOptionalParams(params); 3502 SetupDefaultsForOptionalParams(params);
3503 AddFormalParamsToScope(&params, current_block_->scope); 3503 AddFormalParamsToScope(&params, current_block_->scope);
3504 ASSERT(AbstractType::Handle(Z, func.result_type()).IsResolved()); 3504 ASSERT(AbstractType::Handle(Z, func.result_type()).IsResolved());
3505 ASSERT(func.NumParameters() == params.parameters->length()); 3505 ASSERT(func.NumParameters() == params.parameters->length());
3506 if (!Function::Handle(func.parent_function()).IsGetterFunction()) { 3506 if (!Function::Handle(func.parent_function()).IsGetterFunction()) {
3507 // Parse and discard any formal parameters. They are accessed as 3507 // Skip formal parameters. They are accessed as context variables.
3508 // context variables. 3508 // Parsing them again (and discarding them) does not work in case of
3509 ParamList discarded_params; 3509 // default values with same name as already parsed formal parameter.
3510 ParseFormalParameterList(allow_explicit_default_values, 3510 SkipToMatchingParenthesis();
3511 false,
3512 &discarded_params);
3513 } 3511 }
3514 } else if (func.IsSyncGenClosure()) { 3512 } else if (func.IsSyncGenClosure()) {
3515 AddSyncGenClosureParameters(&params); 3513 AddSyncGenClosureParameters(&params);
3516 SetupDefaultsForOptionalParams(params); 3514 SetupDefaultsForOptionalParams(params);
3517 AddFormalParamsToScope(&params, current_block_->scope); 3515 AddFormalParamsToScope(&params, current_block_->scope);
3518 ASSERT(AbstractType::Handle(Z, func.result_type()).IsResolved()); 3516 ASSERT(AbstractType::Handle(Z, func.result_type()).IsResolved());
3519 if (!Function::Handle(func.parent_function()).IsGetterFunction()) { 3517 if (!Function::Handle(func.parent_function()).IsGetterFunction()) {
3520 // Parse and discard any formal parameters. They are accessed as 3518 // Skip formal parameters. They are accessed as context variables.
3521 // context variables. 3519 // Parsing them again (and discarding them) does not work in case of
3522 ParamList discarded_params; 3520 // default values with same name as already parsed formal parameter.
3523 ParseFormalParameterList(allow_explicit_default_values, 3521 SkipToMatchingParenthesis();
3524 false,
3525 &discarded_params);
3526 } 3522 }
3527 } else if (func.IsAsyncGenClosure()) { 3523 } else if (func.IsAsyncGenClosure()) {
3528 AddAsyncGenClosureParameters(&params); 3524 AddAsyncGenClosureParameters(&params);
3529 SetupDefaultsForOptionalParams(params); 3525 SetupDefaultsForOptionalParams(params);
3530 AddFormalParamsToScope(&params, current_block_->scope); 3526 AddFormalParamsToScope(&params, current_block_->scope);
3531 ASSERT(AbstractType::Handle(Z, func.result_type()).IsResolved()); 3527 ASSERT(AbstractType::Handle(Z, func.result_type()).IsResolved());
3532 ASSERT(func.NumParameters() == params.parameters->length()); 3528 ASSERT(func.NumParameters() == params.parameters->length());
3533 if (!Function::Handle(func.parent_function()).IsGetterFunction()) { 3529 if (!Function::Handle(func.parent_function()).IsGetterFunction()) {
3534 // Parse and discard any formal parameters. They are accessed as 3530 // Skip formal parameters. They are accessed as context variables.
3535 // context variables. 3531 // Parsing them again (and discarding them) does not work in case of
3536 ParamList discarded_params; 3532 // default values with same name as already parsed formal parameter.
3537 ParseFormalParameterList(allow_explicit_default_values, 3533 SkipToMatchingParenthesis();
3538 false,
3539 &discarded_params);
3540 } 3534 }
3541 } else { 3535 } else {
3542 ParseFormalParameterList(allow_explicit_default_values, false, &params); 3536 ParseFormalParameterList(allow_explicit_default_values, false, &params);
3543 3537
3544 // The number of parameters and their type are not yet set in local 3538 // The number of parameters and their type are not yet set in local
3545 // functions, since they are not 'top-level' parsed. 3539 // functions, since they are not 'top-level' parsed.
3546 // However, they are already set when the local function is compiled, since 3540 // However, they are already set when the local function is compiled, since
3547 // the local function was parsed when its parent was compiled. 3541 // the local function was parsed when its parent was compiled.
3548 if (func.parameter_types() == Object::empty_array().raw()) { 3542 if (func.parameter_types() == Object::empty_array().raw()) {
3549 AddFormalParamsToFunction(&params, func); 3543 AddFormalParamsToFunction(&params, func);
(...skipping 11145 matching lines...) Expand 10 before | Expand all | Expand 10 after
14695 14689
14696 14690
14697 void Parser::SkipFunctionLiteral() { 14691 void Parser::SkipFunctionLiteral() {
14698 if (IsIdentifier()) { 14692 if (IsIdentifier()) {
14699 if (LookaheadToken(1) != Token::kLPAREN) { 14693 if (LookaheadToken(1) != Token::kLPAREN) {
14700 SkipType(true); 14694 SkipType(true);
14701 } 14695 }
14702 ExpectIdentifier("function name expected"); 14696 ExpectIdentifier("function name expected");
14703 } 14697 }
14704 if (CurrentToken() == Token::kLPAREN) { 14698 if (CurrentToken() == Token::kLPAREN) {
14705 const bool allow_explicit_default_values = true; 14699 SkipToMatchingParenthesis();
14706 ParamList params;
14707 params.skipped = true;
14708 ParseFormalParameterList(allow_explicit_default_values, false, &params);
14709 } 14700 }
14710 RawFunction::AsyncModifier async_modifier = ParseFunctionModifier(); 14701 RawFunction::AsyncModifier async_modifier = ParseFunctionModifier();
14711 BoolScope allow_await(&this->await_is_keyword_, 14702 BoolScope allow_await(&this->await_is_keyword_,
14712 async_modifier != RawFunction::kNoModifier); 14703 async_modifier != RawFunction::kNoModifier);
14713 if (CurrentToken() == Token::kLBRACE) { 14704 if (CurrentToken() == Token::kLBRACE) {
14714 SkipBlock(); 14705 SkipBlock();
14715 ExpectToken(Token::kRBRACE); 14706 ExpectToken(Token::kRBRACE);
14716 } else if (CurrentToken() == Token::kARROW) { 14707 } else if (CurrentToken() == Token::kARROW) {
14717 ConsumeToken(); 14708 ConsumeToken();
14718 SkipExpr(); 14709 SkipExpr();
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
15154 const ArgumentListNode& function_args, 15145 const ArgumentListNode& function_args,
15155 const LocalVariable* temp_for_last_arg, 15146 const LocalVariable* temp_for_last_arg,
15156 bool is_super_invocation) { 15147 bool is_super_invocation) {
15157 UNREACHABLE(); 15148 UNREACHABLE();
15158 return NULL; 15149 return NULL;
15159 } 15150 }
15160 15151
15161 } // namespace dart 15152 } // namespace dart
15162 15153
15163 #endif // DART_PRECOMPILED_RUNTIME 15154 #endif // DART_PRECOMPILED_RUNTIME
OLDNEW
« no previous file with comments | « no previous file | tests/language/regress_27659_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698