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

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

Issue 12036088: Fix argument test for the captured parameter of an outer function (issue 8007). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | tests/language/argument_definition4_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 6
7 #include "vm/bigint_operations.h" 7 #include "vm/bigint_operations.h"
8 #include "vm/class_finalizer.h" 8 #include "vm/class_finalizer.h"
9 #include "vm/compiler.h" 9 #include "vm/compiler.h"
10 #include "vm/compiler_stats.h" 10 #include "vm/compiler_stats.h"
(...skipping 7692 matching lines...) Expand 10 before | Expand all | Expand 10 after
7703 // or of one of its enclosing functions. 7703 // or of one of its enclosing functions.
7704 // Make sure not to capture the formal parameter, since it is not accessed. 7704 // Make sure not to capture the formal parameter, since it is not accessed.
7705 bool Parser::IsFormalParameter(const String& ident, 7705 bool Parser::IsFormalParameter(const String& ident,
7706 Function* owner_function, 7706 Function* owner_function,
7707 LocalScope** owner_scope, 7707 LocalScope** owner_scope,
7708 intptr_t* local_index) { 7708 intptr_t* local_index) {
7709 if (current_block_ == NULL) { 7709 if (current_block_ == NULL) {
7710 return false; 7710 return false;
7711 } 7711 }
7712 if (ident.Equals(Symbols::This())) { 7712 if (ident.Equals(Symbols::This())) {
7713 // 'this' is not a formal parameter. 7713 // 'this' is not a formal parameter that can be tested with '?this'.
7714 return false; 7714 return false;
7715 } 7715 }
7716 // Since an argument definition test does not use the value of the formal 7716 // Since an argument definition test does not use the value of the formal
7717 // parameter, there is no reason to capture it. 7717 // parameter, there is no reason to capture it.
7718 const bool kTestOnly = true; // No capturing. 7718 const bool kTestOnly = true; // No capturing.
7719 LocalVariable* local = 7719 LocalVariable* local =
7720 current_block_->scope->LookupVariable(ident, kTestOnly); 7720 current_block_->scope->LookupVariable(ident, kTestOnly);
7721 if (local == NULL) { 7721 if ((local == NULL) ||
7722 if (!current_function().IsLocalFunction()) { 7722 (local->owner()->HasContextLevel() &&
7723 (local->owner()->context_level() < 1))) {
7724 if ((local == NULL) && !current_function().IsLocalFunction()) {
7723 // We are not generating code for a local function, so all locals, 7725 // We are not generating code for a local function, so all locals,
7724 // captured or not, are in scope. However, 'ident' was not found, so it 7726 // captured or not, are in scope. However, 'ident' was not found, so it
7725 // does not exist. 7727 // does not exist.
7726 return false; 7728 return false;
7727 } 7729 }
7728 // The formal parameter may belong to an enclosing function and may not have 7730 // The formal parameter belongs to an enclosing function and may not have
7729 // been captured, so it was not included in the context scope and it cannot 7731 // been captured, so it was not included in the context scope and it cannot
7730 // be found by LookupVariable. 7732 // be found by LookupVariable.
7733 ASSERT((local == NULL) || local->is_captured());
7731 // 'ident' necessarily refers to the formal parameter of one of the 7734 // 'ident' necessarily refers to the formal parameter of one of the
7732 // enclosing functions, or a compile error would have prevented the 7735 // enclosing functions, or a compile error would have prevented the
7733 // outermost enclosing function to be executed and we would not be compiling 7736 // outermost enclosing function to be executed and we would not be compiling
7734 // this local function. 7737 // this local function.
7735 // Therefore, look for ident directly in the formal parameter lists of the 7738 // Therefore, look for ident directly in the formal parameter lists of the
7736 // enclosing functions. 7739 // enclosing functions.
7737 // There is no need to return the owner_scope, since the caller will not 7740 // There is no need to return the owner_scope, since the caller will not
7738 // create the saved_arguments_descriptor variable, which already exists. 7741 // create the saved_arguments_descriptor variable, which already exists.
7739 Function& function = Function::Handle(innermost_function().raw()); 7742 Function& function = Function::Handle(innermost_function().raw());
7740 String& param_name = String::Handle(); 7743 String& param_name = String::Handle();
(...skipping 1956 matching lines...) Expand 10 before | Expand all | Expand 10 after
9697 void Parser::SkipQualIdent() { 9700 void Parser::SkipQualIdent() {
9698 ASSERT(IsIdentifier()); 9701 ASSERT(IsIdentifier());
9699 ConsumeToken(); 9702 ConsumeToken();
9700 if (CurrentToken() == Token::kPERIOD) { 9703 if (CurrentToken() == Token::kPERIOD) {
9701 ConsumeToken(); // Consume the kPERIOD token. 9704 ConsumeToken(); // Consume the kPERIOD token.
9702 ExpectIdentifier("identifier expected after '.'"); 9705 ExpectIdentifier("identifier expected after '.'");
9703 } 9706 }
9704 } 9707 }
9705 9708
9706 } // namespace dart 9709 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | tests/language/argument_definition4_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698