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

Side by Side Diff: runtime/vm/object.cc

Issue 42723003: Register synthesized mixin application classes in the library and reuse them (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/parser.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/object.h" 5 #include "vm/object.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/assembler.h" 9 #include "vm/assembler.h"
10 #include "vm/cpu.h" 10 #include "vm/cpu.h"
(...skipping 2592 matching lines...) Expand 10 before | Expand all | Expand 10 after
2603 2603
2604 2604
2605 void Class::set_interfaces(const Array& value) const { 2605 void Class::set_interfaces(const Array& value) const {
2606 // Verification and resolving of interfaces occurs in finalizer. 2606 // Verification and resolving of interfaces occurs in finalizer.
2607 ASSERT(!value.IsNull()); 2607 ASSERT(!value.IsNull());
2608 StorePointer(&raw_ptr()->interfaces_, value.raw()); 2608 StorePointer(&raw_ptr()->interfaces_, value.raw());
2609 } 2609 }
2610 2610
2611 2611
2612 void Class::set_mixin(const Type& value) const { 2612 void Class::set_mixin(const Type& value) const {
2613 // Resolution and application of mixin type occurs in finalizer.
2614 ASSERT(!value.IsNull()); 2613 ASSERT(!value.IsNull());
2615 StorePointer(&raw_ptr()->mixin_, value.raw()); 2614 StorePointer(&raw_ptr()->mixin_, value.raw());
2616 } 2615 }
2617 2616
2618 2617
2619 bool Class::IsMixinApplication() const { 2618 bool Class::IsMixinApplication() const {
2620 return mixin() != Type::null(); 2619 return mixin() != Type::null();
2621 } 2620 }
2622 2621
2622 bool Class::IsAnonymousMixinApplication() const {
2623 return IsMixinApplication() && !is_mixin_typedef();
2624 }
2623 2625
2624 void Class::set_patch_class(const Class& cls) const { 2626 void Class::set_patch_class(const Class& cls) const {
2625 ASSERT(patch_class() == Class::null()); 2627 ASSERT(patch_class() == Class::null());
2626 StorePointer(&raw_ptr()->patch_class_, cls.raw()); 2628 StorePointer(&raw_ptr()->patch_class_, cls.raw());
2627 } 2629 }
2628 2630
2629 2631
2630 void Class::AddDirectSubclass(const Class& subclass) const { 2632 void Class::AddDirectSubclass(const Class& subclass) const {
2631 ASSERT(!subclass.IsNull()); 2633 ASSERT(!subclass.IsNull());
2632 ASSERT(subclass.SuperClass() == raw()); 2634 ASSERT(subclass.SuperClass() == raw());
(...skipping 9594 matching lines...) Expand 10 before | Expand all | Expand 10 after
12227 return chars; 12229 return chars;
12228 } 12230 }
12229 12231
12230 12232
12231 void BoundedType::PrintToJSONStream(JSONStream* stream, bool ref) const { 12233 void BoundedType::PrintToJSONStream(JSONStream* stream, bool ref) const {
12232 JSONObject jsobj(stream); 12234 JSONObject jsobj(stream);
12233 } 12235 }
12234 12236
12235 12237
12236 intptr_t MixinAppType::token_pos() const { 12238 intptr_t MixinAppType::token_pos() const {
12237 return Class::Handle(MixinAppAt(0)).token_pos(); 12239 return AbstractType::Handle(MixinTypeAt(0)).token_pos();
12238 } 12240 }
12239 12241
12240 12242
12241 intptr_t MixinAppType::Depth() const { 12243 intptr_t MixinAppType::Depth() const {
12242 const Array& mixin_apps = Array::Handle(mixins()); 12244 return Array::Handle(mixin_types()).Length();
12243 return mixin_apps.Length();
12244 } 12245 }
12245 12246
12246 12247
12247 RawString* MixinAppType::Name() const { 12248 RawString* MixinAppType::Name() const {
12248 return String::New("MixinAppType"); 12249 return String::New("MixinAppType");
12249 } 12250 }
12250 12251
12251 12252
12252 const char* MixinAppType::ToCString() const { 12253 const char* MixinAppType::ToCString() const {
12253 const char* format = "MixinAppType: super type: %s; first mixin app: %s"; 12254 const char* format = "MixinAppType: super type: %s; first mixin type: %s";
12254 const char* super_type_cstr = String::Handle(AbstractType::Handle( 12255 const char* super_type_cstr = String::Handle(AbstractType::Handle(
12255 SuperType()).Name()).ToCString(); 12256 super_type()).Name()).ToCString();
12256 const char* first_mixin_app_cstr = String::Handle(Class::Handle( 12257 const char* first_mixin_type_cstr = String::Handle(AbstractType::Handle(
12257 MixinAppAt(0)).Name()).ToCString(); 12258 MixinTypeAt(0)).Name()).ToCString();
12258 intptr_t len = OS::SNPrint( 12259 intptr_t len = OS::SNPrint(
12259 NULL, 0, format, super_type_cstr, first_mixin_app_cstr) + 1; 12260 NULL, 0, format, super_type_cstr, first_mixin_type_cstr) + 1;
12260 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); 12261 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
12261 OS::SNPrint(chars, len, format, super_type_cstr, first_mixin_app_cstr); 12262 OS::SNPrint(chars, len, format, super_type_cstr, first_mixin_type_cstr);
12262 return chars; 12263 return chars;
12263 } 12264 }
12264 12265
12265 12266
12266 void MixinAppType::PrintToJSONStream(JSONStream* stream, bool ref) const { 12267 void MixinAppType::PrintToJSONStream(JSONStream* stream, bool ref) const {
12267 JSONObject jsobj(stream); 12268 JSONObject jsobj(stream);
12268 } 12269 }
12269 12270
12270 12271
12271 RawAbstractType* MixinAppType::SuperType() const { 12272 RawAbstractType* MixinAppType::MixinTypeAt(intptr_t depth) const {
12272 return Class::Handle(MixinAppAt(0)).super_type(); 12273 return AbstractType::RawCast(Array::Handle(mixin_types()).At(depth));
12273 } 12274 }
12274 12275
12275 12276
12276 RawClass* MixinAppType::MixinAppAt(intptr_t depth) const { 12277 void MixinAppType::set_super_type(const AbstractType& value) const {
12277 return Class::RawCast(Array::Handle(mixins()).At(depth)); 12278 StorePointer(&raw_ptr()->super_type_, value.raw());
12278 } 12279 }
12279 12280
12280 12281
12281 void MixinAppType::set_mixins(const Array& value) const { 12282 void MixinAppType::set_mixin_types(const Array& value) const {
12282 StorePointer(&raw_ptr()->mixins_, value.raw()); 12283 StorePointer(&raw_ptr()->mixin_types_, value.raw());
12283 } 12284 }
12284 12285
12285 12286
12286 RawMixinAppType* MixinAppType::New() { 12287 RawMixinAppType* MixinAppType::New() {
12287 ASSERT(Isolate::Current()->object_store()->mixin_app_type_class() != 12288 ASSERT(Isolate::Current()->object_store()->mixin_app_type_class() !=
12288 Class::null()); 12289 Class::null());
12289 // MixinAppType objects do not survive finalization, so allocate 12290 // MixinAppType objects do not survive finalization, so allocate
12290 // on new heap. 12291 // on new heap.
12291 RawObject* raw = Object::Allocate(MixinAppType::kClassId, 12292 RawObject* raw = Object::Allocate(MixinAppType::kClassId,
12292 MixinAppType::InstanceSize(), 12293 MixinAppType::InstanceSize(),
12293 Heap::kNew); 12294 Heap::kNew);
12294 return reinterpret_cast<RawMixinAppType*>(raw); 12295 return reinterpret_cast<RawMixinAppType*>(raw);
12295 } 12296 }
12296 12297
12297 12298
12298 RawMixinAppType* MixinAppType::New(const Array& mixins) { 12299 RawMixinAppType* MixinAppType::New(const AbstractType& super_type,
12300 const Array& mixin_types) {
12299 const MixinAppType& result = MixinAppType::Handle(MixinAppType::New()); 12301 const MixinAppType& result = MixinAppType::Handle(MixinAppType::New());
12300 result.set_mixins(mixins); 12302 result.set_super_type(super_type);
12303 result.set_mixin_types(mixin_types);
12301 return result.raw(); 12304 return result.raw();
12302 } 12305 }
12303 12306
12304 12307
12305 const char* Number::ToCString() const { 12308 const char* Number::ToCString() const {
12306 // Number is an interface. No instances of Number should exist. 12309 // Number is an interface. No instances of Number should exist.
12307 UNREACHABLE(); 12310 UNREACHABLE();
12308 return "Number"; 12311 return "Number";
12309 } 12312 }
12310 12313
(...skipping 3272 matching lines...) Expand 10 before | Expand all | Expand 10 after
15583 return "_MirrorReference"; 15586 return "_MirrorReference";
15584 } 15587 }
15585 15588
15586 15589
15587 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { 15590 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const {
15588 JSONObject jsobj(stream); 15591 JSONObject jsobj(stream);
15589 } 15592 }
15590 15593
15591 15594
15592 } // namespace dart 15595 } // namespace dart
OLDNEW
« 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