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 1575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1586 } | 1586 } |
1587 | 1587 |
1588 | 1588 |
1589 static void AddTypeProperties(JSONObject* jsobj, | 1589 static void AddTypeProperties(JSONObject* jsobj, |
1590 const char* user_type, | 1590 const char* user_type, |
1591 const char* vm_type, | 1591 const char* vm_type, |
1592 bool ref) { | 1592 bool ref) { |
1593 bool same_type = (strcmp(user_type, vm_type) == 0); | 1593 bool same_type = (strcmp(user_type, vm_type) == 0); |
1594 if (ref) { | 1594 if (ref) { |
1595 jsobj->AddPropertyF("type", "@%s", user_type); | 1595 jsobj->AddPropertyF("type", "@%s", user_type); |
1596 if (!same_type) { | |
1597 jsobj->AddPropertyF("_vmType", "@%s", vm_type); | |
1598 } | |
1599 } else { | 1596 } else { |
1600 jsobj->AddProperty("type", user_type); | 1597 jsobj->AddProperty("type", user_type); |
1601 if (!same_type) { | 1598 } |
1602 jsobj->AddProperty("_vmType", vm_type); | 1599 if (!same_type) { |
1603 } | 1600 jsobj->AddProperty("_vmType", vm_type); |
1604 } | 1601 } |
1605 } | 1602 } |
1606 | 1603 |
1607 | 1604 |
1608 void Object::PrintJSON(JSONStream* stream, bool ref) const { | 1605 void Object::PrintJSON(JSONStream* stream, bool ref) const { |
1609 if (IsNull()) { | 1606 if (IsNull()) { |
1610 JSONObject jsobj(stream); | 1607 JSONObject jsobj(stream); |
1611 AddTypeProperties(&jsobj, "null", JSONType(), ref); | 1608 AddTypeProperties(&jsobj, "Instance", JSONType(), ref); |
| 1609 jsobj.AddProperty("kind", "Null"); |
1612 jsobj.AddFixedServiceId("objects/null"); | 1610 jsobj.AddFixedServiceId("objects/null"); |
1613 jsobj.AddProperty("valueAsString", "null"); | 1611 jsobj.AddProperty("valueAsString", "null"); |
1614 if (!ref) { | 1612 if (!ref) { |
1615 const Class& cls = Class::Handle(this->clazz()); | 1613 const Class& cls = Class::Handle(this->clazz()); |
1616 jsobj.AddProperty("class", cls); | 1614 jsobj.AddProperty("class", cls); |
1617 jsobj.AddProperty("size", raw()->Size()); | 1615 jsobj.AddProperty("size", raw()->Size()); |
1618 } | 1616 } |
1619 } else { | 1617 } else { |
1620 PrintJSONImpl(stream, ref); | 1618 PrintJSONImpl(stream, ref); |
1621 } | 1619 } |
(...skipping 12519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14141 intptr_t len = OS::SNPrint(NULL, 0, kFormat, type_name.ToCString()) + 1; | 14139 intptr_t len = OS::SNPrint(NULL, 0, kFormat, type_name.ToCString()) + 1; |
14142 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 14140 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
14143 OS::SNPrint(chars, len, kFormat, type_name.ToCString()); | 14141 OS::SNPrint(chars, len, kFormat, type_name.ToCString()); |
14144 return chars; | 14142 return chars; |
14145 } | 14143 } |
14146 } | 14144 } |
14147 | 14145 |
14148 | 14146 |
14149 void Instance::PrintSharedInstanceJSON(JSONObject* jsobj, | 14147 void Instance::PrintSharedInstanceJSON(JSONObject* jsobj, |
14150 bool ref) const { | 14148 bool ref) const { |
| 14149 AddTypeProperties(jsobj, "Instance", JSONType(), ref); |
14151 Class& cls = Class::Handle(this->clazz()); | 14150 Class& cls = Class::Handle(this->clazz()); |
14152 jsobj->AddProperty("class", cls); | 14151 jsobj->AddProperty("class", cls); |
14153 // TODO(turnidge): Provide the type arguments here too. | 14152 // TODO(turnidge): Provide the type arguments here too. |
14154 if (ref) { | 14153 if (ref) { |
14155 return; | 14154 return; |
14156 } | 14155 } |
14157 | 14156 |
14158 if (raw()->IsHeapObject()) { | 14157 if (raw()->IsHeapObject()) { |
14159 jsobj->AddProperty("size", raw()->Size()); | 14158 jsobj->AddProperty("size", raw()->Size()); |
14160 } else { | 14159 } else { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14204 jsobj.AddProperty("kind", "NotInitialized"); | 14203 jsobj.AddProperty("kind", "NotInitialized"); |
14205 jsobj.AddProperty("valueAsString", "<not initialized>"); | 14204 jsobj.AddProperty("valueAsString", "<not initialized>"); |
14206 return; | 14205 return; |
14207 } else if (raw() == Object::transition_sentinel().raw()) { | 14206 } else if (raw() == Object::transition_sentinel().raw()) { |
14208 jsobj.AddProperty("type", "Sentinel"); | 14207 jsobj.AddProperty("type", "Sentinel"); |
14209 jsobj.AddProperty("kind", "BeingInitialized"); | 14208 jsobj.AddProperty("kind", "BeingInitialized"); |
14210 jsobj.AddProperty("valueAsString", "<being initialized>"); | 14209 jsobj.AddProperty("valueAsString", "<being initialized>"); |
14211 return; | 14210 return; |
14212 } | 14211 } |
14213 | 14212 |
14214 AddTypeProperties(&jsobj, "Instance", JSONType(), ref); | |
14215 PrintSharedInstanceJSON(&jsobj, ref); | 14213 PrintSharedInstanceJSON(&jsobj, ref); |
| 14214 if (IsClosure()) { |
| 14215 jsobj.AddProperty("kind", "Closure"); |
| 14216 } else { |
| 14217 jsobj.AddProperty("kind", "PlainInstance"); |
| 14218 } |
14216 jsobj.AddServiceId(*this); | 14219 jsobj.AddServiceId(*this); |
14217 if (IsClosure()) { | 14220 if (IsClosure()) { |
14218 jsobj.AddProperty("function", Function::Handle(Closure::function(*this))); | 14221 jsobj.AddProperty("closureFunction", |
14219 jsobj.AddProperty("context", Context::Handle(Closure::context(*this))); | 14222 Function::Handle(Closure::function(*this))); |
| 14223 jsobj.AddProperty("closureContext", |
| 14224 Context::Handle(Closure::context(*this))); |
14220 } | 14225 } |
14221 if (ref) { | 14226 if (ref) { |
14222 return; | 14227 return; |
14223 } | 14228 } |
14224 } | 14229 } |
14225 | 14230 |
14226 | 14231 |
14227 bool AbstractType::IsResolved() const { | 14232 bool AbstractType::IsResolved() const { |
14228 // AbstractType is an abstract class. | 14233 // AbstractType is an abstract class. |
14229 UNREACHABLE(); | 14234 UNREACHABLE(); |
(...skipping 1072 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15302 OS::SNPrint(NULL, 0, format, unresolved, class_name, args_cstr) + 1; | 15307 OS::SNPrint(NULL, 0, format, unresolved, class_name, args_cstr) + 1; |
15303 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 15308 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
15304 OS::SNPrint(chars, len, format, unresolved, class_name, args_cstr); | 15309 OS::SNPrint(chars, len, format, unresolved, class_name, args_cstr); |
15305 return chars; | 15310 return chars; |
15306 } | 15311 } |
15307 } | 15312 } |
15308 | 15313 |
15309 | 15314 |
15310 void Type::PrintJSONImpl(JSONStream* stream, bool ref) const { | 15315 void Type::PrintJSONImpl(JSONStream* stream, bool ref) const { |
15311 JSONObject jsobj(stream); | 15316 JSONObject jsobj(stream); |
15312 AddTypeProperties(&jsobj, "Type", JSONType(), ref); | |
15313 PrintSharedInstanceJSON(&jsobj, ref); | 15317 PrintSharedInstanceJSON(&jsobj, ref); |
| 15318 jsobj.AddProperty("kind", "Type"); |
15314 if (IsCanonical()) { | 15319 if (IsCanonical()) { |
15315 const Class& type_cls = Class::Handle(type_class()); | 15320 const Class& type_cls = Class::Handle(type_class()); |
15316 intptr_t id = type_cls.FindCanonicalTypeIndex(*this); | 15321 intptr_t id = type_cls.FindCanonicalTypeIndex(*this); |
15317 ASSERT(id >= 0); | 15322 ASSERT(id >= 0); |
15318 intptr_t cid = type_cls.id(); | 15323 intptr_t cid = type_cls.id(); |
15319 jsobj.AddFixedServiceId("classes/%" Pd "/types/%" Pd "", cid, id); | 15324 jsobj.AddFixedServiceId("classes/%" Pd "/types/%" Pd "", cid, id); |
15320 jsobj.AddProperty("typeClass", type_cls); | 15325 jsobj.AddProperty("typeClass", type_cls); |
15321 } else { | 15326 } else { |
15322 jsobj.AddServiceId(*this); | 15327 jsobj.AddServiceId(*this); |
15323 } | 15328 } |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15493 const intptr_t len = OS::SNPrint(NULL, 0, format, type_cstr) + 1; | 15498 const intptr_t len = OS::SNPrint(NULL, 0, format, type_cstr) + 1; |
15494 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 15499 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
15495 OS::SNPrint(chars, len, format, type_cstr); | 15500 OS::SNPrint(chars, len, format, type_cstr); |
15496 return chars; | 15501 return chars; |
15497 } | 15502 } |
15498 } | 15503 } |
15499 | 15504 |
15500 | 15505 |
15501 void TypeRef::PrintJSONImpl(JSONStream* stream, bool ref) const { | 15506 void TypeRef::PrintJSONImpl(JSONStream* stream, bool ref) const { |
15502 JSONObject jsobj(stream); | 15507 JSONObject jsobj(stream); |
15503 AddTypeProperties(&jsobj, "TypeRef", JSONType(), ref); | |
15504 PrintSharedInstanceJSON(&jsobj, ref); | 15508 PrintSharedInstanceJSON(&jsobj, ref); |
| 15509 jsobj.AddProperty("kind", "TypeRef"); |
15505 jsobj.AddServiceId(*this); | 15510 jsobj.AddServiceId(*this); |
15506 const String& user_name = String::Handle(PrettyName()); | 15511 const String& user_name = String::Handle(PrettyName()); |
15507 const String& vm_name = String::Handle(Name()); | 15512 const String& vm_name = String::Handle(Name()); |
15508 AddNameProperties(&jsobj, user_name, vm_name); | 15513 AddNameProperties(&jsobj, user_name, vm_name); |
15509 if (ref) { | 15514 if (ref) { |
15510 return; | 15515 return; |
15511 } | 15516 } |
15512 jsobj.AddProperty("refType", AbstractType::Handle(type())); | 15517 jsobj.AddProperty("refType", AbstractType::Handle(type())); |
15513 } | 15518 } |
15514 | 15519 |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15727 intptr_t len = OS::SNPrint( | 15732 intptr_t len = OS::SNPrint( |
15728 NULL, 0, format, name_cstr, index(), cls_cstr, bound_cstr) + 1; | 15733 NULL, 0, format, name_cstr, index(), cls_cstr, bound_cstr) + 1; |
15729 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 15734 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
15730 OS::SNPrint(chars, len, format, name_cstr, index(), cls_cstr, bound_cstr); | 15735 OS::SNPrint(chars, len, format, name_cstr, index(), cls_cstr, bound_cstr); |
15731 return chars; | 15736 return chars; |
15732 } | 15737 } |
15733 | 15738 |
15734 | 15739 |
15735 void TypeParameter::PrintJSONImpl(JSONStream* stream, bool ref) const { | 15740 void TypeParameter::PrintJSONImpl(JSONStream* stream, bool ref) const { |
15736 JSONObject jsobj(stream); | 15741 JSONObject jsobj(stream); |
15737 AddTypeProperties(&jsobj, "TypeParameter", JSONType(), ref); | |
15738 PrintSharedInstanceJSON(&jsobj, ref); | 15742 PrintSharedInstanceJSON(&jsobj, ref); |
| 15743 jsobj.AddProperty("kind", "TypeParameter"); |
15739 jsobj.AddServiceId(*this); | 15744 jsobj.AddServiceId(*this); |
15740 const String& user_name = String::Handle(PrettyName()); | 15745 const String& user_name = String::Handle(PrettyName()); |
15741 const String& vm_name = String::Handle(Name()); | 15746 const String& vm_name = String::Handle(Name()); |
15742 AddNameProperties(&jsobj, user_name, vm_name); | 15747 AddNameProperties(&jsobj, user_name, vm_name); |
15743 const Class& param_cls = Class::Handle(parameterized_class()); | 15748 const Class& param_cls = Class::Handle(parameterized_class()); |
15744 jsobj.AddProperty("parameterizedClass", param_cls); | 15749 jsobj.AddProperty("parameterizedClass", param_cls); |
15745 if (ref) { | 15750 if (ref) { |
15746 return; | 15751 return; |
15747 } | 15752 } |
15748 jsobj.AddProperty("index", index()); | 15753 jsobj.AddProperty("parameterIndex", index()); |
15749 const AbstractType& upper_bound = AbstractType::Handle(bound()); | 15754 const AbstractType& upper_bound = AbstractType::Handle(bound()); |
15750 jsobj.AddProperty("upperBound", upper_bound); | 15755 jsobj.AddProperty("upperBound", upper_bound); |
15751 } | 15756 } |
15752 | 15757 |
15753 | 15758 |
15754 bool BoundedType::IsMalformed() const { | 15759 bool BoundedType::IsMalformed() const { |
15755 return AbstractType::Handle(type()).IsMalformed(); | 15760 return AbstractType::Handle(type()).IsMalformed(); |
15756 } | 15761 } |
15757 | 15762 |
15758 | 15763 |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15943 NULL, 0, format, type_cstr, bound_cstr, type_param_cstr, cls_cstr) + 1; | 15948 NULL, 0, format, type_cstr, bound_cstr, type_param_cstr, cls_cstr) + 1; |
15944 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 15949 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
15945 OS::SNPrint( | 15950 OS::SNPrint( |
15946 chars, len, format, type_cstr, bound_cstr, type_param_cstr, cls_cstr); | 15951 chars, len, format, type_cstr, bound_cstr, type_param_cstr, cls_cstr); |
15947 return chars; | 15952 return chars; |
15948 } | 15953 } |
15949 | 15954 |
15950 | 15955 |
15951 void BoundedType::PrintJSONImpl(JSONStream* stream, bool ref) const { | 15956 void BoundedType::PrintJSONImpl(JSONStream* stream, bool ref) const { |
15952 JSONObject jsobj(stream); | 15957 JSONObject jsobj(stream); |
15953 AddTypeProperties(&jsobj, "BoundedType", JSONType(), ref); | |
15954 PrintSharedInstanceJSON(&jsobj, ref); | 15958 PrintSharedInstanceJSON(&jsobj, ref); |
| 15959 jsobj.AddProperty("kind", "BoundedType"); |
15955 jsobj.AddServiceId(*this); | 15960 jsobj.AddServiceId(*this); |
15956 const String& user_name = String::Handle(PrettyName()); | 15961 const String& user_name = String::Handle(PrettyName()); |
15957 const String& vm_name = String::Handle(Name()); | 15962 const String& vm_name = String::Handle(Name()); |
15958 AddNameProperties(&jsobj, user_name, vm_name); | 15963 AddNameProperties(&jsobj, user_name, vm_name); |
15959 if (ref) { | 15964 if (ref) { |
15960 return; | 15965 return; |
15961 } | 15966 } |
15962 jsobj.AddProperty("boundedType", AbstractType::Handle(type())); | 15967 jsobj.AddProperty("boundedType", AbstractType::Handle(type())); |
15963 jsobj.AddProperty("upperBound", AbstractType::Handle(bound())); | 15968 jsobj.AddProperty("upperBound", AbstractType::Handle(bound())); |
15964 } | 15969 } |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16046 | 16051 |
16047 const char* Integer::ToCString() const { | 16052 const char* Integer::ToCString() const { |
16048 // Integer is an interface. No instances of Integer should exist. | 16053 // Integer is an interface. No instances of Integer should exist. |
16049 UNREACHABLE(); | 16054 UNREACHABLE(); |
16050 return "Integer"; | 16055 return "Integer"; |
16051 } | 16056 } |
16052 | 16057 |
16053 | 16058 |
16054 void Integer::PrintJSONImpl(JSONStream* stream, bool ref) const { | 16059 void Integer::PrintJSONImpl(JSONStream* stream, bool ref) const { |
16055 JSONObject jsobj(stream); | 16060 JSONObject jsobj(stream); |
16056 AddTypeProperties(&jsobj, "int", JSONType(), ref); | |
16057 PrintSharedInstanceJSON(&jsobj, ref); | 16061 PrintSharedInstanceJSON(&jsobj, ref); |
| 16062 jsobj.AddProperty("kind", "Int"); |
16058 jsobj.AddServiceId(*this); | 16063 jsobj.AddServiceId(*this); |
16059 jsobj.AddProperty("valueAsString", ToCString()); | 16064 jsobj.AddProperty("valueAsString", ToCString()); |
16060 } | 16065 } |
16061 | 16066 |
16062 | 16067 |
16063 // Throw JavascriptIntegerOverflow exception. | 16068 // Throw JavascriptIntegerOverflow exception. |
16064 static void ThrowJavascriptIntegerOverflow(const Integer& i) { | 16069 static void ThrowJavascriptIntegerOverflow(const Integer& i) { |
16065 const Array& exc_args = Array::Handle(Array::New(1)); | 16070 const Array& exc_args = Array::Handle(Array::New(1)); |
16066 const String& i_str = String::Handle(String::New(i.ToCString())); | 16071 const String& i_str = String::Handle(String::New(i.ToCString())); |
16067 exc_args.SetAt(0, i_str); | 16072 exc_args.SetAt(0, i_str); |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16475 // Calculate the size of the string. | 16480 // Calculate the size of the string. |
16476 intptr_t len = OS::SNPrint(NULL, 0, kFormat, Value()) + 1; | 16481 intptr_t len = OS::SNPrint(NULL, 0, kFormat, Value()) + 1; |
16477 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 16482 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
16478 OS::SNPrint(chars, len, kFormat, Value()); | 16483 OS::SNPrint(chars, len, kFormat, Value()); |
16479 return chars; | 16484 return chars; |
16480 } | 16485 } |
16481 | 16486 |
16482 | 16487 |
16483 void Smi::PrintJSONImpl(JSONStream* stream, bool ref) const { | 16488 void Smi::PrintJSONImpl(JSONStream* stream, bool ref) const { |
16484 JSONObject jsobj(stream); | 16489 JSONObject jsobj(stream); |
16485 AddTypeProperties(&jsobj, "int", JSONType(), ref); | |
16486 PrintSharedInstanceJSON(&jsobj, ref); | 16490 PrintSharedInstanceJSON(&jsobj, ref); |
| 16491 jsobj.AddProperty("kind", "Int"); |
16487 jsobj.AddFixedServiceId("objects/int-%" Pd "", Value()); | 16492 jsobj.AddFixedServiceId("objects/int-%" Pd "", Value()); |
16488 jsobj.AddPropertyF("valueAsString", "%" Pd "", Value()); | 16493 jsobj.AddPropertyF("valueAsString", "%" Pd "", Value()); |
16489 } | 16494 } |
16490 | 16495 |
16491 | 16496 |
16492 RawClass* Smi::Class() { | 16497 RawClass* Smi::Class() { |
16493 return Isolate::Current()->object_store()->smi_class(); | 16498 return Isolate::Current()->object_store()->smi_class(); |
16494 } | 16499 } |
16495 | 16500 |
16496 | 16501 |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16737 const int kBufferSize = 128; | 16742 const int kBufferSize = 128; |
16738 char* buffer = Isolate::Current()->current_zone()->Alloc<char>(kBufferSize); | 16743 char* buffer = Isolate::Current()->current_zone()->Alloc<char>(kBufferSize); |
16739 buffer[kBufferSize - 1] = '\0'; | 16744 buffer[kBufferSize - 1] = '\0'; |
16740 DoubleToCString(value(), buffer, kBufferSize); | 16745 DoubleToCString(value(), buffer, kBufferSize); |
16741 return buffer; | 16746 return buffer; |
16742 } | 16747 } |
16743 | 16748 |
16744 | 16749 |
16745 void Double::PrintJSONImpl(JSONStream* stream, bool ref) const { | 16750 void Double::PrintJSONImpl(JSONStream* stream, bool ref) const { |
16746 JSONObject jsobj(stream); | 16751 JSONObject jsobj(stream); |
16747 // Suppress the fact that the internal vm name for this type is | |
16748 // "Double". Return "double" instead. | |
16749 AddTypeProperties(&jsobj, "double", "double", ref); | |
16750 PrintSharedInstanceJSON(&jsobj, ref); | 16752 PrintSharedInstanceJSON(&jsobj, ref); |
| 16753 jsobj.AddProperty("kind", "Double"); |
16751 jsobj.AddServiceId(*this); | 16754 jsobj.AddServiceId(*this); |
16752 jsobj.AddProperty("valueAsString", ToCString()); | 16755 jsobj.AddProperty("valueAsString", ToCString()); |
16753 } | 16756 } |
16754 | 16757 |
16755 | 16758 |
16756 bool Bigint::Neg() const { | 16759 bool Bigint::Neg() const { |
16757 return Bool::Handle(neg()).value(); | 16760 return Bool::Handle(neg()).value(); |
16758 } | 16761 } |
16759 | 16762 |
16760 | 16763 |
(...skipping 1558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
18319 JSONObject jsobj(stream); | 18322 JSONObject jsobj(stream); |
18320 if (raw() == Symbols::OptimizedOut().raw()) { | 18323 if (raw() == Symbols::OptimizedOut().raw()) { |
18321 // TODO(turnidge): This is a hack. The user could have this | 18324 // TODO(turnidge): This is a hack. The user could have this |
18322 // special string in their program. Fixing this involves updating | 18325 // special string in their program. Fixing this involves updating |
18323 // the debugging api a bit. | 18326 // the debugging api a bit. |
18324 jsobj.AddProperty("type", "Sentinel"); | 18327 jsobj.AddProperty("type", "Sentinel"); |
18325 jsobj.AddProperty("kind", "OptimizedOut"); | 18328 jsobj.AddProperty("kind", "OptimizedOut"); |
18326 jsobj.AddProperty("valueAsString", "<optimized out>"); | 18329 jsobj.AddProperty("valueAsString", "<optimized out>"); |
18327 return; | 18330 return; |
18328 } | 18331 } |
18329 AddTypeProperties(&jsobj, "String", JSONType(), ref); | |
18330 PrintSharedInstanceJSON(&jsobj, ref); | 18332 PrintSharedInstanceJSON(&jsobj, ref); |
| 18333 jsobj.AddProperty("kind", "String"); |
18331 jsobj.AddServiceId(*this); | 18334 jsobj.AddServiceId(*this); |
18332 if (ref) { | 18335 if (ref) { |
18333 bool did_truncate = jsobj.AddPropertyStr("valueAsString", *this, 128); | 18336 bool did_truncate = jsobj.AddPropertyStr("valueAsString", *this, 128); |
18334 if (did_truncate) { | 18337 if (did_truncate) { |
18335 jsobj.AddProperty("valueAsStringIsTruncated", did_truncate); | 18338 jsobj.AddProperty("valueAsStringIsTruncated", did_truncate); |
18336 } | 18339 } |
18337 } else { | 18340 } else { |
18338 bool did_truncate = jsobj.AddPropertyStr("valueAsString", *this); | 18341 bool did_truncate = jsobj.AddPropertyStr("valueAsString", *this); |
18339 ASSERT(!did_truncate); | 18342 ASSERT(!did_truncate); |
18340 } | 18343 } |
(...skipping 887 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
19228 | 19231 |
19229 | 19232 |
19230 const char* Bool::ToCString() const { | 19233 const char* Bool::ToCString() const { |
19231 return value() ? "true" : "false"; | 19234 return value() ? "true" : "false"; |
19232 } | 19235 } |
19233 | 19236 |
19234 | 19237 |
19235 void Bool::PrintJSONImpl(JSONStream* stream, bool ref) const { | 19238 void Bool::PrintJSONImpl(JSONStream* stream, bool ref) const { |
19236 const char* str = ToCString(); | 19239 const char* str = ToCString(); |
19237 JSONObject jsobj(stream); | 19240 JSONObject jsobj(stream); |
19238 // Suppress the fact that the internal vm name for this type is | |
19239 // "Bool". Return "bool" instead. | |
19240 AddTypeProperties(&jsobj, "bool", "bool", ref); | |
19241 PrintSharedInstanceJSON(&jsobj, ref); | 19241 PrintSharedInstanceJSON(&jsobj, ref); |
| 19242 jsobj.AddProperty("kind", "Bool"); |
19242 jsobj.AddFixedServiceId("objects/bool-%s", str); | 19243 jsobj.AddFixedServiceId("objects/bool-%s", str); |
19243 jsobj.AddPropertyF("valueAsString", "%s", str); | 19244 jsobj.AddPropertyF("valueAsString", "%s", str); |
19244 } | 19245 } |
19245 | 19246 |
19246 | 19247 |
19247 bool Array::CanonicalizeEquals(const Instance& other) const { | 19248 bool Array::CanonicalizeEquals(const Instance& other) const { |
19248 if (this->raw() == other.raw()) { | 19249 if (this->raw() == other.raw()) { |
19249 // Both handles point to the same raw instance. | 19250 // Both handles point to the same raw instance. |
19250 return true; | 19251 return true; |
19251 } | 19252 } |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
19342 "_ImmutableList len:%" Pd : "_List len:%" Pd; | 19343 "_ImmutableList len:%" Pd : "_List len:%" Pd; |
19343 intptr_t len = OS::SNPrint(NULL, 0, format, Length()) + 1; | 19344 intptr_t len = OS::SNPrint(NULL, 0, format, Length()) + 1; |
19344 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 19345 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
19345 OS::SNPrint(chars, len, format, Length()); | 19346 OS::SNPrint(chars, len, format, Length()); |
19346 return chars; | 19347 return chars; |
19347 } | 19348 } |
19348 | 19349 |
19349 | 19350 |
19350 void Array::PrintJSONImpl(JSONStream* stream, bool ref) const { | 19351 void Array::PrintJSONImpl(JSONStream* stream, bool ref) const { |
19351 JSONObject jsobj(stream); | 19352 JSONObject jsobj(stream); |
19352 AddTypeProperties(&jsobj, "List", JSONType(), ref); | |
19353 PrintSharedInstanceJSON(&jsobj, ref); | 19353 PrintSharedInstanceJSON(&jsobj, ref); |
| 19354 jsobj.AddProperty("kind", "List"); |
19354 jsobj.AddServiceId(*this); | 19355 jsobj.AddServiceId(*this); |
19355 jsobj.AddProperty("length", Length()); | 19356 jsobj.AddProperty("length", Length()); |
19356 if (ref) { | 19357 if (ref) { |
19357 return; | 19358 return; |
19358 } | 19359 } |
19359 { | 19360 { |
19360 JSONArray jsarr(&jsobj, "elements"); | 19361 JSONArray jsarr(&jsobj, "elements"); |
19361 for (intptr_t index = 0; index < Length(); index++) { | 19362 for (intptr_t index = 0; index < Length(); index++) { |
19362 JSONObject jselement(&jsarr); | 19363 JSONObject jselement(&jsarr); |
19363 jselement.AddProperty("index", index); | 19364 jselement.AddProperty("index", index); |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
19588 intptr_t len = OS::SNPrint(NULL, 0, format, Length()) + 1; | 19589 intptr_t len = OS::SNPrint(NULL, 0, format, Length()) + 1; |
19589 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 19590 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
19590 OS::SNPrint(chars, len, format, Length()); | 19591 OS::SNPrint(chars, len, format, Length()); |
19591 return chars; | 19592 return chars; |
19592 } | 19593 } |
19593 | 19594 |
19594 | 19595 |
19595 void GrowableObjectArray::PrintJSONImpl(JSONStream* stream, | 19596 void GrowableObjectArray::PrintJSONImpl(JSONStream* stream, |
19596 bool ref) const { | 19597 bool ref) const { |
19597 JSONObject jsobj(stream); | 19598 JSONObject jsobj(stream); |
19598 AddTypeProperties(&jsobj, "List", JSONType(), ref); | |
19599 PrintSharedInstanceJSON(&jsobj, ref); | 19599 PrintSharedInstanceJSON(&jsobj, ref); |
| 19600 jsobj.AddProperty("kind", "List"); |
19600 jsobj.AddServiceId(*this); | 19601 jsobj.AddServiceId(*this); |
19601 jsobj.AddProperty("length", Length()); | 19602 jsobj.AddProperty("length", Length()); |
19602 if (ref) { | 19603 if (ref) { |
19603 return; | 19604 return; |
19604 } | 19605 } |
19605 { | 19606 { |
19606 JSONArray jsarr(&jsobj, "elements"); | 19607 JSONArray jsarr(&jsobj, "elements"); |
19607 for (intptr_t index = 0; index < Length(); index++) { | 19608 for (intptr_t index = 0; index < Length(); index++) { |
19608 JSONObject jselement(&jsarr); | 19609 JSONObject jselement(&jsarr); |
19609 jselement.AddProperty("index", index); | 19610 jselement.AddProperty("index", index); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
19700 } | 19701 } |
19701 | 19702 |
19702 | 19703 |
19703 const char* LinkedHashMap::ToCString() const { | 19704 const char* LinkedHashMap::ToCString() const { |
19704 // TODO(koda): Print key/value pairs. | 19705 // TODO(koda): Print key/value pairs. |
19705 return "_LinkedHashMap"; | 19706 return "_LinkedHashMap"; |
19706 } | 19707 } |
19707 | 19708 |
19708 | 19709 |
19709 void LinkedHashMap::PrintJSONImpl(JSONStream* stream, bool ref) const { | 19710 void LinkedHashMap::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 19711 JSONObject jsobj(stream); |
| 19712 PrintSharedInstanceJSON(&jsobj, ref); |
| 19713 jsobj.AddProperty("kind", "Map"); |
| 19714 jsobj.AddServiceId(*this); |
| 19715 // TODO(koda): Print length. |
| 19716 if (ref) { |
| 19717 return; |
| 19718 } |
19710 // TODO(koda): Print key/value pairs. | 19719 // TODO(koda): Print key/value pairs. |
19711 Instance::PrintJSONImpl(stream, ref); | |
19712 } | 19720 } |
19713 | 19721 |
19714 | 19722 |
19715 RawFloat32x4* Float32x4::New(float v0, float v1, float v2, float v3, | 19723 RawFloat32x4* Float32x4::New(float v0, float v1, float v2, float v3, |
19716 Heap::Space space) { | 19724 Heap::Space space) { |
19717 ASSERT(Isolate::Current()->object_store()->float32x4_class() != | 19725 ASSERT(Isolate::Current()->object_store()->float32x4_class() != |
19718 Class::null()); | 19726 Class::null()); |
19719 Float32x4& result = Float32x4::Handle(); | 19727 Float32x4& result = Float32x4::Handle(); |
19720 { | 19728 { |
19721 RawObject* raw = Object::Allocate(Float32x4::kClassId, | 19729 RawObject* raw = Object::Allocate(Float32x4::kClassId, |
(...skipping 854 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
20576 } | 20584 } |
20577 | 20585 |
20578 | 20586 |
20579 const char* WeakProperty::ToCString() const { | 20587 const char* WeakProperty::ToCString() const { |
20580 return "_WeakProperty"; | 20588 return "_WeakProperty"; |
20581 } | 20589 } |
20582 | 20590 |
20583 | 20591 |
20584 void WeakProperty::PrintJSONImpl(JSONStream* stream, bool ref) const { | 20592 void WeakProperty::PrintJSONImpl(JSONStream* stream, bool ref) const { |
20585 JSONObject jsobj(stream); | 20593 JSONObject jsobj(stream); |
20586 AddTypeProperties(&jsobj, "Instance", JSONType(), ref); | |
20587 PrintSharedInstanceJSON(&jsobj, ref); | 20594 PrintSharedInstanceJSON(&jsobj, ref); |
| 20595 jsobj.AddProperty("kind", "WeakProperty"); |
20588 jsobj.AddServiceId(*this); | 20596 jsobj.AddServiceId(*this); |
20589 if (ref) { | 20597 if (ref) { |
20590 return; | 20598 return; |
20591 } | 20599 } |
20592 | 20600 |
20593 const Object& key_handle = Object::Handle(key()); | 20601 const Object& key_handle = Object::Handle(key()); |
20594 jsobj.AddProperty("key", key_handle); | 20602 jsobj.AddProperty("propertyKey", key_handle); |
20595 const Object& value_handle = Object::Handle(value()); | 20603 const Object& value_handle = Object::Handle(value()); |
20596 jsobj.AddProperty("value", value_handle); | 20604 jsobj.AddProperty("propertyValue", value_handle); |
20597 } | 20605 } |
20598 | 20606 |
20599 RawAbstractType* MirrorReference::GetAbstractTypeReferent() const { | 20607 RawAbstractType* MirrorReference::GetAbstractTypeReferent() const { |
20600 ASSERT(Object::Handle(referent()).IsAbstractType()); | 20608 ASSERT(Object::Handle(referent()).IsAbstractType()); |
20601 return AbstractType::Cast(Object::Handle(referent())).raw(); | 20609 return AbstractType::Cast(Object::Handle(referent())).raw(); |
20602 } | 20610 } |
20603 | 20611 |
20604 | 20612 |
20605 RawClass* MirrorReference::GetClassReferent() const { | 20613 RawClass* MirrorReference::GetClassReferent() const { |
20606 ASSERT(Object::Handle(referent()).IsClass()); | 20614 ASSERT(Object::Handle(referent()).IsClass()); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
20647 } | 20655 } |
20648 | 20656 |
20649 | 20657 |
20650 const char* MirrorReference::ToCString() const { | 20658 const char* MirrorReference::ToCString() const { |
20651 return "_MirrorReference"; | 20659 return "_MirrorReference"; |
20652 } | 20660 } |
20653 | 20661 |
20654 | 20662 |
20655 void MirrorReference::PrintJSONImpl(JSONStream* stream, bool ref) const { | 20663 void MirrorReference::PrintJSONImpl(JSONStream* stream, bool ref) const { |
20656 JSONObject jsobj(stream); | 20664 JSONObject jsobj(stream); |
20657 AddTypeProperties(&jsobj, "Instance", JSONType(), ref); | |
20658 PrintSharedInstanceJSON(&jsobj, ref); | 20665 PrintSharedInstanceJSON(&jsobj, ref); |
| 20666 jsobj.AddProperty("kind", "MirrorReference"); |
20659 jsobj.AddServiceId(*this); | 20667 jsobj.AddServiceId(*this); |
20660 | 20668 |
20661 if (ref) { | 20669 if (ref) { |
20662 return; | 20670 return; |
20663 } | 20671 } |
20664 | 20672 |
20665 const Object& referent_handle = Object::Handle(referent()); | 20673 const Object& referent_handle = Object::Handle(referent()); |
20666 jsobj.AddProperty("referent", referent_handle); | 20674 jsobj.AddProperty("mirrorReferent", referent_handle); |
20667 } | 20675 } |
20668 | 20676 |
20669 | 20677 |
20670 void UserTag::MakeActive() const { | 20678 void UserTag::MakeActive() const { |
20671 Isolate* isolate = Isolate::Current(); | 20679 Isolate* isolate = Isolate::Current(); |
20672 ASSERT(isolate != NULL); | 20680 ASSERT(isolate != NULL); |
20673 isolate->set_current_tag(*this); | 20681 isolate->set_current_tag(*this); |
20674 } | 20682 } |
20675 | 20683 |
20676 | 20684 |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
20794 return tag_label.ToCString(); | 20802 return tag_label.ToCString(); |
20795 } | 20803 } |
20796 | 20804 |
20797 | 20805 |
20798 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 20806 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { |
20799 Instance::PrintJSONImpl(stream, ref); | 20807 Instance::PrintJSONImpl(stream, ref); |
20800 } | 20808 } |
20801 | 20809 |
20802 | 20810 |
20803 } // namespace dart | 20811 } // namespace dart |
OLD | NEW |