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 6347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6358 jsobj.AddProperty("is_static", is_static()); | 6358 jsobj.AddProperty("is_static", is_static()); |
6359 jsobj.AddProperty("is_const", is_const()); | 6359 jsobj.AddProperty("is_const", is_const()); |
6360 jsobj.AddProperty("is_optimizable", is_optimizable()); | 6360 jsobj.AddProperty("is_optimizable", is_optimizable()); |
6361 jsobj.AddProperty("is_inlinable", IsInlineable()); | 6361 jsobj.AddProperty("is_inlinable", IsInlineable()); |
6362 jsobj.AddProperty("unoptimized_code", Object::Handle(unoptimized_code())); | 6362 jsobj.AddProperty("unoptimized_code", Object::Handle(unoptimized_code())); |
6363 jsobj.AddProperty("usage_counter", usage_counter()); | 6363 jsobj.AddProperty("usage_counter", usage_counter()); |
6364 jsobj.AddProperty("optimized_call_site_count", optimized_call_site_count()); | 6364 jsobj.AddProperty("optimized_call_site_count", optimized_call_site_count()); |
6365 jsobj.AddProperty("code", Object::Handle(CurrentCode())); | 6365 jsobj.AddProperty("code", Object::Handle(CurrentCode())); |
6366 jsobj.AddProperty("deoptimizations", | 6366 jsobj.AddProperty("deoptimizations", |
6367 static_cast<intptr_t>(deoptimization_counter())); | 6367 static_cast<intptr_t>(deoptimization_counter())); |
| 6368 |
| 6369 const Script& script = Script::Handle(this->script()); |
| 6370 if (!script.IsNull()) { |
| 6371 jsobj.AddProperty("script", script); |
| 6372 jsobj.AddProperty("token_pos", token_pos()); |
| 6373 jsobj.AddProperty("end_token_pos", end_token_pos()); |
| 6374 } |
6368 } | 6375 } |
6369 | 6376 |
6370 | 6377 |
6371 void ClosureData::set_context_scope(const ContextScope& value) const { | 6378 void ClosureData::set_context_scope(const ContextScope& value) const { |
6372 StorePointer(&raw_ptr()->context_scope_, value.raw()); | 6379 StorePointer(&raw_ptr()->context_scope_, value.raw()); |
6373 } | 6380 } |
6374 | 6381 |
6375 | 6382 |
6376 void ClosureData::set_implicit_static_closure(const Instance& closure) const { | 6383 void ClosureData::set_implicit_static_closure(const Instance& closure) const { |
6377 ASSERT(!closure.IsNull()); | 6384 ASSERT(!closure.IsNull()); |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6656 jsobj.AddPropertyF("id", "classes/%" Pd "/fields/%" Pd "", cid, id); | 6663 jsobj.AddPropertyF("id", "classes/%" Pd "/fields/%" Pd "", cid, id); |
6657 jsobj.AddProperty("name", internal_field_name); | 6664 jsobj.AddProperty("name", internal_field_name); |
6658 jsobj.AddProperty("user_name", field_name); | 6665 jsobj.AddProperty("user_name", field_name); |
6659 if (is_static()) { | 6666 if (is_static()) { |
6660 const Instance& valueObj = Instance::Handle(value()); | 6667 const Instance& valueObj = Instance::Handle(value()); |
6661 jsobj.AddProperty("value", valueObj); | 6668 jsobj.AddProperty("value", valueObj); |
6662 } | 6669 } |
6663 | 6670 |
6664 jsobj.AddProperty("owner", cls); | 6671 jsobj.AddProperty("owner", cls); |
6665 | 6672 |
6666 // TODO(turnidge): Once the vmservice supports returning types, | |
6667 // return the type here instead of the class. | |
6668 AbstractType& declared_type = AbstractType::Handle(type()); | 6673 AbstractType& declared_type = AbstractType::Handle(type()); |
6669 if (declared_type.HasResolvedTypeClass()) { | 6674 jsobj.AddProperty("declared_type", declared_type); |
6670 cls = declared_type.type_class(); | |
6671 jsobj.AddProperty("declared_type", cls); | |
6672 } | |
6673 | |
6674 jsobj.AddProperty("static", is_static()); | 6675 jsobj.AddProperty("static", is_static()); |
6675 jsobj.AddProperty("final", is_final()); | 6676 jsobj.AddProperty("final", is_final()); |
6676 jsobj.AddProperty("const", is_const()); | 6677 jsobj.AddProperty("const", is_const()); |
6677 if (ref) { | 6678 if (ref) { |
6678 return; | 6679 return; |
6679 } | 6680 } |
6680 jsobj.AddProperty("guard_nullable", is_nullable()); | 6681 jsobj.AddProperty("guard_nullable", is_nullable()); |
6681 if (guarded_cid() == kIllegalCid) { | 6682 if (guarded_cid() == kIllegalCid) { |
6682 jsobj.AddProperty("guard_class", "unknown"); | 6683 jsobj.AddProperty("guard_class", "unknown"); |
6683 } else if (guarded_cid() == kDynamicCid) { | 6684 } else if (guarded_cid() == kDynamicCid) { |
(...skipping 5781 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12465 } else if (raw() == Object::sentinel().raw()) { | 12466 } else if (raw() == Object::sentinel().raw()) { |
12466 return "<not initialized>"; | 12467 return "<not initialized>"; |
12467 } else if (raw() == Object::transition_sentinel().raw()) { | 12468 } else if (raw() == Object::transition_sentinel().raw()) { |
12468 return "<being initialized>"; | 12469 return "<being initialized>"; |
12469 } else { | 12470 } else { |
12470 return ToCString(); | 12471 return ToCString(); |
12471 } | 12472 } |
12472 } | 12473 } |
12473 | 12474 |
12474 | 12475 |
12475 void Instance::PrintToJSONStream(JSONStream* stream, bool ref) const { | 12476 void Instance::PrintSharedInstanceJSON(JSONObject* jsobj, bool ref) const { |
12476 JSONObject jsobj(stream); | 12477 jsobj->AddProperty("type", JSONType(ref)); |
12477 Class& cls = Class::Handle(this->clazz()); | 12478 Class& cls = Class::Handle(this->clazz()); |
12478 | 12479 jsobj->AddProperty("class", cls); |
12479 // TODO(turnidge): Handle <optimized out> like other null-like values. | |
12480 if (IsNull()) { | |
12481 jsobj.AddProperty("type", ref ? "@Null" : "Null"); | |
12482 jsobj.AddProperty("id", "objects/null"); | |
12483 jsobj.AddProperty("preview", "null"); | |
12484 return; | |
12485 } else if (raw() == Object::sentinel().raw()) { | |
12486 jsobj.AddProperty("type", ref ? "@Null" : "Null"); | |
12487 jsobj.AddProperty("id", "objects/not-initialized"); | |
12488 jsobj.AddProperty("preview", "<not initialized>"); | |
12489 return; | |
12490 } else if (raw() == Object::transition_sentinel().raw()) { | |
12491 jsobj.AddProperty("type", ref ? "@Null" : "Null"); | |
12492 jsobj.AddProperty("id", "objects/being-initialized"); | |
12493 jsobj.AddProperty("preview", "<being initialized>"); | |
12494 return; | |
12495 } else if (raw() == Symbols::OptimizedOut().raw()) { | |
12496 // TODO(turnidge): This is a hack. The user could have this | |
12497 // special string in their program. Fixing this involves updating | |
12498 // the debugging api a bit. | |
12499 jsobj.AddProperty("type", ref ? "@Null" : "Null"); | |
12500 jsobj.AddProperty("id", "objects/optimized-out"); | |
12501 jsobj.AddProperty("preview", "<optimized out>"); | |
12502 return; | |
12503 } else { | |
12504 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); | |
12505 const intptr_t id = ring->GetIdForObject(raw()); | |
12506 if (IsClosure()) { | |
12507 const Function& closureFunc = Function::Handle(Closure::function(*this)); | |
12508 jsobj.AddProperty("closureFunc", closureFunc); | |
12509 jsobj.AddProperty("type", ref ? "@Closure" : "Closure"); | |
12510 } else { | |
12511 jsobj.AddProperty("type", JSONType(ref)); | |
12512 } | |
12513 jsobj.AddPropertyF("id", "objects/%" Pd "", id); | |
12514 jsobj.AddProperty("class", cls); | |
12515 jsobj.AddProperty("preview", ToUserCString(40)); | |
12516 } | |
12517 if (ref) { | 12480 if (ref) { |
12518 return; | 12481 return; |
12519 } | 12482 } |
12520 | 12483 |
| 12484 jsobj->AddProperty("size", raw()->Size()); |
| 12485 |
12521 // Walk the superclass chain, adding all instance fields. | 12486 // Walk the superclass chain, adding all instance fields. |
12522 { | 12487 { |
12523 Instance& fieldValue = Instance::Handle(); | 12488 Instance& fieldValue = Instance::Handle(); |
12524 JSONArray jsarr(&jsobj, "fields"); | 12489 JSONArray jsarr(jsobj, "fields"); |
12525 while (!cls.IsNull()) { | 12490 while (!cls.IsNull()) { |
12526 const Array& field_array = Array::Handle(cls.fields()); | 12491 const Array& field_array = Array::Handle(cls.fields()); |
12527 Field& field = Field::Handle(); | 12492 Field& field = Field::Handle(); |
12528 if (!field_array.IsNull()) { | 12493 if (!field_array.IsNull()) { |
12529 for (intptr_t i = 0; i < field_array.Length(); i++) { | 12494 for (intptr_t i = 0; i < field_array.Length(); i++) { |
12530 field ^= field_array.At(i); | 12495 field ^= field_array.At(i); |
12531 if (!field.is_static()) { | 12496 if (!field.is_static()) { |
12532 fieldValue ^= GetField(field); | 12497 fieldValue ^= GetField(field); |
12533 JSONObject jsfield(&jsarr); | 12498 JSONObject jsfield(&jsarr); |
12534 jsfield.AddProperty("decl", field); | 12499 jsfield.AddProperty("decl", field); |
12535 jsfield.AddProperty("value", fieldValue); | 12500 jsfield.AddProperty("value", fieldValue); |
12536 } | 12501 } |
12537 } | 12502 } |
12538 } | 12503 } |
12539 cls = cls.SuperClass(); | 12504 cls = cls.SuperClass(); |
12540 } | 12505 } |
12541 } | 12506 } |
12542 | 12507 |
12543 if (NumNativeFields() > 0) { | 12508 if (NumNativeFields() > 0) { |
12544 JSONArray jsarr(&jsobj, "nativeFields"); | 12509 JSONArray jsarr(jsobj, "nativeFields"); |
12545 for (intptr_t i = 0; i < NumNativeFields(); i++) { | 12510 for (intptr_t i = 0; i < NumNativeFields(); i++) { |
12546 intptr_t value = GetNativeField(i); | 12511 intptr_t value = GetNativeField(i); |
12547 JSONObject jsfield(&jsarr); | 12512 JSONObject jsfield(&jsarr); |
12548 jsfield.AddProperty("index", i); | 12513 jsfield.AddProperty("index", i); |
12549 jsfield.AddProperty("value", value); | 12514 jsfield.AddProperty("value", value); |
12550 } | 12515 } |
12551 } | 12516 } |
12552 | |
12553 jsobj.AddProperty("size", raw()->Size()); | |
12554 } | 12517 } |
12555 | 12518 |
12556 | 12519 |
| 12520 void Instance::PrintToJSONStream(JSONStream* stream, bool ref) const { |
| 12521 JSONObject jsobj(stream); |
| 12522 |
| 12523 // Handle certain special instance values. |
| 12524 if (IsNull()) { |
| 12525 jsobj.AddProperty("type", ref ? "@Null" : "Null"); |
| 12526 jsobj.AddProperty("id", "objects/null"); |
| 12527 jsobj.AddProperty("preview", "null"); |
| 12528 return; |
| 12529 } else if (raw() == Object::sentinel().raw()) { |
| 12530 jsobj.AddProperty("type", ref ? "@Null" : "Null"); |
| 12531 jsobj.AddProperty("id", "objects/not-initialized"); |
| 12532 jsobj.AddProperty("preview", "<not initialized>"); |
| 12533 return; |
| 12534 } else if (raw() == Object::transition_sentinel().raw()) { |
| 12535 jsobj.AddProperty("type", ref ? "@Null" : "Null"); |
| 12536 jsobj.AddProperty("id", "objects/being-initialized"); |
| 12537 jsobj.AddProperty("preview", "<being initialized>"); |
| 12538 return; |
| 12539 } else if (raw() == Symbols::OptimizedOut().raw()) { |
| 12540 // TODO(turnidge): This is a hack. The user could have this |
| 12541 // special string in their program. Fixing this involves updating |
| 12542 // the debugging api a bit. |
| 12543 jsobj.AddProperty("type", ref ? "@Null" : "Null"); |
| 12544 jsobj.AddProperty("id", "objects/optimized-out"); |
| 12545 jsobj.AddProperty("preview", "<optimized out>"); |
| 12546 return; |
| 12547 } |
| 12548 |
| 12549 PrintSharedInstanceJSON(&jsobj, ref); |
| 12550 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); |
| 12551 const intptr_t id = ring->GetIdForObject(raw()); |
| 12552 if (IsClosure()) { |
| 12553 const Function& closureFunc = Function::Handle(Closure::function(*this)); |
| 12554 jsobj.AddProperty("closureFunc", closureFunc); |
| 12555 } |
| 12556 jsobj.AddPropertyF("id", "objects/%" Pd "", id); |
| 12557 jsobj.AddProperty("preview", ToUserCString(40)); |
| 12558 if (ref) { |
| 12559 return; |
| 12560 } |
| 12561 } |
| 12562 |
| 12563 |
12557 bool AbstractType::IsResolved() const { | 12564 bool AbstractType::IsResolved() const { |
12558 // AbstractType is an abstract class. | 12565 // AbstractType is an abstract class. |
12559 UNREACHABLE(); | 12566 UNREACHABLE(); |
12560 return false; | 12567 return false; |
12561 } | 12568 } |
12562 | 12569 |
12563 | 12570 |
12564 bool AbstractType::HasResolvedTypeClass() const { | 12571 bool AbstractType::HasResolvedTypeClass() const { |
12565 // AbstractType is an abstract class. | 12572 // AbstractType is an abstract class. |
12566 UNREACHABLE(); | 12573 UNREACHABLE(); |
(...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13486 OS::SNPrint(chars, len, format, class_name, args_cstr); | 13493 OS::SNPrint(chars, len, format, class_name, args_cstr); |
13487 return chars; | 13494 return chars; |
13488 } | 13495 } |
13489 } else { | 13496 } else { |
13490 return "Unresolved Type"; | 13497 return "Unresolved Type"; |
13491 } | 13498 } |
13492 } | 13499 } |
13493 | 13500 |
13494 | 13501 |
13495 void Type::PrintToJSONStream(JSONStream* stream, bool ref) const { | 13502 void Type::PrintToJSONStream(JSONStream* stream, bool ref) const { |
13496 // TODO(koda): Decide whether to assign stable ids to non-canonical types. | 13503 JSONObject jsobj(stream); |
13497 if (!IsCanonical()) { | 13504 PrintSharedInstanceJSON(&jsobj, ref); |
13498 return Object::PrintToJSONStream(stream, ref); | 13505 if (IsCanonical()) { |
| 13506 const Class& type_cls = Class::Handle(type_class()); |
| 13507 intptr_t id = type_cls.FindCanonicalTypeIndex(*this); |
| 13508 ASSERT(id >= 0); |
| 13509 intptr_t cid = type_cls.id(); |
| 13510 jsobj.AddPropertyF("id", "classes/%" Pd "/types/%" Pd "", cid, id); |
| 13511 jsobj.AddProperty("type_class", type_cls); |
| 13512 } else { |
| 13513 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); |
| 13514 const intptr_t id = ring->GetIdForObject(raw()); |
| 13515 jsobj.AddPropertyF("id", "objects/%" Pd "", id); |
13499 } | 13516 } |
13500 ASSERT(IsCanonical()); | |
13501 JSONObject jsobj(stream); | |
13502 jsobj.AddProperty("type", JSONType(ref)); | |
13503 const Class& type_cls = Class::Handle(type_class()); | |
13504 intptr_t id = type_cls.FindCanonicalTypeIndex(*this); | |
13505 ASSERT(id >= 0); | |
13506 intptr_t cid = type_cls.id(); | |
13507 jsobj.AddPropertyF("id", "classes/%" Pd "/types/%" Pd "", cid, id); | |
13508 const char* name = String::Handle(Name()).ToCString(); | 13517 const char* name = String::Handle(Name()).ToCString(); |
13509 const char* user_name = String::Handle(UserVisibleName()).ToCString(); | 13518 const char* user_name = String::Handle(UserVisibleName()).ToCString(); |
13510 jsobj.AddProperty("name", name); | 13519 jsobj.AddProperty("name", name); |
13511 jsobj.AddProperty("user_name", user_name); | 13520 jsobj.AddProperty("user_name", user_name); |
13512 if (ref) { | 13521 if (ref) { |
13513 return; | 13522 return; |
13514 } | 13523 } |
13515 jsobj.AddProperty("type_class", type_cls); | |
13516 jsobj.AddProperty("type_arguments", TypeArguments::Handle(arguments())); | 13524 jsobj.AddProperty("type_arguments", TypeArguments::Handle(arguments())); |
13517 } | 13525 } |
13518 | 13526 |
13519 | 13527 |
13520 bool TypeRef::IsInstantiated(GrowableObjectArray* trail) const { | 13528 bool TypeRef::IsInstantiated(GrowableObjectArray* trail) const { |
13521 if (TestAndAddToTrail(&trail)) { | 13529 if (TestAndAddToTrail(&trail)) { |
13522 return true; | 13530 return true; |
13523 } | 13531 } |
13524 return AbstractType::Handle(type()).IsInstantiated(trail); | 13532 return AbstractType::Handle(type()).IsInstantiated(trail); |
13525 } | 13533 } |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13675 type()).arguments() == TypeArguments::null()) ? "" : "<...>"; | 13683 type()).arguments() == TypeArguments::null()) ? "" : "<...>"; |
13676 intptr_t len = OS::SNPrint(NULL, 0, format, type_cstr, args_cstr) + 1; | 13684 intptr_t len = OS::SNPrint(NULL, 0, format, type_cstr, args_cstr) + 1; |
13677 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 13685 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
13678 OS::SNPrint(chars, len, format, type_cstr, args_cstr); | 13686 OS::SNPrint(chars, len, format, type_cstr, args_cstr); |
13679 return chars; | 13687 return chars; |
13680 } | 13688 } |
13681 | 13689 |
13682 | 13690 |
13683 void TypeRef::PrintToJSONStream(JSONStream* stream, bool ref) const { | 13691 void TypeRef::PrintToJSONStream(JSONStream* stream, bool ref) const { |
13684 JSONObject jsobj(stream); | 13692 JSONObject jsobj(stream); |
| 13693 PrintSharedInstanceJSON(&jsobj, ref); |
13685 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); | 13694 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); |
13686 const intptr_t id = ring->GetIdForObject(raw()); | 13695 const intptr_t id = ring->GetIdForObject(raw()); |
13687 jsobj.AddProperty("type", JSONType(ref)); | |
13688 jsobj.AddPropertyF("id", "objects/%" Pd "", id); | 13696 jsobj.AddPropertyF("id", "objects/%" Pd "", id); |
13689 const char* name = String::Handle(Name()).ToCString(); | 13697 const char* name = String::Handle(Name()).ToCString(); |
13690 const char* user_name = String::Handle(UserVisibleName()).ToCString(); | 13698 const char* user_name = String::Handle(UserVisibleName()).ToCString(); |
13691 jsobj.AddProperty("name", name); | 13699 jsobj.AddProperty("name", name); |
13692 jsobj.AddProperty("user_name", user_name); | 13700 jsobj.AddProperty("user_name", user_name); |
13693 if (ref) { | 13701 if (ref) { |
13694 return; | 13702 return; |
13695 } | 13703 } |
13696 jsobj.AddProperty("ref_type", AbstractType::Handle(type())); | 13704 jsobj.AddProperty("ref_type", AbstractType::Handle(type())); |
13697 } | 13705 } |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13891 intptr_t len = OS::SNPrint( | 13899 intptr_t len = OS::SNPrint( |
13892 NULL, 0, format, name_cstr, index(), cls_cstr, bound_cstr) + 1; | 13900 NULL, 0, format, name_cstr, index(), cls_cstr, bound_cstr) + 1; |
13893 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 13901 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
13894 OS::SNPrint(chars, len, format, name_cstr, index(), cls_cstr, bound_cstr); | 13902 OS::SNPrint(chars, len, format, name_cstr, index(), cls_cstr, bound_cstr); |
13895 return chars; | 13903 return chars; |
13896 } | 13904 } |
13897 | 13905 |
13898 | 13906 |
13899 void TypeParameter::PrintToJSONStream(JSONStream* stream, bool ref) const { | 13907 void TypeParameter::PrintToJSONStream(JSONStream* stream, bool ref) const { |
13900 JSONObject jsobj(stream); | 13908 JSONObject jsobj(stream); |
| 13909 PrintSharedInstanceJSON(&jsobj, ref); |
13901 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); | 13910 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); |
13902 const intptr_t id = ring->GetIdForObject(raw()); | 13911 const intptr_t id = ring->GetIdForObject(raw()); |
13903 jsobj.AddProperty("type", JSONType(ref)); | |
13904 jsobj.AddPropertyF("id", "objects/%" Pd "", id); | 13912 jsobj.AddPropertyF("id", "objects/%" Pd "", id); |
13905 const char* name = String::Handle(Name()).ToCString(); | 13913 const char* name = String::Handle(Name()).ToCString(); |
13906 const char* user_name = String::Handle(UserVisibleName()).ToCString(); | 13914 const char* user_name = String::Handle(UserVisibleName()).ToCString(); |
13907 jsobj.AddProperty("name", name); | 13915 jsobj.AddProperty("name", name); |
13908 jsobj.AddProperty("user_name", user_name); | 13916 jsobj.AddProperty("user_name", user_name); |
13909 const Class& cls = Class::Handle(parameterized_class()); | 13917 const Class& param_cls = Class::Handle(parameterized_class()); |
13910 jsobj.AddProperty("parameterized_class", cls); | 13918 jsobj.AddProperty("parameterized_class", param_cls); |
13911 if (ref) { | 13919 if (ref) { |
13912 return; | 13920 return; |
13913 } | 13921 } |
13914 jsobj.AddProperty("index", index()); | 13922 jsobj.AddProperty("index", index()); |
13915 const AbstractType& upper_bound = AbstractType::Handle(bound()); | 13923 const AbstractType& upper_bound = AbstractType::Handle(bound()); |
13916 jsobj.AddProperty("upper_bound", upper_bound); | 13924 jsobj.AddProperty("upper_bound", upper_bound); |
13917 } | 13925 } |
13918 | 13926 |
13919 | 13927 |
13920 bool BoundedType::IsMalformed() const { | 13928 bool BoundedType::IsMalformed() const { |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14088 NULL, 0, format, type_cstr, bound_cstr, type_param_cstr, cls_cstr) + 1; | 14096 NULL, 0, format, type_cstr, bound_cstr, type_param_cstr, cls_cstr) + 1; |
14089 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 14097 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
14090 OS::SNPrint( | 14098 OS::SNPrint( |
14091 chars, len, format, type_cstr, bound_cstr, type_param_cstr, cls_cstr); | 14099 chars, len, format, type_cstr, bound_cstr, type_param_cstr, cls_cstr); |
14092 return chars; | 14100 return chars; |
14093 } | 14101 } |
14094 | 14102 |
14095 | 14103 |
14096 void BoundedType::PrintToJSONStream(JSONStream* stream, bool ref) const { | 14104 void BoundedType::PrintToJSONStream(JSONStream* stream, bool ref) const { |
14097 JSONObject jsobj(stream); | 14105 JSONObject jsobj(stream); |
| 14106 PrintSharedInstanceJSON(&jsobj, ref); |
14098 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); | 14107 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); |
14099 const intptr_t id = ring->GetIdForObject(raw()); | 14108 const intptr_t id = ring->GetIdForObject(raw()); |
14100 jsobj.AddProperty("type", JSONType(ref)); | |
14101 jsobj.AddPropertyF("id", "objects/%" Pd "", id); | 14109 jsobj.AddPropertyF("id", "objects/%" Pd "", id); |
14102 const char* name = String::Handle(Name()).ToCString(); | 14110 const char* name = String::Handle(Name()).ToCString(); |
14103 const char* user_name = String::Handle(UserVisibleName()).ToCString(); | 14111 const char* user_name = String::Handle(UserVisibleName()).ToCString(); |
14104 jsobj.AddProperty("name", name); | 14112 jsobj.AddProperty("name", name); |
14105 jsobj.AddProperty("user_name", user_name); | 14113 jsobj.AddProperty("user_name", user_name); |
14106 if (ref) { | 14114 if (ref) { |
14107 return; | 14115 return; |
14108 } | 14116 } |
14109 jsobj.AddProperty("bounded_type", AbstractType::Handle(type())); | 14117 jsobj.AddProperty("bounded_type", AbstractType::Handle(type())); |
14110 jsobj.AddProperty("upper_bound", AbstractType::Handle(bound())); | 14118 jsobj.AddProperty("upper_bound", AbstractType::Handle(bound())); |
(...skipping 2670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16781 "_ImmutableList len:%" Pd : "_List len:%" Pd; | 16789 "_ImmutableList len:%" Pd : "_List len:%" Pd; |
16782 intptr_t len = OS::SNPrint(NULL, 0, format, Length()) + 1; | 16790 intptr_t len = OS::SNPrint(NULL, 0, format, Length()) + 1; |
16783 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 16791 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
16784 OS::SNPrint(chars, len, format, Length()); | 16792 OS::SNPrint(chars, len, format, Length()); |
16785 return chars; | 16793 return chars; |
16786 } | 16794 } |
16787 | 16795 |
16788 | 16796 |
16789 void Array::PrintToJSONStream(JSONStream* stream, bool ref) const { | 16797 void Array::PrintToJSONStream(JSONStream* stream, bool ref) const { |
16790 JSONObject jsobj(stream); | 16798 JSONObject jsobj(stream); |
16791 Class& cls = Class::Handle(this->clazz()); | 16799 PrintSharedInstanceJSON(&jsobj, ref); |
16792 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); | 16800 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); |
16793 const intptr_t id = ring->GetIdForObject(raw()); | 16801 const intptr_t id = ring->GetIdForObject(raw()); |
16794 jsobj.AddProperty("type", JSONType(ref)); | |
16795 jsobj.AddPropertyF("id", "objects/%" Pd "", id); | 16802 jsobj.AddPropertyF("id", "objects/%" Pd "", id); |
16796 jsobj.AddProperty("class", cls); | |
16797 jsobj.AddProperty("length", Length()); | 16803 jsobj.AddProperty("length", Length()); |
16798 if (ref) { | 16804 if (ref) { |
16799 return; | 16805 return; |
16800 } | 16806 } |
16801 { | 16807 { |
16802 JSONArray jsarr(&jsobj, "elements"); | 16808 JSONArray jsarr(&jsobj, "elements"); |
16803 for (intptr_t index = 0; index < Length(); index++) { | 16809 for (intptr_t index = 0; index < Length(); index++) { |
16804 JSONObject jselement(&jsarr); | 16810 JSONObject jselement(&jsarr); |
16805 jselement.AddProperty("index", index); | 16811 jselement.AddProperty("index", index); |
16806 | 16812 |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17120 } | 17126 } |
17121 ASSERT(pos <= max_len); | 17127 ASSERT(pos <= max_len); |
17122 buffer[pos] = '\0'; | 17128 buffer[pos] = '\0'; |
17123 return buffer; | 17129 return buffer; |
17124 } | 17130 } |
17125 | 17131 |
17126 | 17132 |
17127 void GrowableObjectArray::PrintToJSONStream(JSONStream* stream, | 17133 void GrowableObjectArray::PrintToJSONStream(JSONStream* stream, |
17128 bool ref) const { | 17134 bool ref) const { |
17129 JSONObject jsobj(stream); | 17135 JSONObject jsobj(stream); |
17130 Class& cls = Class::Handle(this->clazz()); | 17136 PrintSharedInstanceJSON(&jsobj, ref); |
17131 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); | 17137 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); |
17132 const intptr_t id = ring->GetIdForObject(raw()); | 17138 const intptr_t id = ring->GetIdForObject(raw()); |
17133 jsobj.AddProperty("type", JSONType(ref)); | |
17134 jsobj.AddPropertyF("id", "objects/%" Pd "", id); | 17139 jsobj.AddPropertyF("id", "objects/%" Pd "", id); |
17135 jsobj.AddProperty("class", cls); | |
17136 jsobj.AddProperty("length", Length()); | 17140 jsobj.AddProperty("length", Length()); |
17137 if (ref) { | 17141 if (ref) { |
17138 return; | 17142 return; |
17139 } | 17143 } |
17140 { | 17144 { |
17141 JSONArray jsarr(&jsobj, "elements"); | 17145 JSONArray jsarr(&jsobj, "elements"); |
17142 for (intptr_t index = 0; index < Length(); index++) { | 17146 for (intptr_t index = 0; index < Length(); index++) { |
17143 JSONObject jselement(&jsarr); | 17147 JSONObject jselement(&jsarr); |
17144 jselement.AddProperty("index", index); | 17148 jselement.AddProperty("index", index); |
17145 | 17149 |
(...skipping 853 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17999 return "_MirrorReference"; | 18003 return "_MirrorReference"; |
18000 } | 18004 } |
18001 | 18005 |
18002 | 18006 |
18003 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { | 18007 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { |
18004 Instance::PrintToJSONStream(stream, ref); | 18008 Instance::PrintToJSONStream(stream, ref); |
18005 } | 18009 } |
18006 | 18010 |
18007 | 18011 |
18008 } // namespace dart | 18012 } // namespace dart |
OLD | NEW |