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

Unified Diff: runtime/vm/ast.cc

Issue 10050022: Fix lazy initialization of static fields (issue 2472). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 8 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 | runtime/vm/parser.cc » ('j') | runtime/vm/parser.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/ast.cc
===================================================================
--- runtime/vm/ast.cc (revision 6422)
+++ runtime/vm/ast.cc (working copy)
@@ -406,7 +406,18 @@
AstNode* StaticGetterNode::MakeAssignmentNode(AstNode* rhs) {
- return new StaticSetterNode(token_index(), cls(), field_name(), rhs);
+ // If no setter exist, set the field directly.
+ const String& setter_name = String::Handle(Field::SetterName(field_name()));
+ const Function& function =
+ Function::ZoneHandle(cls().LookupStaticFunction(setter_name));
+ if (function.IsNull()) {
+ const Field& field = Field::ZoneHandle(
+ cls().LookupStaticField(field_name()));
+ ASSERT(!field.IsNull());
srdjan 2012/04/11 19:52:51 Please add a comment why the field must exist.
regis 2012/04/11 21:11:24 Done. I added a comment and debugging code verifyi
+ return new StoreStaticFieldNode(token_index(), field, rhs);
+ } else {
+ return new StaticSetterNode(token_index(), cls(), field_name(), rhs);
+ }
}
« no previous file with comments | « no previous file | runtime/vm/parser.cc » ('j') | runtime/vm/parser.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698