OLD | NEW |
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 1583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1594 } | 1594 } |
1595 } | 1595 } |
1596 | 1596 |
1597 | 1597 |
1598 void Object::PrintJSONImpl(JSONStream* stream, bool ref) const { | 1598 void Object::PrintJSONImpl(JSONStream* stream, bool ref) const { |
1599 JSONObject jsobj(stream); | 1599 JSONObject jsobj(stream); |
1600 AddTypeProperties(&jsobj, "Object", JSONType(), ref); | 1600 AddTypeProperties(&jsobj, "Object", JSONType(), ref); |
1601 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); | 1601 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); |
1602 const intptr_t id = ring->GetIdForObject(raw()); | 1602 const intptr_t id = ring->GetIdForObject(raw()); |
1603 jsobj.AddPropertyF("id", "objects/%" Pd "", id); | 1603 jsobj.AddPropertyF("id", "objects/%" Pd "", id); |
| 1604 if (ref) { |
| 1605 return; |
| 1606 } |
| 1607 Class& cls = Class::Handle(this->clazz()); |
| 1608 jsobj.AddProperty("class", cls); |
| 1609 jsobj.AddProperty("size", raw()->Size()); |
1604 } | 1610 } |
1605 | 1611 |
1606 | 1612 |
1607 RawString* Object::DictionaryName() const { | 1613 RawString* Object::DictionaryName() const { |
1608 return String::null(); | 1614 return String::null(); |
1609 } | 1615 } |
1610 | 1616 |
1611 | 1617 |
1612 void Object::InitializeObject(uword address, intptr_t class_id, intptr_t size) { | 1618 void Object::InitializeObject(uword address, intptr_t class_id, intptr_t size) { |
1613 // TODO(iposva): Get a proper halt instruction from the assembler which | 1619 // TODO(iposva): Get a proper halt instruction from the assembler which |
(...skipping 1903 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3517 | 3523 |
3518 RawType* Class::CanonicalTypeFromIndex(intptr_t idx) const { | 3524 RawType* Class::CanonicalTypeFromIndex(intptr_t idx) const { |
3519 Type& type = Type::Handle(); | 3525 Type& type = Type::Handle(); |
3520 if (idx == 0) { | 3526 if (idx == 0) { |
3521 type = CanonicalType(); | 3527 type = CanonicalType(); |
3522 if (!type.IsNull()) { | 3528 if (!type.IsNull()) { |
3523 return type.raw(); | 3529 return type.raw(); |
3524 } | 3530 } |
3525 } | 3531 } |
3526 Object& types = Object::Handle(canonical_types()); | 3532 Object& types = Object::Handle(canonical_types()); |
3527 if (types.IsNull()) { | 3533 if (types.IsNull() || !types.IsArray()) { |
3528 return Type::null(); | 3534 return Type::null(); |
3529 } | 3535 } |
3530 if ((idx < 0) || (idx >= Array::Cast(types).Length())) { | 3536 if ((idx < 0) || (idx >= Array::Cast(types).Length())) { |
3531 return Type::null(); | 3537 return Type::null(); |
3532 } | 3538 } |
3533 type ^= Array::Cast(types).At(idx); | 3539 type ^= Array::Cast(types).At(idx); |
3534 ASSERT(!type.IsNull()); | 3540 ASSERT(!type.IsNull()); |
3535 return type.raw(); | 3541 return type.raw(); |
3536 } | 3542 } |
3537 | 3543 |
(...skipping 10398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13936 bool ref) const { | 13942 bool ref) const { |
13937 Class& cls = Class::Handle(this->clazz()); | 13943 Class& cls = Class::Handle(this->clazz()); |
13938 jsobj->AddProperty("class", cls); | 13944 jsobj->AddProperty("class", cls); |
13939 // TODO(turnidge): Provide the type arguments here too. | 13945 // TODO(turnidge): Provide the type arguments here too. |
13940 if (ref) { | 13946 if (ref) { |
13941 return; | 13947 return; |
13942 } | 13948 } |
13943 | 13949 |
13944 if (raw()->IsHeapObject()) { | 13950 if (raw()->IsHeapObject()) { |
13945 jsobj->AddProperty("size", raw()->Size()); | 13951 jsobj->AddProperty("size", raw()->Size()); |
| 13952 } else { |
| 13953 jsobj->AddProperty("size", (intptr_t)0); |
13946 } | 13954 } |
13947 | 13955 |
13948 // Walk the superclass chain, adding all instance fields. | 13956 // Walk the superclass chain, adding all instance fields. |
13949 { | 13957 { |
13950 Instance& fieldValue = Instance::Handle(); | 13958 Instance& fieldValue = Instance::Handle(); |
13951 JSONArray jsarr(jsobj, "fields"); | 13959 JSONArray jsarr(jsobj, "fields"); |
13952 while (!cls.IsNull()) { | 13960 while (!cls.IsNull()) { |
13953 const Array& field_array = Array::Handle(cls.fields()); | 13961 const Array& field_array = Array::Handle(cls.fields()); |
13954 Field& field = Field::Handle(); | 13962 Field& field = Field::Handle(); |
13955 if (!field_array.IsNull()) { | 13963 if (!field_array.IsNull()) { |
(...skipping 1156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15112 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); | 15120 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); |
15113 const intptr_t id = ring->GetIdForObject(raw()); | 15121 const intptr_t id = ring->GetIdForObject(raw()); |
15114 jsobj.AddPropertyF("id", "objects/%" Pd "", id); | 15122 jsobj.AddPropertyF("id", "objects/%" Pd "", id); |
15115 } | 15123 } |
15116 const String& user_name = String::Handle(PrettyName()); | 15124 const String& user_name = String::Handle(PrettyName()); |
15117 const String& vm_name = String::Handle(Name()); | 15125 const String& vm_name = String::Handle(Name()); |
15118 AddNameProperties(&jsobj, user_name, vm_name); | 15126 AddNameProperties(&jsobj, user_name, vm_name); |
15119 if (ref) { | 15127 if (ref) { |
15120 return; | 15128 return; |
15121 } | 15129 } |
15122 jsobj.AddProperty("typeArguments", TypeArguments::Handle(arguments())); | 15130 const TypeArguments& typeArgs = TypeArguments::Handle(arguments()); |
| 15131 if (!typeArgs.IsNull()) { |
| 15132 jsobj.AddProperty("typeArguments", typeArgs); |
| 15133 } |
15123 } | 15134 } |
15124 | 15135 |
15125 | 15136 |
15126 bool TypeRef::IsInstantiated(GrowableObjectArray* trail) const { | 15137 bool TypeRef::IsInstantiated(GrowableObjectArray* trail) const { |
15127 if (TestAndAddToTrail(&trail)) { | 15138 if (TestAndAddToTrail(&trail)) { |
15128 return true; | 15139 return true; |
15129 } | 15140 } |
15130 return AbstractType::Handle(type()).IsInstantiated(trail); | 15141 return AbstractType::Handle(type()).IsInstantiated(trail); |
15131 } | 15142 } |
15132 | 15143 |
(...skipping 5547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
20680 return tag_label.ToCString(); | 20691 return tag_label.ToCString(); |
20681 } | 20692 } |
20682 | 20693 |
20683 | 20694 |
20684 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 20695 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { |
20685 Instance::PrintJSONImpl(stream, ref); | 20696 Instance::PrintJSONImpl(stream, ref); |
20686 } | 20697 } |
20687 | 20698 |
20688 | 20699 |
20689 } // namespace dart | 20700 } // namespace dart |
OLD | NEW |