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

Unified Diff: runtime/vm/object.cc

Issue 10829332: - Split functionality of adding implicit constructors and checking (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 4 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
Index: runtime/vm/object.cc
===================================================================
--- runtime/vm/object.cc (revision 10698)
+++ runtime/vm/object.cc (working copy)
@@ -1500,25 +1500,27 @@
}
-void Class::ApplyPatch(const Class& with) const {
+// Apply the members from the patch class to the original class.
+void Class::ApplyPatch(const Class& patch) const {
ASSERT(!is_finalized());
- const Script& patch_script = Script::Handle(with.script());
- const PatchClass& patch = PatchClass::Handle(
+ const Script& patch_script = Script::Handle(patch.script());
+ const PatchClass& patch_class = PatchClass::Handle(
PatchClass::New(*this, patch_script));
const Array& orig_functions = Array::Handle(functions());
intptr_t orig_len = orig_functions.Length();
- const Array& patch_functions = Array::Handle(with.functions());
+ const Array& patch_functions = Array::Handle(patch.functions());
intptr_t patch_len = patch_functions.Length();
// TODO(iposva): Verify that only patching existing methods and adding only
- // new private methods.
+ // new private methods. Currently we prepend all patch class members to the
+ // members lists which makes them override the orignals.
Function& func = Function::Handle();
const Array& new_functions = Array::Handle(Array::New(patch_len + orig_len));
for (intptr_t i = 0; i < patch_len; i++) {
func ^= patch_functions.At(i);
- func.set_owner(patch);
+ func.set_owner(patch_class);
new_functions.SetAt(i, func);
}
for (intptr_t i = 0; i < orig_len; i++) {
@@ -1530,10 +1532,12 @@
const Array& orig_fields = Array::Handle(fields());
orig_len = orig_fields.Length();
- const Array& patch_fields = Array::Handle(with.fields());
+ const Array& patch_fields = Array::Handle(patch.fields());
patch_len = patch_fields.Length();
- // TODO(iposva): Verify that no duplicate fields are entered.
+ // TODO(iposva): Verify that no duplicate fields are entered. Currently we
+ // prepend all patch class members to the members lists which makes them
+ // override the orignals.
Field& field = Field::Handle();
const Array& new_fields = Array::Handle(Array::New(patch_len + orig_len));
for (intptr_t i = 0; i < patch_len; i++) {
@@ -4130,7 +4134,7 @@
bool is_const,
bool is_abstract,
bool is_external,
- const Class& owner,
+ const Object& owner,
intptr_t token_pos) {
ASSERT(name.IsOneByteString());
ASSERT(!owner.IsNull());
@@ -4163,8 +4167,8 @@
intptr_t token_pos) {
ASSERT(name.IsOneByteString());
ASSERT(!parent.IsNull());
- const Class& parent_class = Class::Handle(parent.Owner());
- ASSERT(!parent_class.IsNull());
+ const Object& parent_owner = Object::Handle(parent.raw_ptr()->owner_);
+ ASSERT(!parent_owner.IsNull());
const Function& result = Function::Handle(
Function::New(name,
RawFunction::kClosureFunction,
@@ -4172,7 +4176,7 @@
/* is_const = */ false,
/* is_abstract = */ false,
/* is_external = */ false,
- parent_class,
+ parent_owner,
token_pos));
result.set_parent_function(parent);
return result.raw();
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/parser.h » ('j') | runtime/vm/parser.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698