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

Unified Diff: runtime/vm/parser.cc

Issue 10665009: Fix parent function of deeply nested closures (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/parser.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/parser.cc
===================================================================
--- runtime/vm/parser.cc (revision 9036)
+++ runtime/vm/parser.cc (working copy)
@@ -254,6 +254,7 @@
current_member_(NULL),
allow_function_literals_(true),
current_function_(Function::Handle()),
+ innermost_function_(Function::Handle()),
current_class_(Class::Handle()),
library_(library),
try_blocks_list_(NULL),
@@ -276,6 +277,7 @@
current_member_(NULL),
allow_function_literals_(true),
current_function_(function),
+ innermost_function_(Function::Handle(function.raw())),
current_class_(Class::Handle(current_function_.owner())),
library_(Library::Handle(current_class_.library())),
try_blocks_list_(NULL),
@@ -301,6 +303,11 @@
}
+const Function& Parser::innermost_function() const {
+ return innermost_function_;
+}
+
+
const Class& Parser::current_class() const {
return current_class_;
}
@@ -2075,6 +2082,8 @@
SequenceNode* Parser::ParseFunc(const Function& func,
Array& default_parameter_values) {
TRACE_PARSER("ParseFunc");
+ innermost_function_ = func.raw();
regis 2012/06/22 23:58:32 You should assert that func.parent() == innermost_
hausner 2012/06/23 00:15:04 Good catch! Actually, I initialize innermost_func
+
if (func.IsConstructor()) {
return ParseConstructor(func, default_parameter_values);
}
@@ -4197,10 +4206,10 @@
// non-closurized version of this same function.
function = current_class().LookupClosureFunction(function_pos);
if (function.IsNull() || (function.token_index() != function_pos) ||
- (function.parent_function() != current_function().raw())) {
+ (function.parent_function() != innermost_function().raw())) {
is_new_closure = true;
function = Function::NewClosureFunction(*function_name,
- current_function(),
+ innermost_function(),
function_pos);
function.set_result_type(result_type);
current_class().AddClosureFunction(function);
@@ -5386,7 +5395,7 @@
// Finally parse the 'finally' block.
SequenceNode* finally_block = NULL;
if (CurrentToken() == Token::kFINALLY) {
- current_function_.set_is_optimizable(false);
+ current_function().set_is_optimizable(false);
ConsumeToken(); // Consume the 'finally'.
const intptr_t finally_pos = token_index_;
// Add the finally block to the exit points recorded so far.
« no previous file with comments | « runtime/vm/parser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698