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

Side by Side Diff: runtime/vm/object.cc

Issue 547703002: Rework how types work in the VM Service. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: gen js Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/object_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/object.h" 5 #include "vm/object.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/assembler.h" 9 #include "vm/assembler.h"
10 #include "vm/cpu.h" 10 #include "vm/cpu.h"
(...skipping 1538 matching lines...) Expand 10 before | Expand all | Expand 10 after
1549 1549
1550 cls = Class::New<UserTag>(); 1550 cls = Class::New<UserTag>();
1551 } 1551 }
1552 1552
1553 1553
1554 void Object::Print() const { 1554 void Object::Print() const {
1555 OS::Print("%s\n", ToCString()); 1555 OS::Print("%s\n", ToCString());
1556 } 1556 }
1557 1557
1558 1558
1559 static void AddNameProperties(JSONObject* jsobj,
1560 const String& name,
1561 const String& vm_name) {
1562 jsobj->AddProperty("name", name.ToCString());
1563 if (!name.Equals(vm_name)) {
1564 jsobj->AddProperty("_vmName", vm_name.ToCString());
1565 }
1566 }
1567
1568
1569 static void AddTypeProperties(JSONObject* jsobj,
1570 const char* user_type,
1571 const char* vm_type,
1572 bool ref) {
1573 bool same_type = (strcmp(user_type, vm_type) == 0);
1574 if (ref) {
1575 jsobj->AddPropertyF("type", "@%s", user_type);
1576 if (!same_type) {
1577 jsobj->AddPropertyF("_vmType", "@%s", vm_type);
1578 }
1579 } else {
1580 jsobj->AddProperty("type", user_type);
1581 if (!same_type) {
1582 jsobj->AddProperty("_vmType", vm_type);
1583 }
1584 }
1585 }
1586
1587
1559 void Object::PrintJSON(JSONStream* stream, bool ref) const { 1588 void Object::PrintJSON(JSONStream* stream, bool ref) const {
1560 if (IsNull()) { 1589 if (IsNull()) {
1561 JSONObject jsobj(stream); 1590 JSONObject jsobj(stream);
1562 jsobj.AddProperty("type", ref ? "@Null" : "Null"); 1591 AddTypeProperties(&jsobj, "null", JSONType(), ref);
1563 jsobj.AddProperty("id", "objects/null"); 1592 jsobj.AddProperty("id", "objects/null");
1564 jsobj.AddProperty("valueAsString", "null"); 1593 jsobj.AddProperty("valueAsString", "null");
1565 if (!ref) { 1594 if (!ref) {
1566 const Class& cls = Class::Handle(this->clazz()); 1595 const Class& cls = Class::Handle(this->clazz());
1567 jsobj.AddProperty("class", cls); 1596 jsobj.AddProperty("class", cls);
1568 jsobj.AddProperty("size", raw()->Size()); 1597 jsobj.AddProperty("size", raw()->Size());
1569 } 1598 }
1570 } else { 1599 } else {
1571 PrintJSONImpl(stream, ref); 1600 PrintJSONImpl(stream, ref);
1572 } 1601 }
1573 } 1602 }
1574 1603
1575 1604
1605 void Object::PrintJSONImpl(JSONStream* stream, bool ref) const {
1606 JSONObject jsobj(stream);
1607 AddTypeProperties(&jsobj, "Object", JSONType(), ref);
1608 ObjectIdRing* ring = Isolate::Current()->object_id_ring();
1609 const intptr_t id = ring->GetIdForObject(raw());
1610 jsobj.AddPropertyF("id", "objects/%" Pd "", id);
1611 }
1612
1613
1576 RawString* Object::DictionaryName() const { 1614 RawString* Object::DictionaryName() const {
1577 return String::null(); 1615 return String::null();
1578 } 1616 }
1579 1617
1580 1618
1581 void Object::InitializeObject(uword address, intptr_t class_id, intptr_t size) { 1619 void Object::InitializeObject(uword address, intptr_t class_id, intptr_t size) {
1582 // TODO(iposva): Get a proper halt instruction from the assembler which 1620 // TODO(iposva): Get a proper halt instruction from the assembler which
1583 // would be needed here for code objects. 1621 // would be needed here for code objects.
1584 uword initial_value = reinterpret_cast<uword>(null_); 1622 uword initial_value = reinterpret_cast<uword>(null_);
1585 uword cur = address; 1623 uword cur = address;
(...skipping 2510 matching lines...) Expand 10 before | Expand all | Expand 10 after
4096 const Library& lib = Library::Handle(library()); 4134 const Library& lib = Library::Handle(library());
4097 const char* library_name = lib.IsNull() ? "" : lib.ToCString(); 4135 const char* library_name = lib.IsNull() ? "" : lib.ToCString();
4098 const char* class_name = String::Handle(Name()).ToCString(); 4136 const char* class_name = String::Handle(Name()).ToCString();
4099 intptr_t len = OS::SNPrint(NULL, 0, format, library_name, class_name) + 1; 4137 intptr_t len = OS::SNPrint(NULL, 0, format, library_name, class_name) + 1;
4100 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); 4138 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
4101 OS::SNPrint(chars, len, format, library_name, class_name); 4139 OS::SNPrint(chars, len, format, library_name, class_name);
4102 return chars; 4140 return chars;
4103 } 4141 }
4104 4142
4105 4143
4106 static void AddNameProperties(JSONObject* jsobj,
4107 const String& name,
4108 const String& vm_name) {
4109 jsobj->AddProperty("name", name.ToCString());
4110 if (!name.Equals(vm_name)) {
4111 jsobj->AddProperty("vmName", vm_name.ToCString());
4112 }
4113 }
4114
4115
4116 void Class::PrintJSONImpl(JSONStream* stream, bool ref) const { 4144 void Class::PrintJSONImpl(JSONStream* stream, bool ref) const {
4117 JSONObject jsobj(stream); 4145 JSONObject jsobj(stream);
4118 if ((raw() == Class::null()) || (id() == kFreeListElement)) { 4146 if ((raw() == Class::null()) || (id() == kFreeListElement)) {
4119 jsobj.AddProperty("type", "Null"); 4147 // TODO(turnidge): This is weird. See if there is another way to
4148 // handle this.
4149 jsobj.AddProperty("type", "null");
4120 return; 4150 return;
4121 } 4151 }
4122 jsobj.AddProperty("type", JSONType(ref)); 4152 AddTypeProperties(&jsobj, "Class", JSONType(), ref);
4123 jsobj.AddPropertyF("id", "classes/%" Pd "", id()); 4153 jsobj.AddPropertyF("id", "classes/%" Pd "", id());
4124 const String& user_name = String::Handle(PrettyName()); 4154 const String& user_name = String::Handle(PrettyName());
4125 const String& vm_name = String::Handle(Name()); 4155 const String& vm_name = String::Handle(Name());
4126 AddNameProperties(&jsobj, user_name, vm_name); 4156 AddNameProperties(&jsobj, user_name, vm_name);
4127 if (ref) { 4157 if (ref) {
4128 return; 4158 return;
4129 } 4159 }
4130 4160
4131 const Error& err = Error::Handle(EnsureIsFinalized(Isolate::Current())); 4161 const Error& err = Error::Handle(EnsureIsFinalized(Isolate::Current()));
4132 if (!err.IsNull()) { 4162 if (!err.IsNull()) {
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
4450 JSONObject jsobj(stream); 4480 JSONObject jsobj(stream);
4451 // The index in the canonical_type_arguments table cannot be used as part of 4481 // The index in the canonical_type_arguments table cannot be used as part of
4452 // the object id (as in typearguments/id), because the indices are not 4482 // the object id (as in typearguments/id), because the indices are not
4453 // preserved when the table grows and the entries get rehashed. Use the ring. 4483 // preserved when the table grows and the entries get rehashed. Use the ring.
4454 Isolate* isolate = Isolate::Current(); 4484 Isolate* isolate = Isolate::Current();
4455 ObjectStore* object_store = isolate->object_store(); 4485 ObjectStore* object_store = isolate->object_store();
4456 const Array& table = Array::Handle(object_store->canonical_type_arguments()); 4486 const Array& table = Array::Handle(object_store->canonical_type_arguments());
4457 ASSERT(table.Length() > 0); 4487 ASSERT(table.Length() > 0);
4458 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); 4488 ObjectIdRing* ring = Isolate::Current()->object_id_ring();
4459 const intptr_t id = ring->GetIdForObject(raw()); 4489 const intptr_t id = ring->GetIdForObject(raw());
4460 jsobj.AddProperty("type", JSONType(ref)); 4490 AddTypeProperties(&jsobj, "TypeArguments", JSONType(), ref);
4461 jsobj.AddPropertyF("id", "objects/%" Pd "", id); 4491 jsobj.AddPropertyF("id", "objects/%" Pd "", id);
4462 const String& user_name = String::Handle(PrettyName()); 4492 const String& user_name = String::Handle(PrettyName());
4463 const String& vm_name = String::Handle(Name()); 4493 const String& vm_name = String::Handle(Name());
4464 AddNameProperties(&jsobj, user_name, vm_name); 4494 AddNameProperties(&jsobj, user_name, vm_name);
4465 jsobj.AddProperty("length", Length()); 4495 jsobj.AddProperty("length", Length());
4466 jsobj.AddProperty("numInstantiations", NumInstantiations()); 4496 jsobj.AddProperty("numInstantiations", NumInstantiations());
4467 if (ref) { 4497 if (ref) {
4468 return; 4498 return;
4469 } 4499 }
4470 { 4500 {
(...skipping 2329 matching lines...) Expand 10 before | Expand all | Expand 10 after
6800 } 6830 }
6801 6831
6802 6832
6803 void Function::PrintJSONImpl(JSONStream* stream, bool ref) const { 6833 void Function::PrintJSONImpl(JSONStream* stream, bool ref) const {
6804 Class& cls = Class::Handle(Owner()); 6834 Class& cls = Class::Handle(Owner());
6805 ASSERT(!cls.IsNull()); 6835 ASSERT(!cls.IsNull());
6806 Error& err = Error::Handle(); 6836 Error& err = Error::Handle();
6807 err ^= cls.EnsureIsFinalized(Isolate::Current()); 6837 err ^= cls.EnsureIsFinalized(Isolate::Current());
6808 ASSERT(err.IsNull()); 6838 ASSERT(err.IsNull());
6809 JSONObject jsobj(stream); 6839 JSONObject jsobj(stream);
6810 jsobj.AddProperty("type", JSONType(ref)); 6840 AddTypeProperties(&jsobj, "Function", JSONType(), ref);
6811 jsobj.AddProperty("id", GetFunctionServiceId(*this, cls)); 6841 jsobj.AddProperty("id", GetFunctionServiceId(*this, cls));
6812 const String& user_name = String::Handle(PrettyName()); 6842 const String& user_name = String::Handle(PrettyName());
6813 const String& vm_name = String::Handle(name()); 6843 const String& vm_name = String::Handle(name());
6814 AddNameProperties(&jsobj, user_name, vm_name); 6844 AddNameProperties(&jsobj, user_name, vm_name);
6815 if (cls.IsTopLevel()) { 6845 if (cls.IsTopLevel()) {
6816 const Library& library = Library::Handle(cls.library()); 6846 const Library& library = Library::Handle(cls.library());
6817 jsobj.AddProperty("owningLibrary", library); 6847 jsobj.AddProperty("owningLibrary", library);
6818 } else { 6848 } else {
6819 jsobj.AddProperty("owningClass", cls); 6849 jsobj.AddProperty("owningClass", cls);
6820 } 6850 }
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
7146 OS::SNPrint(chars, len, kFormat, cls_name, field_name, kF0, kF1, kF2); 7176 OS::SNPrint(chars, len, kFormat, cls_name, field_name, kF0, kF1, kF2);
7147 return chars; 7177 return chars;
7148 } 7178 }
7149 7179
7150 void Field::PrintJSONImpl(JSONStream* stream, bool ref) const { 7180 void Field::PrintJSONImpl(JSONStream* stream, bool ref) const {
7151 JSONObject jsobj(stream); 7181 JSONObject jsobj(stream);
7152 Class& cls = Class::Handle(owner()); 7182 Class& cls = Class::Handle(owner());
7153 intptr_t id = cls.FindFieldIndex(*this); 7183 intptr_t id = cls.FindFieldIndex(*this);
7154 ASSERT(id >= 0); 7184 ASSERT(id >= 0);
7155 intptr_t cid = cls.id(); 7185 intptr_t cid = cls.id();
7156 jsobj.AddProperty("type", JSONType(ref)); 7186 AddTypeProperties(&jsobj, "Field", JSONType(), ref);
7157 jsobj.AddPropertyF("id", "classes/%" Pd "/fields/%" Pd "", cid, id); 7187 jsobj.AddPropertyF("id", "classes/%" Pd "/fields/%" Pd "", cid, id);
7158 const String& user_name = String::Handle(PrettyName()); 7188 const String& user_name = String::Handle(PrettyName());
7159 const String& vm_name = String::Handle(name()); 7189 const String& vm_name = String::Handle(name());
7160 AddNameProperties(&jsobj, user_name, vm_name); 7190 AddNameProperties(&jsobj, user_name, vm_name);
7161 if (is_static()) { 7191 if (is_static()) {
7162 const Instance& valueObj = Instance::Handle(value()); 7192 const Instance& valueObj = Instance::Handle(value());
7163 jsobj.AddProperty("value", valueObj); 7193 jsobj.AddProperty("value", valueObj);
7164 } 7194 }
7165 7195
7166 if (cls.IsTopLevel()) { 7196 if (cls.IsTopLevel()) {
(...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after
7937 } 7967 }
7938 7968
7939 7969
7940 const char* TokenStream::ToCString() const { 7970 const char* TokenStream::ToCString() const {
7941 return "TokenStream"; 7971 return "TokenStream";
7942 } 7972 }
7943 7973
7944 7974
7945 void TokenStream::PrintJSONImpl(JSONStream* stream, bool ref) const { 7975 void TokenStream::PrintJSONImpl(JSONStream* stream, bool ref) const {
7946 JSONObject jsobj(stream); 7976 JSONObject jsobj(stream);
7947 jsobj.AddProperty("type", JSONType(ref)); 7977 AddTypeProperties(&jsobj, "Object", JSONType(), ref);
7948 // TODO(johnmccutchan): Generate a stable id. TokenStreams hang off 7978 // TODO(johnmccutchan): Generate a stable id. TokenStreams hang off
7949 // a Script object but do not have a back reference to generate a stable id. 7979 // a Script object but do not have a back reference to generate a stable id.
7950 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); 7980 ObjectIdRing* ring = Isolate::Current()->object_id_ring();
7951 const intptr_t id = ring->GetIdForObject(raw()); 7981 const intptr_t id = ring->GetIdForObject(raw());
7952 jsobj.AddPropertyF("id", "objects/%" Pd "", id); 7982 jsobj.AddPropertyF("id", "objects/%" Pd "", id);
7953 if (ref) { 7983 if (ref) {
7954 return; 7984 return;
7955 } 7985 }
7956 const String& private_key = String::Handle(PrivateKey()); 7986 const String& private_key = String::Handle(PrivateKey());
7957 jsobj.AddProperty("privateKey", private_key); 7987 jsobj.AddProperty("privateKey", private_key);
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after
8480 } 8510 }
8481 } 8511 }
8482 } 8512 }
8483 return Library::null(); 8513 return Library::null();
8484 } 8514 }
8485 8515
8486 8516
8487 // See also Dart_ScriptGetTokenInfo. 8517 // See also Dart_ScriptGetTokenInfo.
8488 void Script::PrintJSONImpl(JSONStream* stream, bool ref) const { 8518 void Script::PrintJSONImpl(JSONStream* stream, bool ref) const {
8489 JSONObject jsobj(stream); 8519 JSONObject jsobj(stream);
8490 jsobj.AddProperty("type", JSONType(ref)); 8520 AddTypeProperties(&jsobj, "Script", JSONType(), ref);
8491 const String& name = String::Handle(url()); 8521 const String& name = String::Handle(url());
8492 ASSERT(!name.IsNull()); 8522 ASSERT(!name.IsNull());
8493 const String& encoded_url = String::Handle(String::EncodeIRI(name)); 8523 const String& encoded_url = String::Handle(String::EncodeIRI(name));
8494 ASSERT(!encoded_url.IsNull()); 8524 ASSERT(!encoded_url.IsNull());
8495 const Library& lib = Library::Handle(FindLibrary()); 8525 const Library& lib = Library::Handle(FindLibrary());
8496 intptr_t lib_index = (lib.IsNull()) ? -1 : lib.index(); 8526 intptr_t lib_index = (lib.IsNull()) ? -1 : lib.index();
8497 jsobj.AddPropertyF("id", "libraries/%" Pd "/scripts/%s", 8527 jsobj.AddPropertyF("id", "libraries/%" Pd "/scripts/%s",
8498 lib_index, encoded_url.ToCString()); 8528 lib_index, encoded_url.ToCString());
8499 jsobj.AddProperty("name", name.ToCString()); 8529 jsobj.AddProperty("name", name.ToCString());
8500 jsobj.AddProperty("kind", GetKindAsCString()); 8530 jsobj.AddProperty("kind", GetKindAsCString());
(...skipping 1272 matching lines...) Expand 10 before | Expand all | Expand 10 after
9773 OS::SNPrint(chars, len, kFormat, name.ToCString()); 9803 OS::SNPrint(chars, len, kFormat, name.ToCString());
9774 return chars; 9804 return chars;
9775 } 9805 }
9776 9806
9777 9807
9778 void Library::PrintJSONImpl(JSONStream* stream, bool ref) const { 9808 void Library::PrintJSONImpl(JSONStream* stream, bool ref) const {
9779 const char* library_name = String::Handle(name()).ToCString(); 9809 const char* library_name = String::Handle(name()).ToCString();
9780 intptr_t id = index(); 9810 intptr_t id = index();
9781 ASSERT(id >= 0); 9811 ASSERT(id >= 0);
9782 JSONObject jsobj(stream); 9812 JSONObject jsobj(stream);
9783 jsobj.AddProperty("type", JSONType(ref)); 9813 AddTypeProperties(&jsobj, "Library", JSONType(), ref);
9784 jsobj.AddPropertyF("id", "libraries/%" Pd "", id); 9814 jsobj.AddPropertyF("id", "libraries/%" Pd "", id);
9785 jsobj.AddProperty("name", library_name); 9815 jsobj.AddProperty("name", library_name);
9786 const char* library_url = String::Handle(url()).ToCString(); 9816 const char* library_url = String::Handle(url()).ToCString();
9787 jsobj.AddProperty("url", library_url); 9817 jsobj.AddProperty("url", library_url);
9788 if (ref) { 9818 if (ref) {
9789 return; 9819 return;
9790 } 9820 }
9791 { 9821 {
9792 JSONArray jsarr(&jsobj, "classes"); 9822 JSONArray jsarr(&jsobj, "classes");
9793 ClassDictionaryIterator class_iter(*this); 9823 ClassDictionaryIterator class_iter(*this);
(...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after
10560 KindAsStr(iter.Kind()), 10590 KindAsStr(iter.Kind()),
10561 iter.DeoptId(), 10591 iter.DeoptId(),
10562 iter.TokenPos(), 10592 iter.TokenPos(),
10563 iter.TryIndex()); 10593 iter.TryIndex());
10564 } 10594 }
10565 return buffer; 10595 return buffer;
10566 } 10596 }
10567 10597
10568 10598
10569 void PcDescriptors::PrintToJSONObject(JSONObject* jsobj, bool ref) const { 10599 void PcDescriptors::PrintToJSONObject(JSONObject* jsobj, bool ref) const {
10570 jsobj->AddProperty("type", JSONType(ref)); 10600 AddTypeProperties(jsobj, "Object", JSONType(), ref);
10571 // TODO(johnmccutchan): Generate a stable id. PcDescriptors hang off a Code 10601 // TODO(johnmccutchan): Generate a stable id. PcDescriptors hang off a Code
10572 // object but do not have a back reference to generate an ID. 10602 // object but do not have a back reference to generate an ID.
10573 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); 10603 ObjectIdRing* ring = Isolate::Current()->object_id_ring();
10574 const intptr_t id = ring->GetIdForObject(raw()); 10604 const intptr_t id = ring->GetIdForObject(raw());
10575 jsobj->AddPropertyF("id", "objects/%" Pd "", id); 10605 jsobj->AddPropertyF("id", "objects/%" Pd "", id);
10576 if (ref) { 10606 if (ref) {
10577 return; 10607 return;
10578 } 10608 }
10579 JSONArray members(jsobj, "members"); 10609 JSONArray members(jsobj, "members");
10580 Iterator iter(*this, RawPcDescriptors::kAnyKind); 10610 Iterator iter(*this, RawPcDescriptors::kAnyKind);
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
10859 (len - num_chars), 10889 (len - num_chars),
10860 i, var_name, info); 10890 i, var_name, info);
10861 } 10891 }
10862 return buffer; 10892 return buffer;
10863 } 10893 }
10864 10894
10865 10895
10866 void LocalVarDescriptors::PrintJSONImpl(JSONStream* stream, 10896 void LocalVarDescriptors::PrintJSONImpl(JSONStream* stream,
10867 bool ref) const { 10897 bool ref) const {
10868 JSONObject jsobj(stream); 10898 JSONObject jsobj(stream);
10869 jsobj.AddProperty("type", JSONType(ref)); 10899 AddTypeProperties(&jsobj, "Object", JSONType(), ref);
10870 // TODO(johnmccutchan): Generate a stable id. LocalVarDescriptors hang off 10900 // TODO(johnmccutchan): Generate a stable id. LocalVarDescriptors hang off
10871 // a Code object but do not have a back reference to generate an ID. 10901 // a Code object but do not have a back reference to generate an ID.
10872 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); 10902 ObjectIdRing* ring = Isolate::Current()->object_id_ring();
10873 const intptr_t id = ring->GetIdForObject(raw()); 10903 const intptr_t id = ring->GetIdForObject(raw());
10874 jsobj.AddPropertyF("id", "objects/%" Pd "", id); 10904 jsobj.AddPropertyF("id", "objects/%" Pd "", id);
10875 if (ref) { 10905 if (ref) {
10876 return; 10906 return;
10877 } 10907 }
10878 JSONArray members(&jsobj, "members"); 10908 JSONArray members(&jsobj, "members");
10879 String& var_name = String::Handle(); 10909 String& var_name = String::Handle();
(...skipping 1445 matching lines...) Expand 10 before | Expand all | Expand 10 after
12325 } else { 12355 } else {
12326 ASSERT(obj.IsFunction()); 12356 ASSERT(obj.IsFunction());
12327 // Dart function. 12357 // Dart function.
12328 return Function::Cast(obj).QualifiedPrettyName(); 12358 return Function::Cast(obj).QualifiedPrettyName();
12329 } 12359 }
12330 } 12360 }
12331 12361
12332 12362
12333 void Code::PrintJSONImpl(JSONStream* stream, bool ref) const { 12363 void Code::PrintJSONImpl(JSONStream* stream, bool ref) const {
12334 JSONObject jsobj(stream); 12364 JSONObject jsobj(stream);
12335 jsobj.AddProperty("type", JSONType(ref)); 12365 AddTypeProperties(&jsobj, "Code", JSONType(), ref);
12336 jsobj.AddPropertyF("id", "code/%" Px64"-%" Px "", compile_timestamp(), 12366 jsobj.AddPropertyF("id", "code/%" Px64"-%" Px "", compile_timestamp(),
12337 EntryPoint()); 12367 EntryPoint());
12338 jsobj.AddPropertyF("start", "%" Px "", EntryPoint()); 12368 jsobj.AddPropertyF("start", "%" Px "", EntryPoint());
12339 jsobj.AddPropertyF("end", "%" Px "", EntryPoint() + Size()); 12369 jsobj.AddPropertyF("end", "%" Px "", EntryPoint() + Size());
12340 jsobj.AddProperty("optimized", is_optimized()); 12370 jsobj.AddProperty("optimized", is_optimized());
12341 jsobj.AddProperty("alive", is_alive()); 12371 jsobj.AddProperty("alive", is_alive());
12342 jsobj.AddProperty("kind", "Dart"); 12372 jsobj.AddProperty("kind", "Dart");
12343 const String& user_name = String::Handle(PrettyName()); 12373 const String& user_name = String::Handle(PrettyName());
12344 const String& vm_name = String::Handle(Name()); 12374 const String& vm_name = String::Handle(Name());
12345 AddNameProperties(&jsobj, user_name, vm_name); 12375 AddNameProperties(&jsobj, user_name, vm_name);
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
12488 if (!parent_ctx.IsNull()) { 12518 if (!parent_ctx.IsNull()) {
12489 parent_ctx.Dump(indent + 2); 12519 parent_ctx.Dump(indent + 2);
12490 } 12520 }
12491 IndentN(indent); 12521 IndentN(indent);
12492 OS::PrintErr("}\n"); 12522 OS::PrintErr("}\n");
12493 } 12523 }
12494 12524
12495 12525
12496 void Context::PrintJSONImpl(JSONStream* stream, bool ref) const { 12526 void Context::PrintJSONImpl(JSONStream* stream, bool ref) const {
12497 JSONObject jsobj(stream); 12527 JSONObject jsobj(stream);
12498 jsobj.AddProperty("type", JSONType(ref)); 12528 // TODO(turnidge): Should the user level type for Context be Context
12529 // or Object?
12530 AddTypeProperties(&jsobj, "Context", JSONType(), ref);
12499 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); 12531 ObjectIdRing* ring = Isolate::Current()->object_id_ring();
12500 const intptr_t id = ring->GetIdForObject(raw()); 12532 const intptr_t id = ring->GetIdForObject(raw());
12501 jsobj.AddPropertyF("id", "objects/%" Pd "", id); 12533 jsobj.AddPropertyF("id", "objects/%" Pd "", id);
12502 12534
12503 jsobj.AddProperty("length", num_variables()); 12535 jsobj.AddProperty("length", num_variables());
12504 12536
12505 if (ref) { 12537 if (ref) {
12506 return; 12538 return;
12507 } 12539 }
12508 12540
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
12888 } 12920 }
12889 12921
12890 12922
12891 const char* ApiError::ToCString() const { 12923 const char* ApiError::ToCString() const {
12892 return "ApiError"; 12924 return "ApiError";
12893 } 12925 }
12894 12926
12895 12927
12896 void ApiError::PrintJSONImpl(JSONStream* stream, bool ref) const { 12928 void ApiError::PrintJSONImpl(JSONStream* stream, bool ref) const {
12897 JSONObject jsobj(stream); 12929 JSONObject jsobj(stream);
12898 jsobj.AddProperty("type", "Error"); 12930 AddTypeProperties(&jsobj, "Error", JSONType(), ref);
12899 jsobj.AddProperty("id", ""); 12931 jsobj.AddProperty("id", "");
12900 jsobj.AddProperty("kind", JSONType(false));
12901 jsobj.AddProperty("message", ToErrorCString()); 12932 jsobj.AddProperty("message", ToErrorCString());
12902 } 12933 }
12903 12934
12904 12935
12905 RawLanguageError* LanguageError::New() { 12936 RawLanguageError* LanguageError::New() {
12906 ASSERT(Object::language_error_class() != Class::null()); 12937 ASSERT(Object::language_error_class() != Class::null());
12907 RawObject* raw = Object::Allocate(LanguageError::kClassId, 12938 RawObject* raw = Object::Allocate(LanguageError::kClassId,
12908 LanguageError::InstanceSize(), 12939 LanguageError::InstanceSize(),
12909 Heap::kOld); 12940 Heap::kOld);
12910 return reinterpret_cast<RawLanguageError*>(raw); 12941 return reinterpret_cast<RawLanguageError*>(raw);
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
13027 } 13058 }
13028 13059
13029 13060
13030 const char* LanguageError::ToCString() const { 13061 const char* LanguageError::ToCString() const {
13031 return "LanguageError"; 13062 return "LanguageError";
13032 } 13063 }
13033 13064
13034 13065
13035 void LanguageError::PrintJSONImpl(JSONStream* stream, bool ref) const { 13066 void LanguageError::PrintJSONImpl(JSONStream* stream, bool ref) const {
13036 JSONObject jsobj(stream); 13067 JSONObject jsobj(stream);
13037 jsobj.AddProperty("type", "Error"); 13068 AddTypeProperties(&jsobj, "Error", JSONType(), ref);
13038 jsobj.AddProperty("id", ""); 13069 jsobj.AddProperty("id", "");
13039 jsobj.AddProperty("kind", JSONType(false));
13040 jsobj.AddProperty("message", ToErrorCString()); 13070 jsobj.AddProperty("message", ToErrorCString());
13041 } 13071 }
13042 13072
13043 13073
13044 RawUnhandledException* UnhandledException::New(const Instance& exception, 13074 RawUnhandledException* UnhandledException::New(const Instance& exception,
13045 const Instance& stacktrace, 13075 const Instance& stacktrace,
13046 Heap::Space space) { 13076 Heap::Space space) {
13047 ASSERT(Object::unhandled_exception_class() != Class::null()); 13077 ASSERT(Object::unhandled_exception_class() != Class::null());
13048 UnhandledException& result = UnhandledException::Handle(); 13078 UnhandledException& result = UnhandledException::Handle();
13049 { 13079 {
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
13122 13152
13123 const char* UnhandledException::ToCString() const { 13153 const char* UnhandledException::ToCString() const {
13124 return "UnhandledException"; 13154 return "UnhandledException";
13125 } 13155 }
13126 13156
13127 13157
13128 13158
13129 void UnhandledException::PrintJSONImpl(JSONStream* stream, 13159 void UnhandledException::PrintJSONImpl(JSONStream* stream,
13130 bool ref) const { 13160 bool ref) const {
13131 JSONObject jsobj(stream); 13161 JSONObject jsobj(stream);
13132 jsobj.AddProperty("type", "Error"); 13162 AddTypeProperties(&jsobj, "Error", JSONType(), ref);
13133 jsobj.AddProperty("id", ""); 13163 jsobj.AddProperty("id", "");
13134 jsobj.AddProperty("kind", JSONType(false));
13135 jsobj.AddProperty("message", ToErrorCString()); 13164 jsobj.AddProperty("message", ToErrorCString());
13136 13165
13137 Instance& instance = Instance::Handle(); 13166 Instance& instance = Instance::Handle();
13138 instance = exception(); 13167 instance = exception();
13139 jsobj.AddProperty("exception", instance); 13168 jsobj.AddProperty("exception", instance);
13140 instance = stacktrace(); 13169 instance = stacktrace();
13141 jsobj.AddProperty("stacktrace", instance); 13170 jsobj.AddProperty("stacktrace", instance);
13142 } 13171 }
13143 13172
13144 13173
(...skipping 23 matching lines...) Expand all
13168 } 13197 }
13169 13198
13170 13199
13171 const char* UnwindError::ToCString() const { 13200 const char* UnwindError::ToCString() const {
13172 return "UnwindError"; 13201 return "UnwindError";
13173 } 13202 }
13174 13203
13175 13204
13176 void UnwindError::PrintJSONImpl(JSONStream* stream, bool ref) const { 13205 void UnwindError::PrintJSONImpl(JSONStream* stream, bool ref) const {
13177 JSONObject jsobj(stream); 13206 JSONObject jsobj(stream);
13178 jsobj.AddProperty("type", "Error"); 13207 AddTypeProperties(&jsobj, "Error", JSONType(), ref);
13179 jsobj.AddProperty("id", ""); 13208 jsobj.AddProperty("id", "");
13180 jsobj.AddProperty("kind", JSONType(false));
13181 jsobj.AddProperty("message", ToErrorCString()); 13209 jsobj.AddProperty("message", ToErrorCString());
13182 } 13210 }
13183 13211
13184 13212
13185 RawObject* Instance::Evaluate(const String& expr, 13213 RawObject* Instance::Evaluate(const String& expr,
13186 const Array& param_names, 13214 const Array& param_names,
13187 const Array& param_values) const { 13215 const Array& param_values) const {
13188 const Class& cls = Class::Handle(clazz()); 13216 const Class& cls = Class::Handle(clazz());
13189 const Function& eval_func = 13217 const Function& eval_func =
13190 Function::Handle(EvaluateHelper(cls, expr, param_names, false)); 13218 Function::Handle(EvaluateHelper(cls, expr, param_names, false));
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
13613 const String& type_name = String::Handle(type.UserVisibleName()); 13641 const String& type_name = String::Handle(type.UserVisibleName());
13614 // Calculate the size of the string. 13642 // Calculate the size of the string.
13615 intptr_t len = OS::SNPrint(NULL, 0, kFormat, type_name.ToCString()) + 1; 13643 intptr_t len = OS::SNPrint(NULL, 0, kFormat, type_name.ToCString()) + 1;
13616 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); 13644 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
13617 OS::SNPrint(chars, len, kFormat, type_name.ToCString()); 13645 OS::SNPrint(chars, len, kFormat, type_name.ToCString());
13618 return chars; 13646 return chars;
13619 } 13647 }
13620 } 13648 }
13621 13649
13622 13650
13623 void Instance::PrintSharedInstanceJSON(JSONObject* jsobj, bool ref) const { 13651 void Instance::PrintSharedInstanceJSON(JSONObject* jsobj,
13624 jsobj->AddProperty("type", JSONType(ref)); 13652 bool ref) const {
13625 Class& cls = Class::Handle(this->clazz()); 13653 Class& cls = Class::Handle(this->clazz());
13626 jsobj->AddProperty("class", cls); 13654 jsobj->AddProperty("class", cls);
13627 // TODO(turnidge): Provide the type arguments here too. 13655 // TODO(turnidge): Provide the type arguments here too.
13628 if (ref) { 13656 if (ref) {
13629 return; 13657 return;
13630 } 13658 }
13631 13659
13632 if (raw()->IsHeapObject()) { 13660 if (raw()->IsHeapObject()) {
13633 jsobj->AddProperty("size", raw()->Size()); 13661 jsobj->AddProperty("size", raw()->Size());
13634 } 13662 }
(...skipping 25 matching lines...) Expand all
13660 for (intptr_t i = 0; i < NumNativeFields(); i++) { 13688 for (intptr_t i = 0; i < NumNativeFields(); i++) {
13661 intptr_t value = GetNativeField(i); 13689 intptr_t value = GetNativeField(i);
13662 JSONObject jsfield(&jsarr); 13690 JSONObject jsfield(&jsarr);
13663 jsfield.AddProperty("index", i); 13691 jsfield.AddProperty("index", i);
13664 jsfield.AddProperty("value", value); 13692 jsfield.AddProperty("value", value);
13665 } 13693 }
13666 } 13694 }
13667 } 13695 }
13668 13696
13669 13697
13670 void Object::PrintJSONImpl(JSONStream* stream, bool ref) const {
13671 JSONObject jsobj(stream);
13672 jsobj.AddProperty("type", JSONType(ref));
13673 ObjectIdRing* ring = Isolate::Current()->object_id_ring();
13674 const intptr_t id = ring->GetIdForObject(raw());
13675 jsobj.AddPropertyF("id", "objects/%" Pd "", id);
13676 }
13677
13678
13679 void Instance::PrintJSONImpl(JSONStream* stream, bool ref) const { 13698 void Instance::PrintJSONImpl(JSONStream* stream, bool ref) const {
13680 JSONObject jsobj(stream); 13699 JSONObject jsobj(stream);
13681 13700
13682 // Handle certain special instance values. 13701 // Handle certain special instance values.
13683 if (raw() == Object::sentinel().raw()) { 13702 if (raw() == Object::sentinel().raw()) {
13684 jsobj.AddProperty("type", "Sentinel"); 13703 jsobj.AddProperty("type", "Sentinel");
13685 jsobj.AddProperty("id", "objects/not-initialized"); 13704 jsobj.AddProperty("id", "objects/not-initialized");
13686 jsobj.AddProperty("valueAsString", "<not initialized>"); 13705 jsobj.AddProperty("valueAsString", "<not initialized>");
13687 return; 13706 return;
13688 } else if (raw() == Object::transition_sentinel().raw()) { 13707 } else if (raw() == Object::transition_sentinel().raw()) {
13689 jsobj.AddProperty("type", "Sentinel"); 13708 jsobj.AddProperty("type", "Sentinel");
13690 jsobj.AddProperty("id", "objects/being-initialized"); 13709 jsobj.AddProperty("id", "objects/being-initialized");
13691 jsobj.AddProperty("valueAsString", "<being initialized>"); 13710 jsobj.AddProperty("valueAsString", "<being initialized>");
13692 return; 13711 return;
13693 } 13712 }
13694 13713
13714 AddTypeProperties(&jsobj, "Instance", JSONType(), ref);
13695 PrintSharedInstanceJSON(&jsobj, ref); 13715 PrintSharedInstanceJSON(&jsobj, ref);
13696 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); 13716 ObjectIdRing* ring = Isolate::Current()->object_id_ring();
13697 const intptr_t id = ring->GetIdForObject(raw()); 13717 const intptr_t id = ring->GetIdForObject(raw());
13698 if (IsClosure()) { 13718 if (IsClosure()) {
13699 const Function& closureFunc = Function::Handle(Closure::function(*this)); 13719 const Function& closureFunc = Function::Handle(Closure::function(*this));
13700 jsobj.AddProperty("closureFunc", closureFunc); 13720 jsobj.AddProperty("closureFunc", closureFunc);
13701 const Context& closureCtxt = Context::Handle(Closure::context(*this)); 13721 const Context& closureCtxt = Context::Handle(Closure::context(*this));
13702 jsobj.AddProperty("closureCtxt", closureCtxt); 13722 jsobj.AddProperty("closureCtxt", closureCtxt);
13703 } 13723 }
13704 jsobj.AddPropertyF("id", "objects/%" Pd "", id); 13724 jsobj.AddPropertyF("id", "objects/%" Pd "", id);
(...skipping 1047 matching lines...) Expand 10 before | Expand all | Expand 10 after
14752 return chars; 14772 return chars;
14753 } 14773 }
14754 } else { 14774 } else {
14755 return "Unresolved Type"; 14775 return "Unresolved Type";
14756 } 14776 }
14757 } 14777 }
14758 14778
14759 14779
14760 void Type::PrintJSONImpl(JSONStream* stream, bool ref) const { 14780 void Type::PrintJSONImpl(JSONStream* stream, bool ref) const {
14761 JSONObject jsobj(stream); 14781 JSONObject jsobj(stream);
14782 AddTypeProperties(&jsobj, "Type", JSONType(), ref);
14762 PrintSharedInstanceJSON(&jsobj, ref); 14783 PrintSharedInstanceJSON(&jsobj, ref);
14763 if (IsCanonical()) { 14784 if (IsCanonical()) {
14764 const Class& type_cls = Class::Handle(type_class()); 14785 const Class& type_cls = Class::Handle(type_class());
14765 intptr_t id = type_cls.FindCanonicalTypeIndex(*this); 14786 intptr_t id = type_cls.FindCanonicalTypeIndex(*this);
14766 ASSERT(id >= 0); 14787 ASSERT(id >= 0);
14767 intptr_t cid = type_cls.id(); 14788 intptr_t cid = type_cls.id();
14768 jsobj.AddPropertyF("id", "classes/%" Pd "/types/%" Pd "", cid, id); 14789 jsobj.AddPropertyF("id", "classes/%" Pd "/types/%" Pd "", cid, id);
14769 jsobj.AddProperty("typeClass", type_cls); 14790 jsobj.AddProperty("typeClass", type_cls);
14770 } else { 14791 } else {
14771 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); 14792 ObjectIdRing* ring = Isolate::Current()->object_id_ring();
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
14924 const intptr_t len = OS::SNPrint(NULL, 0, format, type_cstr) + 1; 14945 const intptr_t len = OS::SNPrint(NULL, 0, format, type_cstr) + 1;
14925 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); 14946 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
14926 OS::SNPrint(chars, len, format, type_cstr); 14947 OS::SNPrint(chars, len, format, type_cstr);
14927 return chars; 14948 return chars;
14928 } 14949 }
14929 } 14950 }
14930 14951
14931 14952
14932 void TypeRef::PrintJSONImpl(JSONStream* stream, bool ref) const { 14953 void TypeRef::PrintJSONImpl(JSONStream* stream, bool ref) const {
14933 JSONObject jsobj(stream); 14954 JSONObject jsobj(stream);
14955 AddTypeProperties(&jsobj, "TypeRef", JSONType(), ref);
14934 PrintSharedInstanceJSON(&jsobj, ref); 14956 PrintSharedInstanceJSON(&jsobj, ref);
14935 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); 14957 ObjectIdRing* ring = Isolate::Current()->object_id_ring();
14936 const intptr_t id = ring->GetIdForObject(raw()); 14958 const intptr_t id = ring->GetIdForObject(raw());
14937 jsobj.AddPropertyF("id", "objects/%" Pd "", id); 14959 jsobj.AddPropertyF("id", "objects/%" Pd "", id);
14938 const String& user_name = String::Handle(PrettyName()); 14960 const String& user_name = String::Handle(PrettyName());
14939 const String& vm_name = String::Handle(Name()); 14961 const String& vm_name = String::Handle(Name());
14940 AddNameProperties(&jsobj, user_name, vm_name); 14962 AddNameProperties(&jsobj, user_name, vm_name);
14941 if (ref) { 14963 if (ref) {
14942 return; 14964 return;
14943 } 14965 }
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
15140 intptr_t len = OS::SNPrint( 15162 intptr_t len = OS::SNPrint(
15141 NULL, 0, format, name_cstr, index(), cls_cstr, bound_cstr) + 1; 15163 NULL, 0, format, name_cstr, index(), cls_cstr, bound_cstr) + 1;
15142 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); 15164 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
15143 OS::SNPrint(chars, len, format, name_cstr, index(), cls_cstr, bound_cstr); 15165 OS::SNPrint(chars, len, format, name_cstr, index(), cls_cstr, bound_cstr);
15144 return chars; 15166 return chars;
15145 } 15167 }
15146 15168
15147 15169
15148 void TypeParameter::PrintJSONImpl(JSONStream* stream, bool ref) const { 15170 void TypeParameter::PrintJSONImpl(JSONStream* stream, bool ref) const {
15149 JSONObject jsobj(stream); 15171 JSONObject jsobj(stream);
15172 AddTypeProperties(&jsobj, "TypeParameter", JSONType(), ref);
15150 PrintSharedInstanceJSON(&jsobj, ref); 15173 PrintSharedInstanceJSON(&jsobj, ref);
15151 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); 15174 ObjectIdRing* ring = Isolate::Current()->object_id_ring();
15152 const intptr_t id = ring->GetIdForObject(raw()); 15175 const intptr_t id = ring->GetIdForObject(raw());
15153 jsobj.AddPropertyF("id", "objects/%" Pd "", id); 15176 jsobj.AddPropertyF("id", "objects/%" Pd "", id);
15154 const String& user_name = String::Handle(PrettyName()); 15177 const String& user_name = String::Handle(PrettyName());
15155 const String& vm_name = String::Handle(Name()); 15178 const String& vm_name = String::Handle(Name());
15156 AddNameProperties(&jsobj, user_name, vm_name); 15179 AddNameProperties(&jsobj, user_name, vm_name);
15157 const Class& param_cls = Class::Handle(parameterized_class()); 15180 const Class& param_cls = Class::Handle(parameterized_class());
15158 jsobj.AddProperty("parameterizedClass", param_cls); 15181 jsobj.AddProperty("parameterizedClass", param_cls);
15159 if (ref) { 15182 if (ref) {
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
15343 NULL, 0, format, type_cstr, bound_cstr, type_param_cstr, cls_cstr) + 1; 15366 NULL, 0, format, type_cstr, bound_cstr, type_param_cstr, cls_cstr) + 1;
15344 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); 15367 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
15345 OS::SNPrint( 15368 OS::SNPrint(
15346 chars, len, format, type_cstr, bound_cstr, type_param_cstr, cls_cstr); 15369 chars, len, format, type_cstr, bound_cstr, type_param_cstr, cls_cstr);
15347 return chars; 15370 return chars;
15348 } 15371 }
15349 15372
15350 15373
15351 void BoundedType::PrintJSONImpl(JSONStream* stream, bool ref) const { 15374 void BoundedType::PrintJSONImpl(JSONStream* stream, bool ref) const {
15352 JSONObject jsobj(stream); 15375 JSONObject jsobj(stream);
15376 AddTypeProperties(&jsobj, "BoundedType", JSONType(), ref);
15353 PrintSharedInstanceJSON(&jsobj, ref); 15377 PrintSharedInstanceJSON(&jsobj, ref);
15354 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); 15378 ObjectIdRing* ring = Isolate::Current()->object_id_ring();
15355 const intptr_t id = ring->GetIdForObject(raw()); 15379 const intptr_t id = ring->GetIdForObject(raw());
15356 jsobj.AddPropertyF("id", "objects/%" Pd "", id); 15380 jsobj.AddPropertyF("id", "objects/%" Pd "", id);
15357 const String& user_name = String::Handle(PrettyName()); 15381 const String& user_name = String::Handle(PrettyName());
15358 const String& vm_name = String::Handle(Name()); 15382 const String& vm_name = String::Handle(Name());
15359 AddNameProperties(&jsobj, user_name, vm_name); 15383 AddNameProperties(&jsobj, user_name, vm_name);
15360 if (ref) { 15384 if (ref) {
15361 return; 15385 return;
15362 } 15386 }
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
15436 15460
15437 15461
15438 const char* Number::ToCString() const { 15462 const char* Number::ToCString() const {
15439 // Number is an interface. No instances of Number should exist. 15463 // Number is an interface. No instances of Number should exist.
15440 UNREACHABLE(); 15464 UNREACHABLE();
15441 return "Number"; 15465 return "Number";
15442 } 15466 }
15443 15467
15444 15468
15445 void Number::PrintJSONImpl(JSONStream* stream, bool ref) const { 15469 void Number::PrintJSONImpl(JSONStream* stream, bool ref) const {
15446 JSONObject jsobj(stream); 15470 UNREACHABLE();
15447 PrintSharedInstanceJSON(&jsobj, ref);
15448 ObjectIdRing* ring = Isolate::Current()->object_id_ring();
15449 const intptr_t id = ring->GetIdForObject(raw());
15450 jsobj.AddPropertyF("id", "objects/%" Pd "", id);
15451 jsobj.AddProperty("valueAsString", ToCString());
15452 } 15471 }
15453 15472
15454 15473
15455 const char* Integer::ToCString() const { 15474 const char* Integer::ToCString() const {
15456 // Integer is an interface. No instances of Integer should exist. 15475 // Integer is an interface. No instances of Integer should exist.
15457 UNREACHABLE(); 15476 UNREACHABLE();
15458 return "Integer"; 15477 return "Integer";
15459 } 15478 }
15460 15479
15461 15480
15462 void Integer::PrintJSONImpl(JSONStream* stream, bool ref) const { 15481 void Integer::PrintJSONImpl(JSONStream* stream, bool ref) const {
15463 Number::PrintJSONImpl(stream, ref); 15482 JSONObject jsobj(stream);
15483 AddTypeProperties(&jsobj, "int", JSONType(), ref);
15484 PrintSharedInstanceJSON(&jsobj, ref);
15485 ObjectIdRing* ring = Isolate::Current()->object_id_ring();
15486 const intptr_t id = ring->GetIdForObject(raw());
15487 jsobj.AddPropertyF("id", "objects/%" Pd "", id);
15488 jsobj.AddProperty("valueAsString", ToCString());
15464 } 15489 }
15465 15490
15466 15491
15467 // Throw JavascriptIntegerOverflow exception. 15492 // Throw JavascriptIntegerOverflow exception.
15468 static void ThrowJavascriptIntegerOverflow(const Integer& i) { 15493 static void ThrowJavascriptIntegerOverflow(const Integer& i) {
15469 const Array& exc_args = Array::Handle(Array::New(1)); 15494 const Array& exc_args = Array::Handle(Array::New(1));
15470 const String& i_str = String::Handle(String::New(i.ToCString())); 15495 const String& i_str = String::Handle(String::New(i.ToCString()));
15471 exc_args.SetAt(0, i_str); 15496 exc_args.SetAt(0, i_str);
15472 Exceptions::ThrowByType(Exceptions::kJavascriptIntegerOverflowError, 15497 Exceptions::ThrowByType(Exceptions::kJavascriptIntegerOverflowError,
15473 exc_args); 15498 exc_args);
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
15886 // Calculate the size of the string. 15911 // Calculate the size of the string.
15887 intptr_t len = OS::SNPrint(NULL, 0, kFormat, Value()) + 1; 15912 intptr_t len = OS::SNPrint(NULL, 0, kFormat, Value()) + 1;
15888 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); 15913 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
15889 OS::SNPrint(chars, len, kFormat, Value()); 15914 OS::SNPrint(chars, len, kFormat, Value());
15890 return chars; 15915 return chars;
15891 } 15916 }
15892 15917
15893 15918
15894 void Smi::PrintJSONImpl(JSONStream* stream, bool ref) const { 15919 void Smi::PrintJSONImpl(JSONStream* stream, bool ref) const {
15895 JSONObject jsobj(stream); 15920 JSONObject jsobj(stream);
15921 AddTypeProperties(&jsobj, "int", JSONType(), ref);
15896 PrintSharedInstanceJSON(&jsobj, ref); 15922 PrintSharedInstanceJSON(&jsobj, ref);
15897 jsobj.AddPropertyF("id", "objects/int-%" Pd "", Value()); 15923 jsobj.AddPropertyF("id", "objects/int-%" Pd "", Value());
15898 jsobj.AddPropertyF("valueAsString", "%" Pd "", Value()); 15924 jsobj.AddPropertyF("valueAsString", "%" Pd "", Value());
15899 } 15925 }
15900 15926
15901 15927
15902 RawClass* Smi::Class() { 15928 RawClass* Smi::Class() {
15903 return Isolate::Current()->object_store()->smi_class(); 15929 return Isolate::Current()->object_store()->smi_class();
15904 } 15930 }
15905 15931
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
16012 const char* kFormat = "%lld"; 16038 const char* kFormat = "%lld";
16013 // Calculate the size of the string. 16039 // Calculate the size of the string.
16014 intptr_t len = OS::SNPrint(NULL, 0, kFormat, value()) + 1; 16040 intptr_t len = OS::SNPrint(NULL, 0, kFormat, value()) + 1;
16015 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); 16041 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
16016 OS::SNPrint(chars, len, kFormat, value()); 16042 OS::SNPrint(chars, len, kFormat, value());
16017 return chars; 16043 return chars;
16018 } 16044 }
16019 16045
16020 16046
16021 void Mint::PrintJSONImpl(JSONStream* stream, bool ref) const { 16047 void Mint::PrintJSONImpl(JSONStream* stream, bool ref) const {
16022 Number::PrintJSONImpl(stream, ref); 16048 Integer::PrintJSONImpl(stream, ref);
16023 } 16049 }
16024 16050
16025 16051
16026 void Double::set_value(double value) const { 16052 void Double::set_value(double value) const {
16027 raw_ptr()->value_ = value; 16053 raw_ptr()->value_ = value;
16028 } 16054 }
16029 16055
16030 16056
16031 bool Double::BitwiseEqualsToDouble(double value) const { 16057 bool Double::BitwiseEqualsToDouble(double value) const {
16032 intptr_t value_offset = Double::value_offset(); 16058 intptr_t value_offset = Double::value_offset();
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
16144 } 16170 }
16145 const int kBufferSize = 128; 16171 const int kBufferSize = 128;
16146 char* buffer = Isolate::Current()->current_zone()->Alloc<char>(kBufferSize); 16172 char* buffer = Isolate::Current()->current_zone()->Alloc<char>(kBufferSize);
16147 buffer[kBufferSize - 1] = '\0'; 16173 buffer[kBufferSize - 1] = '\0';
16148 DoubleToCString(value(), buffer, kBufferSize); 16174 DoubleToCString(value(), buffer, kBufferSize);
16149 return buffer; 16175 return buffer;
16150 } 16176 }
16151 16177
16152 16178
16153 void Double::PrintJSONImpl(JSONStream* stream, bool ref) const { 16179 void Double::PrintJSONImpl(JSONStream* stream, bool ref) const {
16154 Number::PrintJSONImpl(stream, ref); 16180 JSONObject jsobj(stream);
16181 // Suppress the fact that the internal vm name for this type is
16182 // "Double". Return "double" instead.
16183 AddTypeProperties(&jsobj, "double", "double", ref);
16184 PrintSharedInstanceJSON(&jsobj, ref);
16185 ObjectIdRing* ring = Isolate::Current()->object_id_ring();
16186 const intptr_t id = ring->GetIdForObject(raw());
16187 jsobj.AddPropertyF("id", "objects/%" Pd "", id);
16188 jsobj.AddProperty("valueAsString", ToCString());
16155 } 16189 }
16156 16190
16157 16191
16158 RawBigint* Integer::AsBigint() const { 16192 RawBigint* Integer::AsBigint() const {
16159 ASSERT(!IsNull()); 16193 ASSERT(!IsNull());
16160 if (IsSmi()) { 16194 if (IsSmi()) {
16161 Smi& smi = Smi::Handle(); 16195 Smi& smi = Smi::Handle();
16162 smi ^= raw(); 16196 smi ^= raw();
16163 return BigintOperations::NewFromSmi(smi); 16197 return BigintOperations::NewFromSmi(smi);
16164 } else if (IsMint()) { 16198 } else if (IsMint()) {
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
16320 return zone->AllocUnsafe(size); 16354 return zone->AllocUnsafe(size);
16321 } 16355 }
16322 16356
16323 16357
16324 const char* Bigint::ToCString() const { 16358 const char* Bigint::ToCString() const {
16325 return BigintOperations::ToDecimalCString(*this, &BigintAllocator); 16359 return BigintOperations::ToDecimalCString(*this, &BigintAllocator);
16326 } 16360 }
16327 16361
16328 16362
16329 void Bigint::PrintJSONImpl(JSONStream* stream, bool ref) const { 16363 void Bigint::PrintJSONImpl(JSONStream* stream, bool ref) const {
16330 Number::PrintJSONImpl(stream, ref); 16364 Integer::PrintJSONImpl(stream, ref);
16331 } 16365 }
16332 16366
16333 16367
16334 // Synchronize with implementation in compiler (intrinsifier). 16368 // Synchronize with implementation in compiler (intrinsifier).
16335 class StringHasher : ValueObject { 16369 class StringHasher : ValueObject {
16336 public: 16370 public:
16337 StringHasher() : hash_(0) {} 16371 StringHasher() : hash_(0) {}
16338 void Add(int32_t ch) { 16372 void Add(int32_t ch) {
16339 hash_ = CombineHashes(hash_, ch); 16373 hash_ = CombineHashes(hash_, ch);
16340 } 16374 }
(...skipping 894 matching lines...) Expand 10 before | Expand all | Expand 10 after
17235 JSONObject jsobj(stream); 17269 JSONObject jsobj(stream);
17236 if (raw() == Symbols::OptimizedOut().raw()) { 17270 if (raw() == Symbols::OptimizedOut().raw()) {
17237 // TODO(turnidge): This is a hack. The user could have this 17271 // TODO(turnidge): This is a hack. The user could have this
17238 // special string in their program. Fixing this involves updating 17272 // special string in their program. Fixing this involves updating
17239 // the debugging api a bit. 17273 // the debugging api a bit.
17240 jsobj.AddProperty("type", "Sentinel"); 17274 jsobj.AddProperty("type", "Sentinel");
17241 jsobj.AddProperty("id", "objects/optimized-out"); 17275 jsobj.AddProperty("id", "objects/optimized-out");
17242 jsobj.AddProperty("valueAsString", "<optimized out>"); 17276 jsobj.AddProperty("valueAsString", "<optimized out>");
17243 return; 17277 return;
17244 } 17278 }
17279 AddTypeProperties(&jsobj, "String", JSONType(), ref);
17245 PrintSharedInstanceJSON(&jsobj, ref); 17280 PrintSharedInstanceJSON(&jsobj, ref);
17246 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); 17281 ObjectIdRing* ring = Isolate::Current()->object_id_ring();
17247 const intptr_t id = ring->GetIdForObject(raw()); 17282 const intptr_t id = ring->GetIdForObject(raw());
17248 jsobj.AddPropertyF("id", "objects/%" Pd "", id); 17283 jsobj.AddPropertyF("id", "objects/%" Pd "", id);
17249 jsobj.AddProperty("valueAsString", ToUserCString(1024)); 17284 jsobj.AddProperty("valueAsString", ToUserCString(1024));
17250 } 17285 }
17251 17286
17252 17287
17253 void String::ToUTF8(uint8_t* utf8_array, intptr_t array_len) const { 17288 void String::ToUTF8(uint8_t* utf8_array, intptr_t array_len) const {
17254 ASSERT(array_len >= Utf8::Length(*this)); 17289 ASSERT(array_len >= Utf8::Length(*this));
(...skipping 849 matching lines...) Expand 10 before | Expand all | Expand 10 after
18104 18139
18105 18140
18106 const char* Bool::ToCString() const { 18141 const char* Bool::ToCString() const {
18107 return value() ? "true" : "false"; 18142 return value() ? "true" : "false";
18108 } 18143 }
18109 18144
18110 18145
18111 void Bool::PrintJSONImpl(JSONStream* stream, bool ref) const { 18146 void Bool::PrintJSONImpl(JSONStream* stream, bool ref) const {
18112 const char* str = ToCString(); 18147 const char* str = ToCString();
18113 JSONObject jsobj(stream); 18148 JSONObject jsobj(stream);
18114 jsobj.AddProperty("type", JSONType(ref)); 18149 // Suppress the fact that the internal vm name for this type is
18150 // "Bool". Return "bool" instead.
18151 AddTypeProperties(&jsobj, "bool", "bool", ref);
18152 PrintSharedInstanceJSON(&jsobj, ref);
18115 jsobj.AddPropertyF("id", "objects/bool-%s", str); 18153 jsobj.AddPropertyF("id", "objects/bool-%s", str);
18116 const Class& cls = Class::Handle(this->clazz());
18117 jsobj.AddProperty("class", cls);
18118 jsobj.AddPropertyF("valueAsString", "%s", str); 18154 jsobj.AddPropertyF("valueAsString", "%s", str);
18119 } 18155 }
18120 18156
18121 18157
18122 bool Array::CanonicalizeEquals(const Instance& other) const { 18158 bool Array::CanonicalizeEquals(const Instance& other) const {
18123 if (this->raw() == other.raw()) { 18159 if (this->raw() == other.raw()) {
18124 // Both handles point to the same raw instance. 18160 // Both handles point to the same raw instance.
18125 return true; 18161 return true;
18126 } 18162 }
18127 18163
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
18225 "_ImmutableList len:%" Pd : "_List len:%" Pd; 18261 "_ImmutableList len:%" Pd : "_List len:%" Pd;
18226 intptr_t len = OS::SNPrint(NULL, 0, format, Length()) + 1; 18262 intptr_t len = OS::SNPrint(NULL, 0, format, Length()) + 1;
18227 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); 18263 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
18228 OS::SNPrint(chars, len, format, Length()); 18264 OS::SNPrint(chars, len, format, Length());
18229 return chars; 18265 return chars;
18230 } 18266 }
18231 18267
18232 18268
18233 void Array::PrintJSONImpl(JSONStream* stream, bool ref) const { 18269 void Array::PrintJSONImpl(JSONStream* stream, bool ref) const {
18234 JSONObject jsobj(stream); 18270 JSONObject jsobj(stream);
18271 AddTypeProperties(&jsobj, "List", JSONType(), ref);
18235 PrintSharedInstanceJSON(&jsobj, ref); 18272 PrintSharedInstanceJSON(&jsobj, ref);
18236 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); 18273 ObjectIdRing* ring = Isolate::Current()->object_id_ring();
18237 const intptr_t id = ring->GetIdForObject(raw()); 18274 const intptr_t id = ring->GetIdForObject(raw());
18238 jsobj.AddPropertyF("id", "objects/%" Pd "", id); 18275 jsobj.AddPropertyF("id", "objects/%" Pd "", id);
18239 jsobj.AddProperty("length", Length()); 18276 jsobj.AddProperty("length", Length());
18240 if (ref) { 18277 if (ref) {
18241 return; 18278 return;
18242 } 18279 }
18243 { 18280 {
18244 JSONArray jsarr(&jsobj, "elements"); 18281 JSONArray jsarr(&jsobj, "elements");
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
18469 intptr_t len = OS::SNPrint(NULL, 0, format, Length()) + 1; 18506 intptr_t len = OS::SNPrint(NULL, 0, format, Length()) + 1;
18470 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); 18507 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
18471 OS::SNPrint(chars, len, format, Length()); 18508 OS::SNPrint(chars, len, format, Length());
18472 return chars; 18509 return chars;
18473 } 18510 }
18474 18511
18475 18512
18476 void GrowableObjectArray::PrintJSONImpl(JSONStream* stream, 18513 void GrowableObjectArray::PrintJSONImpl(JSONStream* stream,
18477 bool ref) const { 18514 bool ref) const {
18478 JSONObject jsobj(stream); 18515 JSONObject jsobj(stream);
18516 AddTypeProperties(&jsobj, "List", JSONType(), ref);
18479 PrintSharedInstanceJSON(&jsobj, ref); 18517 PrintSharedInstanceJSON(&jsobj, ref);
18480 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); 18518 ObjectIdRing* ring = Isolate::Current()->object_id_ring();
18481 const intptr_t id = ring->GetIdForObject(raw()); 18519 const intptr_t id = ring->GetIdForObject(raw());
18482 jsobj.AddPropertyF("id", "objects/%" Pd "", id); 18520 jsobj.AddPropertyF("id", "objects/%" Pd "", id);
18483 jsobj.AddProperty("length", Length()); 18521 jsobj.AddProperty("length", Length());
18484 if (ref) { 18522 if (ref) {
18485 return; 18523 return;
18486 } 18524 }
18487 { 18525 {
18488 JSONArray jsarr(&jsobj, "elements"); 18526 JSONArray jsarr(&jsobj, "elements");
(...skipping 1039 matching lines...) Expand 10 before | Expand all | Expand 10 after
19528 } 19566 }
19529 19567
19530 19568
19531 const char* WeakProperty::ToCString() const { 19569 const char* WeakProperty::ToCString() const {
19532 return "_WeakProperty"; 19570 return "_WeakProperty";
19533 } 19571 }
19534 19572
19535 19573
19536 void WeakProperty::PrintJSONImpl(JSONStream* stream, bool ref) const { 19574 void WeakProperty::PrintJSONImpl(JSONStream* stream, bool ref) const {
19537 JSONObject jsobj(stream); 19575 JSONObject jsobj(stream);
19576 AddTypeProperties(&jsobj, "Instance", JSONType(), ref);
19538 PrintSharedInstanceJSON(&jsobj, ref); 19577 PrintSharedInstanceJSON(&jsobj, ref);
19539 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); 19578 ObjectIdRing* ring = Isolate::Current()->object_id_ring();
19540 const intptr_t id = ring->GetIdForObject(raw()); 19579 const intptr_t id = ring->GetIdForObject(raw());
19541 jsobj.AddPropertyF("id", "objects/%" Pd "", id); 19580 jsobj.AddPropertyF("id", "objects/%" Pd "", id);
19542 19581
19543 if (ref) { 19582 if (ref) {
19544 return; 19583 return;
19545 } 19584 }
19546 19585
19547 const Object& key_handle = Object::Handle(key()); 19586 const Object& key_handle = Object::Handle(key());
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
19601 } 19640 }
19602 19641
19603 19642
19604 const char* MirrorReference::ToCString() const { 19643 const char* MirrorReference::ToCString() const {
19605 return "_MirrorReference"; 19644 return "_MirrorReference";
19606 } 19645 }
19607 19646
19608 19647
19609 void MirrorReference::PrintJSONImpl(JSONStream* stream, bool ref) const { 19648 void MirrorReference::PrintJSONImpl(JSONStream* stream, bool ref) const {
19610 JSONObject jsobj(stream); 19649 JSONObject jsobj(stream);
19650 AddTypeProperties(&jsobj, "Instance", JSONType(), ref);
19611 PrintSharedInstanceJSON(&jsobj, ref); 19651 PrintSharedInstanceJSON(&jsobj, ref);
19612 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); 19652 ObjectIdRing* ring = Isolate::Current()->object_id_ring();
19613 const intptr_t id = ring->GetIdForObject(raw()); 19653 const intptr_t id = ring->GetIdForObject(raw());
19614 jsobj.AddPropertyF("id", "objects/%" Pd "", id); 19654 jsobj.AddPropertyF("id", "objects/%" Pd "", id);
19615 19655
19616 if (ref) { 19656 if (ref) {
19617 return; 19657 return;
19618 } 19658 }
19619 19659
19620 const Object& referent_handle = Object::Handle(referent()); 19660 const Object& referent_handle = Object::Handle(referent());
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
19750 return tag_label.ToCString(); 19790 return tag_label.ToCString();
19751 } 19791 }
19752 19792
19753 19793
19754 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { 19794 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const {
19755 Instance::PrintJSONImpl(stream, ref); 19795 Instance::PrintJSONImpl(stream, ref);
19756 } 19796 }
19757 19797
19758 19798
19759 } // namespace dart 19799 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/object_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698