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

Unified Diff: runtime/vm/class_finalizer.cc

Issue 12261029: Minor improvement in mixin application (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 10 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/class_finalizer.cc
===================================================================
--- runtime/vm/class_finalizer.cc (revision 18491)
+++ runtime/vm/class_finalizer.cc (working copy)
@@ -1121,8 +1121,19 @@
class_name.ToCString());
}
- const Array& functions = Array::Handle(mixin_cls.functions());
+ const GrowableObjectArray& cloned_funcs =
+ GrowableObjectArray::Handle(GrowableObjectArray::New());
+ Array& functions = Array::Handle();
Function& func = Function::Handle();
+ // The parser creates the mixin application class and adds just
+ // one function, the implicit constructor.
+ functions = cls.functions();
+ ASSERT(functions.Length() == 1);
+ func ^= functions.At(0);
+ ASSERT(func.IsImplicitConstructor());
+ cloned_funcs.Add(func);
+ // Now clone the functions from the mixin class.
+ functions = mixin_cls.functions();
const intptr_t num_functions = functions.Length();
for (int i = 0; i < num_functions; i++) {
func ^= functions.At(i);
@@ -1138,9 +1149,15 @@
}
if (!func.is_static()) {
func = func.Clone(cls);
- cls.AddFunction(func);
+ cloned_funcs.Add(func);
}
}
+ functions = Array::MakeArray(cloned_funcs);
+ cls.SetFunctions(functions);
+
+ // Now clone the fields from the mixin class. There should be no
+ // existing fields in the mixin application class.
+ ASSERT(Array::Handle(cls.fields()).Length() == 0);
Array& fields = Array::Handle(mixin_cls.fields());
Field& field = Field::Handle();
const GrowableObjectArray& cloned_fields =
@@ -1154,7 +1171,6 @@
}
}
fields = Array::MakeArray(cloned_fields);
- ASSERT(Array::Handle(cls.fields()).Length() == 0);
cls.SetFields(fields);
}
« 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