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

Unified Diff: runtime/vm/parser.cc

Issue 9109024: Second try at additional nested block in functions. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 8 years, 12 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 | « no previous file | 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 3009)
+++ runtime/vm/parser.cc (working copy)
@@ -546,6 +546,18 @@
};
+static bool HasReturnNode(SequenceNode* seq) {
+ if (seq->length() == 0) {
+ return false;
+ } else if ((seq->length()) == 1 &&
+ (seq->NodeAt(seq->length() - 1)->IsSequenceNode())) {
+ return HasReturnNode(seq->NodeAt(seq->length() - 1)->AsSequenceNode());
+ } else {
+ return seq->NodeAt(seq->length() - 1)->IsReturnNode();
+ }
+}
+
+
void Parser::ParseFunction(ParsedFunction* parsed_function) {
Isolate* isolate = Isolate::Current();
// Compilation can be nested, preserve the ast node id.
@@ -584,8 +596,7 @@
UNREACHABLE();
}
- if ((node_sequence->length() == 0) ||
- !node_sequence->NodeAt(node_sequence->length() - 1)->IsReturnNode()) {
+ if (!HasReturnNode(node_sequence)) {
// Add implicit return node.
node_sequence->Add(new ReturnNode(parser.token_index_));
}
@@ -1834,6 +1845,7 @@
}
}
+ OpenBlock(); // Open a nested scope for the outermost function block.
if (CurrentToken() == Token::kLBRACE) {
ConsumeToken();
ParseStatementSequence();
@@ -1849,6 +1861,8 @@
} else {
UnexpectedToken();
}
+ SequenceNode* body = CloseBlock();
+ current_block_->statements->Add(body);
return CloseBlock();
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698