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

Unified Diff: runtime/vm/parser.cc

Issue 8380023: Implicitly move super constructor call (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 9 years, 2 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 | tests/language/language.status » ('j') | 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 642)
+++ runtime/vm/parser.cc (working copy)
@@ -1363,7 +1363,7 @@
void Parser::ParseInitializers(const Class& cls) {
TRACE_PARSER("ParseInitializers");
LocalVariable* receiver = current_block_->scope->VariableAt(0);
- bool super_init_seen = false;
+ AstNode* super_init_statement = NULL;
if (CurrentToken() == Token::kCOLON) {
if ((LookaheadToken(1) == Token::kTHIS) &&
((LookaheadToken(2) == Token::kLPAREN) ||
@@ -1380,26 +1380,26 @@
do {
ConsumeToken(); // Colon or comma.
- AstNode* init_statement = NULL;
if (CurrentToken() == Token::kSUPER) {
- if (super_init_seen) {
+ if (super_init_statement != NULL) {
ErrorMsg("Duplicate call to super constructor");
}
- init_statement = ParseSuperInitializer(cls, receiver);
- super_init_seen = true;
+ super_init_statement = ParseSuperInitializer(cls, receiver);
} else {
- init_statement = ParseInitializer(cls, receiver);
+ AstNode* init_statement = ParseInitializer(cls, receiver);
+ current_block_->statements->Add(init_statement);
}
- current_block_->statements->Add(init_statement);
} while (CurrentToken() == Token::kCOMMA);
}
- // Generate implicit super() if we haven't seen an explicit super call
- // or constructor redirection.
- // Omit the implicit super() if there is no super class (i.e.
- // we're not compiling class Object), or if the super class is an
- // artificially generated "wrapper class" that has no constructor.
- if (!super_init_seen) {
+ if (super_init_statement != NULL) {
+ // TODO(hausner): Move explicit supercall to the end of the initializer
regis 2011/10/24 22:39:19 Is this TODO still needed?
+ // list to avoid executing constructor code on partially initialized
+ // objects. Issue 4995181.
+ current_block_->statements->Add(super_init_statement);
+ } else {
+ // Generate implicit super() if we haven't seen an explicit super call
+ // or constructor redirection.
GenerateSuperInitializerCall(cls, receiver);
}
« no previous file with comments | « no previous file | tests/language/language.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698