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 12524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14146 intptr_t len = OS::SNPrint(NULL, 0, kFormat, type_name.ToCString()) + 1; | 14144 intptr_t len = OS::SNPrint(NULL, 0, kFormat, type_name.ToCString()) + 1; |
14147 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 14145 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
14148 OS::SNPrint(chars, len, kFormat, type_name.ToCString()); | 14146 OS::SNPrint(chars, len, kFormat, type_name.ToCString()); |
14149 return chars; | 14147 return chars; |
14150 } | 14148 } |
14151 } | 14149 } |
14152 | 14150 |
14153 | 14151 |
14154 void Instance::PrintSharedInstanceJSON(JSONObject* jsobj, | 14152 void Instance::PrintSharedInstanceJSON(JSONObject* jsobj, |
14155 bool ref) const { | 14153 bool ref) const { |
| 14154 AddTypeProperties(jsobj, "Instance", JSONType(), ref); |
14156 Class& cls = Class::Handle(this->clazz()); | 14155 Class& cls = Class::Handle(this->clazz()); |
14157 jsobj->AddProperty("class", cls); | 14156 jsobj->AddProperty("class", cls); |
14158 // TODO(turnidge): Provide the type arguments here too. | 14157 // TODO(turnidge): Provide the type arguments here too. |
14159 if (ref) { | 14158 if (ref) { |
14160 return; | 14159 return; |
14161 } | 14160 } |
14162 | 14161 |
14163 if (raw()->IsHeapObject()) { | 14162 if (raw()->IsHeapObject()) { |
14164 jsobj->AddProperty("size", raw()->Size()); | 14163 jsobj->AddProperty("size", raw()->Size()); |
14165 } else { | 14164 } else { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14209 jsobj.AddProperty("kind", "NotInitialized"); | 14208 jsobj.AddProperty("kind", "NotInitialized"); |
14210 jsobj.AddProperty("valueAsString", "<not initialized>"); | 14209 jsobj.AddProperty("valueAsString", "<not initialized>"); |
14211 return; | 14210 return; |
14212 } else if (raw() == Object::transition_sentinel().raw()) { | 14211 } else if (raw() == Object::transition_sentinel().raw()) { |
14213 jsobj.AddProperty("type", "Sentinel"); | 14212 jsobj.AddProperty("type", "Sentinel"); |
14214 jsobj.AddProperty("kind", "BeingInitialized"); | 14213 jsobj.AddProperty("kind", "BeingInitialized"); |
14215 jsobj.AddProperty("valueAsString", "<being initialized>"); | 14214 jsobj.AddProperty("valueAsString", "<being initialized>"); |
14216 return; | 14215 return; |
14217 } | 14216 } |
14218 | 14217 |
14219 AddTypeProperties(&jsobj, "Instance", JSONType(), ref); | |
14220 PrintSharedInstanceJSON(&jsobj, ref); | 14218 PrintSharedInstanceJSON(&jsobj, ref); |
| 14219 if (IsClosure()) { |
| 14220 jsobj.AddProperty("kind", "Closure"); |
| 14221 } else { |
| 14222 jsobj.AddProperty("kind", "PlainInstance"); |
| 14223 } |
14221 jsobj.AddServiceId(*this); | 14224 jsobj.AddServiceId(*this); |
14222 if (IsClosure()) { | 14225 if (IsClosure()) { |
14223 jsobj.AddProperty("function", Function::Handle(Closure::function(*this))); | 14226 jsobj.AddProperty("closureFunction", |
14224 jsobj.AddProperty("context", Context::Handle(Closure::context(*this))); | 14227 Function::Handle(Closure::function(*this))); |
| 14228 jsobj.AddProperty("closureContext", |
| 14229 Context::Handle(Closure::context(*this))); |
14225 } | 14230 } |
14226 if (ref) { | 14231 if (ref) { |
14227 return; | 14232 return; |
14228 } | 14233 } |
14229 } | 14234 } |
14230 | 14235 |
14231 | 14236 |
14232 bool AbstractType::IsResolved() const { | 14237 bool AbstractType::IsResolved() const { |
14233 // AbstractType is an abstract class. | 14238 // AbstractType is an abstract class. |
14234 UNREACHABLE(); | 14239 UNREACHABLE(); |
(...skipping 1072 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15307 OS::SNPrint(NULL, 0, format, unresolved, class_name, args_cstr) + 1; | 15312 OS::SNPrint(NULL, 0, format, unresolved, class_name, args_cstr) + 1; |
15308 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 15313 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
15309 OS::SNPrint(chars, len, format, unresolved, class_name, args_cstr); | 15314 OS::SNPrint(chars, len, format, unresolved, class_name, args_cstr); |
15310 return chars; | 15315 return chars; |
15311 } | 15316 } |
15312 } | 15317 } |
15313 | 15318 |
15314 | 15319 |
15315 void Type::PrintJSONImpl(JSONStream* stream, bool ref) const { | 15320 void Type::PrintJSONImpl(JSONStream* stream, bool ref) const { |
15316 JSONObject jsobj(stream); | 15321 JSONObject jsobj(stream); |
15317 AddTypeProperties(&jsobj, "Type", JSONType(), ref); | |
15318 PrintSharedInstanceJSON(&jsobj, ref); | 15322 PrintSharedInstanceJSON(&jsobj, ref); |
| 15323 jsobj.AddProperty("kind", "Type"); |
15319 if (IsCanonical()) { | 15324 if (IsCanonical()) { |
15320 const Class& type_cls = Class::Handle(type_class()); | 15325 const Class& type_cls = Class::Handle(type_class()); |
15321 intptr_t id = type_cls.FindCanonicalTypeIndex(*this); | 15326 intptr_t id = type_cls.FindCanonicalTypeIndex(*this); |
15322 ASSERT(id >= 0); | 15327 ASSERT(id >= 0); |
15323 intptr_t cid = type_cls.id(); | 15328 intptr_t cid = type_cls.id(); |
15324 jsobj.AddFixedServiceId("classes/%" Pd "/types/%" Pd "", cid, id); | 15329 jsobj.AddFixedServiceId("classes/%" Pd "/types/%" Pd "", cid, id); |
15325 jsobj.AddProperty("typeClass", type_cls); | 15330 jsobj.AddProperty("typeClass", type_cls); |
15326 } else { | 15331 } else { |
15327 jsobj.AddServiceId(*this); | 15332 jsobj.AddServiceId(*this); |
15328 } | 15333 } |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15498 const intptr_t len = OS::SNPrint(NULL, 0, format, type_cstr) + 1; | 15503 const intptr_t len = OS::SNPrint(NULL, 0, format, type_cstr) + 1; |
15499 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 15504 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
15500 OS::SNPrint(chars, len, format, type_cstr); | 15505 OS::SNPrint(chars, len, format, type_cstr); |
15501 return chars; | 15506 return chars; |
15502 } | 15507 } |
15503 } | 15508 } |
15504 | 15509 |
15505 | 15510 |
15506 void TypeRef::PrintJSONImpl(JSONStream* stream, bool ref) const { | 15511 void TypeRef::PrintJSONImpl(JSONStream* stream, bool ref) const { |
15507 JSONObject jsobj(stream); | 15512 JSONObject jsobj(stream); |
15508 AddTypeProperties(&jsobj, "TypeRef", JSONType(), ref); | |
15509 PrintSharedInstanceJSON(&jsobj, ref); | 15513 PrintSharedInstanceJSON(&jsobj, ref); |
| 15514 jsobj.AddProperty("kind", "TypeRef"); |
15510 jsobj.AddServiceId(*this); | 15515 jsobj.AddServiceId(*this); |
15511 const String& user_name = String::Handle(PrettyName()); | 15516 const String& user_name = String::Handle(PrettyName()); |
15512 const String& vm_name = String::Handle(Name()); | 15517 const String& vm_name = String::Handle(Name()); |
15513 AddNameProperties(&jsobj, user_name, vm_name); | 15518 AddNameProperties(&jsobj, user_name, vm_name); |
15514 if (ref) { | 15519 if (ref) { |
15515 return; | 15520 return; |
15516 } | 15521 } |
15517 jsobj.AddProperty("refType", AbstractType::Handle(type())); | 15522 jsobj.AddProperty("type", AbstractType::Handle(type())); |
15518 } | 15523 } |
15519 | 15524 |
15520 | 15525 |
15521 void TypeParameter::set_is_finalized() const { | 15526 void TypeParameter::set_is_finalized() const { |
15522 ASSERT(!IsFinalized()); | 15527 ASSERT(!IsFinalized()); |
15523 set_type_state(RawTypeParameter::kFinalizedUninstantiated); | 15528 set_type_state(RawTypeParameter::kFinalizedUninstantiated); |
15524 } | 15529 } |
15525 | 15530 |
15526 | 15531 |
15527 bool TypeParameter::IsEquivalent(const Instance& other, | 15532 bool TypeParameter::IsEquivalent(const Instance& other, |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15732 intptr_t len = OS::SNPrint( | 15737 intptr_t len = OS::SNPrint( |
15733 NULL, 0, format, name_cstr, index(), cls_cstr, bound_cstr) + 1; | 15738 NULL, 0, format, name_cstr, index(), cls_cstr, bound_cstr) + 1; |
15734 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 15739 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
15735 OS::SNPrint(chars, len, format, name_cstr, index(), cls_cstr, bound_cstr); | 15740 OS::SNPrint(chars, len, format, name_cstr, index(), cls_cstr, bound_cstr); |
15736 return chars; | 15741 return chars; |
15737 } | 15742 } |
15738 | 15743 |
15739 | 15744 |
15740 void TypeParameter::PrintJSONImpl(JSONStream* stream, bool ref) const { | 15745 void TypeParameter::PrintJSONImpl(JSONStream* stream, bool ref) const { |
15741 JSONObject jsobj(stream); | 15746 JSONObject jsobj(stream); |
15742 AddTypeProperties(&jsobj, "TypeParameter", JSONType(), ref); | |
15743 PrintSharedInstanceJSON(&jsobj, ref); | 15747 PrintSharedInstanceJSON(&jsobj, ref); |
| 15748 jsobj.AddProperty("kind", "TypeParameter"); |
15744 jsobj.AddServiceId(*this); | 15749 jsobj.AddServiceId(*this); |
15745 const String& user_name = String::Handle(PrettyName()); | 15750 const String& user_name = String::Handle(PrettyName()); |
15746 const String& vm_name = String::Handle(Name()); | 15751 const String& vm_name = String::Handle(Name()); |
15747 AddNameProperties(&jsobj, user_name, vm_name); | 15752 AddNameProperties(&jsobj, user_name, vm_name); |
15748 const Class& param_cls = Class::Handle(parameterized_class()); | 15753 const Class& param_cls = Class::Handle(parameterized_class()); |
15749 jsobj.AddProperty("parameterizedClass", param_cls); | 15754 jsobj.AddProperty("parameterizedClass", param_cls); |
15750 if (ref) { | 15755 if (ref) { |
15751 return; | 15756 return; |
15752 } | 15757 } |
15753 jsobj.AddProperty("index", index()); | 15758 jsobj.AddProperty("parameterIndex", index()); |
15754 const AbstractType& upper_bound = AbstractType::Handle(bound()); | 15759 const AbstractType& upper_bound = AbstractType::Handle(bound()); |
15755 jsobj.AddProperty("upperBound", upper_bound); | 15760 jsobj.AddProperty("bound", upper_bound); |
15756 } | 15761 } |
15757 | 15762 |
15758 | 15763 |
15759 bool BoundedType::IsMalformed() const { | 15764 bool BoundedType::IsMalformed() const { |
15760 return AbstractType::Handle(type()).IsMalformed(); | 15765 return AbstractType::Handle(type()).IsMalformed(); |
15761 } | 15766 } |
15762 | 15767 |
15763 | 15768 |
15764 bool BoundedType::IsMalbounded() const { | 15769 bool BoundedType::IsMalbounded() const { |
15765 return AbstractType::Handle(type()).IsMalbounded(); | 15770 return AbstractType::Handle(type()).IsMalbounded(); |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15948 NULL, 0, format, type_cstr, bound_cstr, type_param_cstr, cls_cstr) + 1; | 15953 NULL, 0, format, type_cstr, bound_cstr, type_param_cstr, cls_cstr) + 1; |
15949 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 15954 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
15950 OS::SNPrint( | 15955 OS::SNPrint( |
15951 chars, len, format, type_cstr, bound_cstr, type_param_cstr, cls_cstr); | 15956 chars, len, format, type_cstr, bound_cstr, type_param_cstr, cls_cstr); |
15952 return chars; | 15957 return chars; |
15953 } | 15958 } |
15954 | 15959 |
15955 | 15960 |
15956 void BoundedType::PrintJSONImpl(JSONStream* stream, bool ref) const { | 15961 void BoundedType::PrintJSONImpl(JSONStream* stream, bool ref) const { |
15957 JSONObject jsobj(stream); | 15962 JSONObject jsobj(stream); |
15958 AddTypeProperties(&jsobj, "BoundedType", JSONType(), ref); | |
15959 PrintSharedInstanceJSON(&jsobj, ref); | 15963 PrintSharedInstanceJSON(&jsobj, ref); |
| 15964 jsobj.AddProperty("kind", "BoundedType"); |
15960 jsobj.AddServiceId(*this); | 15965 jsobj.AddServiceId(*this); |
15961 const String& user_name = String::Handle(PrettyName()); | 15966 const String& user_name = String::Handle(PrettyName()); |
15962 const String& vm_name = String::Handle(Name()); | 15967 const String& vm_name = String::Handle(Name()); |
15963 AddNameProperties(&jsobj, user_name, vm_name); | 15968 AddNameProperties(&jsobj, user_name, vm_name); |
15964 if (ref) { | 15969 if (ref) { |
15965 return; | 15970 return; |
15966 } | 15971 } |
15967 jsobj.AddProperty("boundedType", AbstractType::Handle(type())); | 15972 jsobj.AddProperty("type", AbstractType::Handle(type())); |
15968 jsobj.AddProperty("upperBound", AbstractType::Handle(bound())); | 15973 jsobj.AddProperty("bound", AbstractType::Handle(bound())); |
15969 } | 15974 } |
15970 | 15975 |
15971 | 15976 |
15972 intptr_t MixinAppType::token_pos() const { | 15977 intptr_t MixinAppType::token_pos() const { |
15973 return AbstractType::Handle(MixinTypeAt(0)).token_pos(); | 15978 return AbstractType::Handle(MixinTypeAt(0)).token_pos(); |
15974 } | 15979 } |
15975 | 15980 |
15976 | 15981 |
15977 intptr_t MixinAppType::Depth() const { | 15982 intptr_t MixinAppType::Depth() const { |
15978 return Array::Handle(mixin_types()).Length(); | 15983 return Array::Handle(mixin_types()).Length(); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16051 | 16056 |
16052 const char* Integer::ToCString() const { | 16057 const char* Integer::ToCString() const { |
16053 // Integer is an interface. No instances of Integer should exist. | 16058 // Integer is an interface. No instances of Integer should exist. |
16054 UNREACHABLE(); | 16059 UNREACHABLE(); |
16055 return "Integer"; | 16060 return "Integer"; |
16056 } | 16061 } |
16057 | 16062 |
16058 | 16063 |
16059 void Integer::PrintJSONImpl(JSONStream* stream, bool ref) const { | 16064 void Integer::PrintJSONImpl(JSONStream* stream, bool ref) const { |
16060 JSONObject jsobj(stream); | 16065 JSONObject jsobj(stream); |
16061 AddTypeProperties(&jsobj, "int", JSONType(), ref); | |
16062 PrintSharedInstanceJSON(&jsobj, ref); | 16066 PrintSharedInstanceJSON(&jsobj, ref); |
| 16067 jsobj.AddProperty("kind", "Int"); |
16063 jsobj.AddServiceId(*this); | 16068 jsobj.AddServiceId(*this); |
16064 jsobj.AddProperty("valueAsString", ToCString()); | 16069 jsobj.AddProperty("valueAsString", ToCString()); |
16065 } | 16070 } |
16066 | 16071 |
16067 | 16072 |
16068 // Throw JavascriptIntegerOverflow exception. | 16073 // Throw JavascriptIntegerOverflow exception. |
16069 static void ThrowJavascriptIntegerOverflow(const Integer& i) { | 16074 static void ThrowJavascriptIntegerOverflow(const Integer& i) { |
16070 const Array& exc_args = Array::Handle(Array::New(1)); | 16075 const Array& exc_args = Array::Handle(Array::New(1)); |
16071 const String& i_str = String::Handle(String::New(i.ToCString())); | 16076 const String& i_str = String::Handle(String::New(i.ToCString())); |
16072 exc_args.SetAt(0, i_str); | 16077 exc_args.SetAt(0, i_str); |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16480 // Calculate the size of the string. | 16485 // Calculate the size of the string. |
16481 intptr_t len = OS::SNPrint(NULL, 0, kFormat, Value()) + 1; | 16486 intptr_t len = OS::SNPrint(NULL, 0, kFormat, Value()) + 1; |
16482 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 16487 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
16483 OS::SNPrint(chars, len, kFormat, Value()); | 16488 OS::SNPrint(chars, len, kFormat, Value()); |
16484 return chars; | 16489 return chars; |
16485 } | 16490 } |
16486 | 16491 |
16487 | 16492 |
16488 void Smi::PrintJSONImpl(JSONStream* stream, bool ref) const { | 16493 void Smi::PrintJSONImpl(JSONStream* stream, bool ref) const { |
16489 JSONObject jsobj(stream); | 16494 JSONObject jsobj(stream); |
16490 AddTypeProperties(&jsobj, "int", JSONType(), ref); | |
16491 PrintSharedInstanceJSON(&jsobj, ref); | 16495 PrintSharedInstanceJSON(&jsobj, ref); |
| 16496 jsobj.AddProperty("kind", "Int"); |
16492 jsobj.AddFixedServiceId("objects/int-%" Pd "", Value()); | 16497 jsobj.AddFixedServiceId("objects/int-%" Pd "", Value()); |
16493 jsobj.AddPropertyF("valueAsString", "%" Pd "", Value()); | 16498 jsobj.AddPropertyF("valueAsString", "%" Pd "", Value()); |
16494 } | 16499 } |
16495 | 16500 |
16496 | 16501 |
16497 RawClass* Smi::Class() { | 16502 RawClass* Smi::Class() { |
16498 return Isolate::Current()->object_store()->smi_class(); | 16503 return Isolate::Current()->object_store()->smi_class(); |
16499 } | 16504 } |
16500 | 16505 |
16501 | 16506 |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16742 const int kBufferSize = 128; | 16747 const int kBufferSize = 128; |
16743 char* buffer = Isolate::Current()->current_zone()->Alloc<char>(kBufferSize); | 16748 char* buffer = Isolate::Current()->current_zone()->Alloc<char>(kBufferSize); |
16744 buffer[kBufferSize - 1] = '\0'; | 16749 buffer[kBufferSize - 1] = '\0'; |
16745 DoubleToCString(value(), buffer, kBufferSize); | 16750 DoubleToCString(value(), buffer, kBufferSize); |
16746 return buffer; | 16751 return buffer; |
16747 } | 16752 } |
16748 | 16753 |
16749 | 16754 |
16750 void Double::PrintJSONImpl(JSONStream* stream, bool ref) const { | 16755 void Double::PrintJSONImpl(JSONStream* stream, bool ref) const { |
16751 JSONObject jsobj(stream); | 16756 JSONObject jsobj(stream); |
16752 // Suppress the fact that the internal vm name for this type is | |
16753 // "Double". Return "double" instead. | |
16754 AddTypeProperties(&jsobj, "double", "double", ref); | |
16755 PrintSharedInstanceJSON(&jsobj, ref); | 16757 PrintSharedInstanceJSON(&jsobj, ref); |
| 16758 jsobj.AddProperty("kind", "Double"); |
16756 jsobj.AddServiceId(*this); | 16759 jsobj.AddServiceId(*this); |
16757 jsobj.AddProperty("valueAsString", ToCString()); | 16760 jsobj.AddProperty("valueAsString", ToCString()); |
16758 } | 16761 } |
16759 | 16762 |
16760 | 16763 |
16761 bool Bigint::Neg() const { | 16764 bool Bigint::Neg() const { |
16762 return Bool::Handle(neg()).value(); | 16765 return Bool::Handle(neg()).value(); |
16763 } | 16766 } |
16764 | 16767 |
16765 | 16768 |
(...skipping 1558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
18324 JSONObject jsobj(stream); | 18327 JSONObject jsobj(stream); |
18325 if (raw() == Symbols::OptimizedOut().raw()) { | 18328 if (raw() == Symbols::OptimizedOut().raw()) { |
18326 // TODO(turnidge): This is a hack. The user could have this | 18329 // TODO(turnidge): This is a hack. The user could have this |
18327 // special string in their program. Fixing this involves updating | 18330 // special string in their program. Fixing this involves updating |
18328 // the debugging api a bit. | 18331 // the debugging api a bit. |
18329 jsobj.AddProperty("type", "Sentinel"); | 18332 jsobj.AddProperty("type", "Sentinel"); |
18330 jsobj.AddProperty("kind", "OptimizedOut"); | 18333 jsobj.AddProperty("kind", "OptimizedOut"); |
18331 jsobj.AddProperty("valueAsString", "<optimized out>"); | 18334 jsobj.AddProperty("valueAsString", "<optimized out>"); |
18332 return; | 18335 return; |
18333 } | 18336 } |
18334 AddTypeProperties(&jsobj, "String", JSONType(), ref); | |
18335 PrintSharedInstanceJSON(&jsobj, ref); | 18337 PrintSharedInstanceJSON(&jsobj, ref); |
| 18338 jsobj.AddProperty("kind", "String"); |
18336 jsobj.AddServiceId(*this); | 18339 jsobj.AddServiceId(*this); |
18337 if (ref) { | 18340 if (ref) { |
18338 bool did_truncate = jsobj.AddPropertyStr("valueAsString", *this, 128); | 18341 bool did_truncate = jsobj.AddPropertyStr("valueAsString", *this, 128); |
18339 if (did_truncate) { | 18342 if (did_truncate) { |
18340 jsobj.AddProperty("valueAsStringIsTruncated", did_truncate); | 18343 jsobj.AddProperty("valueAsStringIsTruncated", did_truncate); |
18341 } | 18344 } |
18342 } else { | 18345 } else { |
18343 bool did_truncate = jsobj.AddPropertyStr("valueAsString", *this); | 18346 bool did_truncate = jsobj.AddPropertyStr("valueAsString", *this); |
18344 ASSERT(!did_truncate); | 18347 ASSERT(!did_truncate); |
18345 } | 18348 } |
(...skipping 887 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
19233 | 19236 |
19234 | 19237 |
19235 const char* Bool::ToCString() const { | 19238 const char* Bool::ToCString() const { |
19236 return value() ? "true" : "false"; | 19239 return value() ? "true" : "false"; |
19237 } | 19240 } |
19238 | 19241 |
19239 | 19242 |
19240 void Bool::PrintJSONImpl(JSONStream* stream, bool ref) const { | 19243 void Bool::PrintJSONImpl(JSONStream* stream, bool ref) const { |
19241 const char* str = ToCString(); | 19244 const char* str = ToCString(); |
19242 JSONObject jsobj(stream); | 19245 JSONObject jsobj(stream); |
19243 // Suppress the fact that the internal vm name for this type is | |
19244 // "Bool". Return "bool" instead. | |
19245 AddTypeProperties(&jsobj, "bool", "bool", ref); | |
19246 PrintSharedInstanceJSON(&jsobj, ref); | 19246 PrintSharedInstanceJSON(&jsobj, ref); |
| 19247 jsobj.AddProperty("kind", "Bool"); |
19247 jsobj.AddFixedServiceId("objects/bool-%s", str); | 19248 jsobj.AddFixedServiceId("objects/bool-%s", str); |
19248 jsobj.AddPropertyF("valueAsString", "%s", str); | 19249 jsobj.AddPropertyF("valueAsString", "%s", str); |
19249 } | 19250 } |
19250 | 19251 |
19251 | 19252 |
19252 bool Array::CanonicalizeEquals(const Instance& other) const { | 19253 bool Array::CanonicalizeEquals(const Instance& other) const { |
19253 if (this->raw() == other.raw()) { | 19254 if (this->raw() == other.raw()) { |
19254 // Both handles point to the same raw instance. | 19255 // Both handles point to the same raw instance. |
19255 return true; | 19256 return true; |
19256 } | 19257 } |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
19347 "_ImmutableList len:%" Pd : "_List len:%" Pd; | 19348 "_ImmutableList len:%" Pd : "_List len:%" Pd; |
19348 intptr_t len = OS::SNPrint(NULL, 0, format, Length()) + 1; | 19349 intptr_t len = OS::SNPrint(NULL, 0, format, Length()) + 1; |
19349 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 19350 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
19350 OS::SNPrint(chars, len, format, Length()); | 19351 OS::SNPrint(chars, len, format, Length()); |
19351 return chars; | 19352 return chars; |
19352 } | 19353 } |
19353 | 19354 |
19354 | 19355 |
19355 void Array::PrintJSONImpl(JSONStream* stream, bool ref) const { | 19356 void Array::PrintJSONImpl(JSONStream* stream, bool ref) const { |
19356 JSONObject jsobj(stream); | 19357 JSONObject jsobj(stream); |
19357 AddTypeProperties(&jsobj, "List", JSONType(), ref); | |
19358 PrintSharedInstanceJSON(&jsobj, ref); | 19358 PrintSharedInstanceJSON(&jsobj, ref); |
| 19359 jsobj.AddProperty("kind", "List"); |
19359 jsobj.AddServiceId(*this); | 19360 jsobj.AddServiceId(*this); |
19360 jsobj.AddProperty("length", Length()); | 19361 jsobj.AddProperty("length", Length()); |
19361 if (ref) { | 19362 if (ref) { |
19362 return; | 19363 return; |
19363 } | 19364 } |
19364 { | 19365 { |
19365 JSONArray jsarr(&jsobj, "elements"); | 19366 JSONArray jsarr(&jsobj, "elements"); |
19366 for (intptr_t index = 0; index < Length(); index++) { | 19367 for (intptr_t index = 0; index < Length(); index++) { |
19367 JSONObject jselement(&jsarr); | 19368 JSONObject jselement(&jsarr); |
19368 jselement.AddProperty("index", index); | 19369 jselement.AddProperty("index", index); |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
19593 intptr_t len = OS::SNPrint(NULL, 0, format, Length()) + 1; | 19594 intptr_t len = OS::SNPrint(NULL, 0, format, Length()) + 1; |
19594 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 19595 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
19595 OS::SNPrint(chars, len, format, Length()); | 19596 OS::SNPrint(chars, len, format, Length()); |
19596 return chars; | 19597 return chars; |
19597 } | 19598 } |
19598 | 19599 |
19599 | 19600 |
19600 void GrowableObjectArray::PrintJSONImpl(JSONStream* stream, | 19601 void GrowableObjectArray::PrintJSONImpl(JSONStream* stream, |
19601 bool ref) const { | 19602 bool ref) const { |
19602 JSONObject jsobj(stream); | 19603 JSONObject jsobj(stream); |
19603 AddTypeProperties(&jsobj, "List", JSONType(), ref); | |
19604 PrintSharedInstanceJSON(&jsobj, ref); | 19604 PrintSharedInstanceJSON(&jsobj, ref); |
| 19605 jsobj.AddProperty("kind", "List"); |
19605 jsobj.AddServiceId(*this); | 19606 jsobj.AddServiceId(*this); |
19606 jsobj.AddProperty("length", Length()); | 19607 jsobj.AddProperty("length", Length()); |
19607 if (ref) { | 19608 if (ref) { |
19608 return; | 19609 return; |
19609 } | 19610 } |
19610 { | 19611 { |
19611 JSONArray jsarr(&jsobj, "elements"); | 19612 JSONArray jsarr(&jsobj, "elements"); |
19612 for (intptr_t index = 0; index < Length(); index++) { | 19613 for (intptr_t index = 0; index < Length(); index++) { |
19613 JSONObject jselement(&jsarr); | 19614 JSONObject jselement(&jsarr); |
19614 jselement.AddProperty("index", index); | 19615 jselement.AddProperty("index", index); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
19705 } | 19706 } |
19706 | 19707 |
19707 | 19708 |
19708 const char* LinkedHashMap::ToCString() const { | 19709 const char* LinkedHashMap::ToCString() const { |
19709 // TODO(koda): Print key/value pairs. | 19710 // TODO(koda): Print key/value pairs. |
19710 return "_LinkedHashMap"; | 19711 return "_LinkedHashMap"; |
19711 } | 19712 } |
19712 | 19713 |
19713 | 19714 |
19714 void LinkedHashMap::PrintJSONImpl(JSONStream* stream, bool ref) const { | 19715 void LinkedHashMap::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 19716 JSONObject jsobj(stream); |
| 19717 PrintSharedInstanceJSON(&jsobj, ref); |
| 19718 jsobj.AddProperty("kind", "Map"); |
| 19719 jsobj.AddServiceId(*this); |
| 19720 // TODO(koda): Print length. |
| 19721 if (ref) { |
| 19722 return; |
| 19723 } |
19715 // TODO(koda): Print key/value pairs. | 19724 // TODO(koda): Print key/value pairs. |
19716 Instance::PrintJSONImpl(stream, ref); | |
19717 } | 19725 } |
19718 | 19726 |
19719 | 19727 |
19720 RawFloat32x4* Float32x4::New(float v0, float v1, float v2, float v3, | 19728 RawFloat32x4* Float32x4::New(float v0, float v1, float v2, float v3, |
19721 Heap::Space space) { | 19729 Heap::Space space) { |
19722 ASSERT(Isolate::Current()->object_store()->float32x4_class() != | 19730 ASSERT(Isolate::Current()->object_store()->float32x4_class() != |
19723 Class::null()); | 19731 Class::null()); |
19724 Float32x4& result = Float32x4::Handle(); | 19732 Float32x4& result = Float32x4::Handle(); |
19725 { | 19733 { |
19726 RawObject* raw = Object::Allocate(Float32x4::kClassId, | 19734 RawObject* raw = Object::Allocate(Float32x4::kClassId, |
(...skipping 854 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
20581 } | 20589 } |
20582 | 20590 |
20583 | 20591 |
20584 const char* WeakProperty::ToCString() const { | 20592 const char* WeakProperty::ToCString() const { |
20585 return "_WeakProperty"; | 20593 return "_WeakProperty"; |
20586 } | 20594 } |
20587 | 20595 |
20588 | 20596 |
20589 void WeakProperty::PrintJSONImpl(JSONStream* stream, bool ref) const { | 20597 void WeakProperty::PrintJSONImpl(JSONStream* stream, bool ref) const { |
20590 JSONObject jsobj(stream); | 20598 JSONObject jsobj(stream); |
20591 AddTypeProperties(&jsobj, "Instance", JSONType(), ref); | |
20592 PrintSharedInstanceJSON(&jsobj, ref); | 20599 PrintSharedInstanceJSON(&jsobj, ref); |
| 20600 jsobj.AddProperty("kind", "WeakProperty"); |
20593 jsobj.AddServiceId(*this); | 20601 jsobj.AddServiceId(*this); |
20594 if (ref) { | 20602 if (ref) { |
20595 return; | 20603 return; |
20596 } | 20604 } |
20597 | 20605 |
20598 const Object& key_handle = Object::Handle(key()); | 20606 const Object& key_handle = Object::Handle(key()); |
20599 jsobj.AddProperty("key", key_handle); | 20607 jsobj.AddProperty("propertyKey", key_handle); |
20600 const Object& value_handle = Object::Handle(value()); | 20608 const Object& value_handle = Object::Handle(value()); |
20601 jsobj.AddProperty("value", value_handle); | 20609 jsobj.AddProperty("propertyValue", value_handle); |
20602 } | 20610 } |
20603 | 20611 |
20604 RawAbstractType* MirrorReference::GetAbstractTypeReferent() const { | 20612 RawAbstractType* MirrorReference::GetAbstractTypeReferent() const { |
20605 ASSERT(Object::Handle(referent()).IsAbstractType()); | 20613 ASSERT(Object::Handle(referent()).IsAbstractType()); |
20606 return AbstractType::Cast(Object::Handle(referent())).raw(); | 20614 return AbstractType::Cast(Object::Handle(referent())).raw(); |
20607 } | 20615 } |
20608 | 20616 |
20609 | 20617 |
20610 RawClass* MirrorReference::GetClassReferent() const { | 20618 RawClass* MirrorReference::GetClassReferent() const { |
20611 ASSERT(Object::Handle(referent()).IsClass()); | 20619 ASSERT(Object::Handle(referent()).IsClass()); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
20652 } | 20660 } |
20653 | 20661 |
20654 | 20662 |
20655 const char* MirrorReference::ToCString() const { | 20663 const char* MirrorReference::ToCString() const { |
20656 return "_MirrorReference"; | 20664 return "_MirrorReference"; |
20657 } | 20665 } |
20658 | 20666 |
20659 | 20667 |
20660 void MirrorReference::PrintJSONImpl(JSONStream* stream, bool ref) const { | 20668 void MirrorReference::PrintJSONImpl(JSONStream* stream, bool ref) const { |
20661 JSONObject jsobj(stream); | 20669 JSONObject jsobj(stream); |
20662 AddTypeProperties(&jsobj, "Instance", JSONType(), ref); | |
20663 PrintSharedInstanceJSON(&jsobj, ref); | 20670 PrintSharedInstanceJSON(&jsobj, ref); |
| 20671 jsobj.AddProperty("kind", "MirrorReference"); |
20664 jsobj.AddServiceId(*this); | 20672 jsobj.AddServiceId(*this); |
20665 | 20673 |
20666 if (ref) { | 20674 if (ref) { |
20667 return; | 20675 return; |
20668 } | 20676 } |
20669 | 20677 |
20670 const Object& referent_handle = Object::Handle(referent()); | 20678 const Object& referent_handle = Object::Handle(referent()); |
20671 jsobj.AddProperty("referent", referent_handle); | 20679 jsobj.AddProperty("mirrorReferent", referent_handle); |
20672 } | 20680 } |
20673 | 20681 |
20674 | 20682 |
20675 void UserTag::MakeActive() const { | 20683 void UserTag::MakeActive() const { |
20676 Isolate* isolate = Isolate::Current(); | 20684 Isolate* isolate = Isolate::Current(); |
20677 ASSERT(isolate != NULL); | 20685 ASSERT(isolate != NULL); |
20678 isolate->set_current_tag(*this); | 20686 isolate->set_current_tag(*this); |
20679 } | 20687 } |
20680 | 20688 |
20681 | 20689 |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
20799 return tag_label.ToCString(); | 20807 return tag_label.ToCString(); |
20800 } | 20808 } |
20801 | 20809 |
20802 | 20810 |
20803 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 20811 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { |
20804 Instance::PrintJSONImpl(stream, ref); | 20812 Instance::PrintJSONImpl(stream, ref); |
20805 } | 20813 } |
20806 | 20814 |
20807 | 20815 |
20808 } // namespace dart | 20816 } // namespace dart |
OLD | NEW |