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

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
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
2623 2622
(...skipping 9608 matching lines...) Expand 10 before | Expand all | Expand 10 after
12232 return chars; 12231 return chars;
12233 } 12232 }
12234 12233
12235 12234
12236 void BoundedType::PrintToJSONStream(JSONStream* stream, bool ref) const { 12235 void BoundedType::PrintToJSONStream(JSONStream* stream, bool ref) const {
12237 JSONObject jsobj(stream); 12236 JSONObject jsobj(stream);
12238 } 12237 }
12239 12238
12240 12239
12241 intptr_t MixinAppType::token_pos() const { 12240 intptr_t MixinAppType::token_pos() const {
12242 return Class::Handle(MixinAppAt(0)).token_pos(); 12241 return AbstractType::Handle(MixinTypeAt(0)).token_pos();
hausner 2013/10/25 17:11:49 Should this be the position of the super type inst
regis 2013/10/25 18:34:25 I think the position of the first mixin type is be
12243 } 12242 }
12244 12243
12245 12244
12246 intptr_t MixinAppType::Depth() const { 12245 intptr_t MixinAppType::Depth() const {
12247 const Array& mixin_apps = Array::Handle(mixins()); 12246 return Array::Handle(mixin_types()).Length();
12248 return mixin_apps.Length();
12249 } 12247 }
12250 12248
12251 12249
12252 RawString* MixinAppType::Name() const { 12250 RawString* MixinAppType::Name() const {
12253 return String::New("MixinAppType"); 12251 return String::New("MixinAppType");
12254 } 12252 }
12255 12253
12256 12254
12257 const char* MixinAppType::ToCString() const { 12255 const char* MixinAppType::ToCString() const {
12258 const char* format = "MixinAppType: super type: %s; first mixin app: %s"; 12256 const char* format = "MixinAppType: super type: %s; first mixin type: %s";
12259 const char* super_type_cstr = String::Handle(AbstractType::Handle( 12257 const char* super_type_cstr = String::Handle(AbstractType::Handle(
12260 SuperType()).Name()).ToCString(); 12258 super_type()).Name()).ToCString();
12261 const char* first_mixin_app_cstr = String::Handle(Class::Handle( 12259 const char* first_mixin_type_cstr = String::Handle(AbstractType::Handle(
12262 MixinAppAt(0)).Name()).ToCString(); 12260 MixinTypeAt(0)).Name()).ToCString();
12263 intptr_t len = OS::SNPrint( 12261 intptr_t len = OS::SNPrint(
12264 NULL, 0, format, super_type_cstr, first_mixin_app_cstr) + 1; 12262 NULL, 0, format, super_type_cstr, first_mixin_type_cstr) + 1;
12265 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); 12263 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
12266 OS::SNPrint(chars, len, format, super_type_cstr, first_mixin_app_cstr); 12264 OS::SNPrint(chars, len, format, super_type_cstr, first_mixin_type_cstr);
12267 return chars; 12265 return chars;
12268 } 12266 }
12269 12267
12270 12268
12271 void MixinAppType::PrintToJSONStream(JSONStream* stream, bool ref) const { 12269 void MixinAppType::PrintToJSONStream(JSONStream* stream, bool ref) const {
12272 JSONObject jsobj(stream); 12270 JSONObject jsobj(stream);
12273 } 12271 }
12274 12272
12275 12273
12276 RawAbstractType* MixinAppType::SuperType() const { 12274 RawAbstractType* MixinAppType::MixinTypeAt(intptr_t depth) const {
12277 return Class::Handle(MixinAppAt(0)).super_type(); 12275 return AbstractType::RawCast(Array::Handle(mixin_types()).At(depth));
12278 } 12276 }
12279 12277
12280 12278
12281 RawClass* MixinAppType::MixinAppAt(intptr_t depth) const { 12279 void MixinAppType::set_super_type(const AbstractType& value) const {
12282 return Class::RawCast(Array::Handle(mixins()).At(depth)); 12280 StorePointer(&raw_ptr()->super_type_, value.raw());
12283 } 12281 }
12284 12282
12285 12283
12286 void MixinAppType::set_mixins(const Array& value) const { 12284 void MixinAppType::set_mixin_types(const Array& value) const {
12287 StorePointer(&raw_ptr()->mixins_, value.raw()); 12285 StorePointer(&raw_ptr()->mixin_types_, value.raw());
12288 } 12286 }
12289 12287
12290 12288
12291 RawMixinAppType* MixinAppType::New() { 12289 RawMixinAppType* MixinAppType::New() {
12292 ASSERT(Isolate::Current()->object_store()->mixin_app_type_class() != 12290 ASSERT(Isolate::Current()->object_store()->mixin_app_type_class() !=
12293 Class::null()); 12291 Class::null());
12294 // MixinAppType objects do not survive finalization, so allocate 12292 // MixinAppType objects do not survive finalization, so allocate
12295 // on new heap. 12293 // on new heap.
12296 RawObject* raw = Object::Allocate(MixinAppType::kClassId, 12294 RawObject* raw = Object::Allocate(MixinAppType::kClassId,
12297 MixinAppType::InstanceSize(), 12295 MixinAppType::InstanceSize(),
12298 Heap::kNew); 12296 Heap::kNew);
12299 return reinterpret_cast<RawMixinAppType*>(raw); 12297 return reinterpret_cast<RawMixinAppType*>(raw);
12300 } 12298 }
12301 12299
12302 12300
12303 RawMixinAppType* MixinAppType::New(const Array& mixins) { 12301 RawMixinAppType* MixinAppType::New(const AbstractType& super_type,
12302 const Array& mixin_types) {
12304 const MixinAppType& result = MixinAppType::Handle(MixinAppType::New()); 12303 const MixinAppType& result = MixinAppType::Handle(MixinAppType::New());
12305 result.set_mixins(mixins); 12304 result.set_super_type(super_type);
12305 result.set_mixin_types(mixin_types);
12306 return result.raw(); 12306 return result.raw();
12307 } 12307 }
12308 12308
12309 12309
12310 const char* Number::ToCString() const { 12310 const char* Number::ToCString() const {
12311 // Number is an interface. No instances of Number should exist. 12311 // Number is an interface. No instances of Number should exist.
12312 UNREACHABLE(); 12312 UNREACHABLE();
12313 return "Number"; 12313 return "Number";
12314 } 12314 }
12315 12315
(...skipping 3272 matching lines...) Expand 10 before | Expand all | Expand 10 after
15588 return "_MirrorReference"; 15588 return "_MirrorReference";
15589 } 15589 }
15590 15590
15591 15591
15592 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { 15592 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const {
15593 JSONObject jsobj(stream); 15593 JSONObject jsobj(stream);
15594 } 15594 }
15595 15595
15596 15596
15597 } // namespace dart 15597 } // namespace dart
OLDNEW
« runtime/vm/object.h ('K') | « runtime/vm/object.h ('k') | runtime/vm/parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698