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

Unified Diff: runtime/vm/object.cc

Issue 12210127: First stab at mixins in VM compiler (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 | « runtime/vm/object.h ('k') | runtime/vm/parser.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object.cc
===================================================================
--- runtime/vm/object.cc (revision 18475)
+++ runtime/vm/object.cc (working copy)
@@ -2075,6 +2075,13 @@
}
+void Class::set_mixin(const Type& value) const {
+ // Resolution and application of mixin type occurs in finalizer.
+ ASSERT(!value.IsNull());
+ StorePointer(&raw_ptr()->mixin_, value.raw());
+}
+
+
void Class::AddDirectSubclass(const Class& subclass) const {
ASSERT(!subclass.IsNull());
ASSERT(subclass.SuperClass() == raw());
@@ -4082,6 +4089,15 @@
}
+// The compiler generates an implicit constructor if a class definition
+// does not contain an explicit constructor or factory. The implicit
+// constructor has the same token position as the owner class.
+bool Function::IsImplicitConstructor() const {
+ return IsConstructor() &&
+ (token_pos() == Class::Handle(Owner()).token_pos());
+}
+
+
bool Function::IsImplicitClosureFunction() const {
if (!IsClosureFunction()) {
return false;
@@ -4141,6 +4157,24 @@
}
+RawFunction* Function::Clone(const Class& new_owner) const {
+ ASSERT(!IsConstructor());
+ Function& clone = Function::Handle();
+ clone ^= Object::Clone(*this, Heap::kOld);
+ const Class& owner = Class::Handle(this->Owner());
+ const PatchClass& clone_owner =
+ PatchClass::Handle(PatchClass::New(new_owner, owner));
+ clone.set_owner(clone_owner);
+ clone.StorePointer(&clone.raw_ptr()->code_, Code::null());
+ clone.StorePointer(&clone.raw_ptr()->unoptimized_code_, Code::null());
+ clone.set_usage_counter(0);
+ clone.set_deoptimization_counter(0);
+ clone.set_optimized_instruction_count(0);
+ clone.set_optimized_call_site_count(0);
+ return clone.raw();
+}
+
+
RawFunction* Function::NewClosureFunction(const String& name,
const Function& parent,
intptr_t token_pos) {
@@ -4379,6 +4413,16 @@
}
+RawClass* Function::origin() const {
+ const Object& obj = Object::Handle(raw_ptr()->owner_);
+ if (obj.IsClass()) {
+ return Class::Cast(obj).raw();
+ }
+ ASSERT(obj.IsPatchClass());
+ return PatchClass::Cast(obj).source_class();
+}
+
+
RawScript* Function::script() const {
const Object& obj = Object::Handle(raw_ptr()->owner_);
if (obj.IsClass()) {
@@ -4638,6 +4682,26 @@
}
+RawClass* Field::owner() const {
+ const Object& obj = Object::Handle(raw_ptr()->owner_);
+ if (obj.IsClass()) {
+ return Class::Cast(obj).raw();
+ }
+ ASSERT(obj.IsPatchClass());
+ return PatchClass::Cast(obj).patched_class();
+}
+
+
+RawClass* Field::origin() const {
+ const Object& obj = Object::Handle(raw_ptr()->owner_);
+ if (obj.IsClass()) {
+ return Class::Cast(obj).raw();
+ }
+ ASSERT(obj.IsPatchClass());
+ return PatchClass::Cast(obj).source_class();
+}
+
+
RawInstance* Field::value() const {
ASSERT(is_static()); // Valid only for static dart fields.
return raw_ptr()->value_;
@@ -4689,6 +4753,21 @@
}
+
+RawField* Field::Clone(const Class& new_owner) const {
+ Field& clone = Field::Handle();
+ clone ^= Object::Clone(*this, Heap::kOld);
+ const Class& owner = Class::Handle(this->owner());
+ const PatchClass& clone_owner =
+ PatchClass::Handle(PatchClass::New(new_owner, owner));
+ clone.set_owner(clone_owner);
+ if (!clone.is_static()) {
+ clone.SetOffset(0);
+ }
+ return clone.raw();
+}
+
+
RawString* Field::UserVisibleName() const {
const String& str = String::Handle(name());
return IdentifierPrettyName(str);
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698