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

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

Issue 9835070: Do not share local function between closurized and non-closurized enclosing (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 9 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/src/ImplicitClosure2Test.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 3907 matching lines...) Expand 10 before | Expand all | Expand 10 after
3918 String::ZoneHandle(String::NewSymbol("function")); 3918 String::ZoneHandle(String::NewSymbol("function"));
3919 function_name = &anonymous_function_name; 3919 function_name = &anonymous_function_name;
3920 } 3920 }
3921 ASSERT(ident_pos >= 0); 3921 ASSERT(ident_pos >= 0);
3922 3922
3923 if (CurrentToken() != Token::kLPAREN) { 3923 if (CurrentToken() != Token::kLPAREN) {
3924 ErrorMsg("'(' expected"); 3924 ErrorMsg("'(' expected");
3925 } 3925 }
3926 intptr_t function_pos = token_index_; 3926 intptr_t function_pos = token_index_;
3927 3927
3928 // Check whether we have parsed this closure before, in a previous 3928 // Check whether we have parsed this closure function before, in a previous
3929 // compilation. If so, reuse the function object, else create a new one 3929 // compilation. If so, reuse the function object, else create a new one
3930 // and register it in the current class. 3930 // and register it in the current class.
3931 // Note that we cannot share the same closure function between the closurized
3932 // and non-closurized versions of the same parent function.
3931 Function& function = Function::ZoneHandle(); 3933 Function& function = Function::ZoneHandle();
3932 bool is_new_closure = false; 3934 bool is_new_closure = false;
3935 // TODO(hausner): There could be two different closures at the given
3936 // function_pos, one enclosed in a closurized function and one enclosed in the
3937 // non-closurized version of this same function.
3933 function = current_class().LookupClosureFunction(function_pos); 3938 function = current_class().LookupClosureFunction(function_pos);
3934 if (function.IsNull() || (function.token_index() != function_pos)) { 3939 if (function.IsNull() || (function.token_index() != function_pos) ||
3940 (function.parent_function() != current_function().raw())) {
3935 is_new_closure = true; 3941 is_new_closure = true;
3936 function = Function::NewClosureFunction(*function_name, 3942 function = Function::NewClosureFunction(*function_name,
3937 current_function(), 3943 current_function(),
3938 function_pos); 3944 function_pos);
3939 function.set_result_type(result_type); 3945 function.set_result_type(result_type);
3940 current_class().AddClosureFunction(function); 3946 current_class().AddClosureFunction(function);
3941 } 3947 }
3942 3948
3943 // The function type does not need to be determined at compile time, unless 3949 // The function type does not need to be determined at compile time, unless
3944 // the closure is assigned to a function variable and type checks are enabled. 3950 // the closure is assigned to a function variable and type checks are enabled.
3945 // At run time, the function type is derived from the signature class of the 3951 // At run time, the function type is derived from the signature class of the
3946 // closure function and from the type arguments of the instantiator. 3952 // closure function and from the type arguments of the instantiator.
3947 3953
3948 LocalVariable* function_variable = NULL; 3954 LocalVariable* function_variable = NULL;
(...skipping 4292 matching lines...) Expand 10 before | Expand all | Expand 10 after
8241 void Parser::SkipQualIdent() { 8247 void Parser::SkipQualIdent() {
8242 ASSERT(IsIdentifier()); 8248 ASSERT(IsIdentifier());
8243 ConsumeToken(); 8249 ConsumeToken();
8244 if (CurrentToken() == Token::kPERIOD) { 8250 if (CurrentToken() == Token::kPERIOD) {
8245 ConsumeToken(); // Consume the kPERIOD token. 8251 ConsumeToken(); // Consume the kPERIOD token.
8246 ExpectIdentifier("identifier expected after '.'"); 8252 ExpectIdentifier("identifier expected after '.'");
8247 } 8253 }
8248 } 8254 }
8249 8255
8250 } // namespace dart 8256 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | tests/language/src/ImplicitClosure2Test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698