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

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: code review 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
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 jsobj.AddProperty("type", "Null");
4120 return; 4148 return;
4121 } 4149 }
4122 jsobj.AddProperty("type", JSONType(ref)); 4150 AddTypeProperties(&jsobj, "Class", JSONType(), ref);
4123 jsobj.AddPropertyF("id", "classes/%" Pd "", id()); 4151 jsobj.AddPropertyF("id", "classes/%" Pd "", id());
4124 const String& user_name = String::Handle(PrettyName()); 4152 const String& user_name = String::Handle(PrettyName());
4125 const String& vm_name = String::Handle(Name()); 4153 const String& vm_name = String::Handle(Name());
4126 AddNameProperties(&jsobj, user_name, vm_name); 4154 AddNameProperties(&jsobj, user_name, vm_name);
4127 if (ref) { 4155 if (ref) {
4128 return; 4156 return;
4129 } 4157 }
4130 4158
4131 const Error& err = Error::Handle(EnsureIsFinalized(Isolate::Current())); 4159 const Error& err = Error::Handle(EnsureIsFinalized(Isolate::Current()));
4132 if (!err.IsNull()) { 4160 if (!err.IsNull()) {
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
4450 JSONObject jsobj(stream); 4478 JSONObject jsobj(stream);
4451 // The index in the canonical_type_arguments table cannot be used as part of 4479 // 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 4480 // 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. 4481 // preserved when the table grows and the entries get rehashed. Use the ring.
4454 Isolate* isolate = Isolate::Current(); 4482 Isolate* isolate = Isolate::Current();
4455 ObjectStore* object_store = isolate->object_store(); 4483 ObjectStore* object_store = isolate->object_store();
4456 const Array& table = Array::Handle(object_store->canonical_type_arguments()); 4484 const Array& table = Array::Handle(object_store->canonical_type_arguments());
4457 ASSERT(table.Length() > 0); 4485 ASSERT(table.Length() > 0);
4458 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); 4486 ObjectIdRing* ring = Isolate::Current()->object_id_ring();
4459 const intptr_t id = ring->GetIdForObject(raw()); 4487 const intptr_t id = ring->GetIdForObject(raw());
4460 jsobj.AddProperty("type", JSONType(ref)); 4488 AddTypeProperties(&jsobj, "TypeArguments", JSONType(), ref);
4461 jsobj.AddPropertyF("id", "objects/%" Pd "", id); 4489 jsobj.AddPropertyF("id", "objects/%" Pd "", id);
4462 const String& user_name = String::Handle(PrettyName()); 4490 const String& user_name = String::Handle(PrettyName());
4463 const String& vm_name = String::Handle(Name()); 4491 const String& vm_name = String::Handle(Name());
4464 AddNameProperties(&jsobj, user_name, vm_name); 4492 AddNameProperties(&jsobj, user_name, vm_name);
4465 jsobj.AddProperty("length", Length()); 4493 jsobj.AddProperty("length", Length());
4466 jsobj.AddProperty("numInstantiations", NumInstantiations()); 4494 jsobj.AddProperty("numInstantiations", NumInstantiations());
4467 if (ref) { 4495 if (ref) {
4468 return; 4496 return;
4469 } 4497 }
4470 { 4498 {
(...skipping 2329 matching lines...) Expand 10 before | Expand all | Expand 10 after
6800 } 6828 }
6801 6829
6802 6830
6803 void Function::PrintJSONImpl(JSONStream* stream, bool ref) const { 6831 void Function::PrintJSONImpl(JSONStream* stream, bool ref) const {
6804 Class& cls = Class::Handle(Owner()); 6832 Class& cls = Class::Handle(Owner());
6805 ASSERT(!cls.IsNull()); 6833 ASSERT(!cls.IsNull());
6806 Error& err = Error::Handle(); 6834 Error& err = Error::Handle();
6807 err ^= cls.EnsureIsFinalized(Isolate::Current()); 6835 err ^= cls.EnsureIsFinalized(Isolate::Current());
6808 ASSERT(err.IsNull()); 6836 ASSERT(err.IsNull());
6809 JSONObject jsobj(stream); 6837 JSONObject jsobj(stream);
6810 jsobj.AddProperty("type", JSONType(ref)); 6838 AddTypeProperties(&jsobj, "Function", JSONType(), ref);
6811 jsobj.AddProperty("id", GetFunctionServiceId(*this, cls)); 6839 jsobj.AddProperty("id", GetFunctionServiceId(*this, cls));
6812 const String& user_name = String::Handle(PrettyName()); 6840 const String& user_name = String::Handle(PrettyName());
6813 const String& vm_name = String::Handle(name()); 6841 const String& vm_name = String::Handle(name());
6814 AddNameProperties(&jsobj, user_name, vm_name); 6842 AddNameProperties(&jsobj, user_name, vm_name);
6815 if (cls.IsTopLevel()) { 6843 if (cls.IsTopLevel()) {
6816 const Library& library = Library::Handle(cls.library()); 6844 const Library& library = Library::Handle(cls.library());
6817 jsobj.AddProperty("owningLibrary", library); 6845 jsobj.AddProperty("owningLibrary", library);
6818 } else { 6846 } else {
6819 jsobj.AddProperty("owningClass", cls); 6847 jsobj.AddProperty("owningClass", cls);
6820 } 6848 }
(...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); 7174 OS::SNPrint(chars, len, kFormat, cls_name, field_name, kF0, kF1, kF2);
7147 return chars; 7175 return chars;
7148 } 7176 }
7149 7177
7150 void Field::PrintJSONImpl(JSONStream* stream, bool ref) const { 7178 void Field::PrintJSONImpl(JSONStream* stream, bool ref) const {
7151 JSONObject jsobj(stream); 7179 JSONObject jsobj(stream);
7152 Class& cls = Class::Handle(owner()); 7180 Class& cls = Class::Handle(owner());
7153 intptr_t id = cls.FindFieldIndex(*this); 7181 intptr_t id = cls.FindFieldIndex(*this);
7154 ASSERT(id >= 0); 7182 ASSERT(id >= 0);
7155 intptr_t cid = cls.id(); 7183 intptr_t cid = cls.id();
7156 jsobj.AddProperty("type", JSONType(ref)); 7184 AddTypeProperties(&jsobj, "Field", JSONType(), ref);
7157 jsobj.AddPropertyF("id", "classes/%" Pd "/fields/%" Pd "", cid, id); 7185 jsobj.AddPropertyF("id", "classes/%" Pd "/fields/%" Pd "", cid, id);
7158 const String& user_name = String::Handle(PrettyName()); 7186 const String& user_name = String::Handle(PrettyName());
7159 const String& vm_name = String::Handle(name()); 7187 const String& vm_name = String::Handle(name());
7160 AddNameProperties(&jsobj, user_name, vm_name); 7188 AddNameProperties(&jsobj, user_name, vm_name);
7161 if (is_static()) { 7189 if (is_static()) {
7162 const Instance& valueObj = Instance::Handle(value()); 7190 const Instance& valueObj = Instance::Handle(value());
7163 jsobj.AddProperty("value", valueObj); 7191 jsobj.AddProperty("value", valueObj);
7164 } 7192 }
7165 7193
7166 if (cls.IsTopLevel()) { 7194 if (cls.IsTopLevel()) {
(...skipping 1299 matching lines...) Expand 10 before | Expand all | Expand 10 after
8466 } 8494 }
8467 } 8495 }
8468 } 8496 }
8469 return Library::null(); 8497 return Library::null();
8470 } 8498 }
8471 8499
8472 8500
8473 // See also Dart_ScriptGetTokenInfo. 8501 // See also Dart_ScriptGetTokenInfo.
8474 void Script::PrintJSONImpl(JSONStream* stream, bool ref) const { 8502 void Script::PrintJSONImpl(JSONStream* stream, bool ref) const {
8475 JSONObject jsobj(stream); 8503 JSONObject jsobj(stream);
8476 jsobj.AddProperty("type", JSONType(ref)); 8504 AddTypeProperties(&jsobj, "Script", JSONType(), ref);
8477 const String& name = String::Handle(url()); 8505 const String& name = String::Handle(url());
8478 ASSERT(!name.IsNull()); 8506 ASSERT(!name.IsNull());
8479 const String& encoded_url = String::Handle(String::EncodeIRI(name)); 8507 const String& encoded_url = String::Handle(String::EncodeIRI(name));
8480 ASSERT(!encoded_url.IsNull()); 8508 ASSERT(!encoded_url.IsNull());
8481 const Library& lib = Library::Handle(FindLibrary()); 8509 const Library& lib = Library::Handle(FindLibrary());
8482 intptr_t lib_index = (lib.IsNull()) ? -1 : lib.index(); 8510 intptr_t lib_index = (lib.IsNull()) ? -1 : lib.index();
8483 jsobj.AddPropertyF("id", "libraries/%" Pd "/scripts/%s", 8511 jsobj.AddPropertyF("id", "libraries/%" Pd "/scripts/%s",
8484 lib_index, encoded_url.ToCString()); 8512 lib_index, encoded_url.ToCString());
8485 jsobj.AddProperty("name", name.ToCString()); 8513 jsobj.AddProperty("name", name.ToCString());
8486 jsobj.AddProperty("kind", GetKindAsCString()); 8514 jsobj.AddProperty("kind", GetKindAsCString());
(...skipping 1272 matching lines...) Expand 10 before | Expand all | Expand 10 after
9759 OS::SNPrint(chars, len, kFormat, name.ToCString()); 9787 OS::SNPrint(chars, len, kFormat, name.ToCString());
9760 return chars; 9788 return chars;
9761 } 9789 }
9762 9790
9763 9791
9764 void Library::PrintJSONImpl(JSONStream* stream, bool ref) const { 9792 void Library::PrintJSONImpl(JSONStream* stream, bool ref) const {
9765 const char* library_name = String::Handle(name()).ToCString(); 9793 const char* library_name = String::Handle(name()).ToCString();
9766 intptr_t id = index(); 9794 intptr_t id = index();
9767 ASSERT(id >= 0); 9795 ASSERT(id >= 0);
9768 JSONObject jsobj(stream); 9796 JSONObject jsobj(stream);
9769 jsobj.AddProperty("type", JSONType(ref)); 9797 AddTypeProperties(&jsobj, "Library", JSONType(), ref);
9770 jsobj.AddPropertyF("id", "libraries/%" Pd "", id); 9798 jsobj.AddPropertyF("id", "libraries/%" Pd "", id);
9771 jsobj.AddProperty("name", library_name); 9799 jsobj.AddProperty("name", library_name);
9772 const char* library_url = String::Handle(url()).ToCString(); 9800 const char* library_url = String::Handle(url()).ToCString();
9773 jsobj.AddProperty("url", library_url); 9801 jsobj.AddProperty("url", library_url);
9774 if (ref) { 9802 if (ref) {
9775 return; 9803 return;
9776 } 9804 }
9777 { 9805 {
9778 JSONArray jsarr(&jsobj, "classes"); 9806 JSONArray jsarr(&jsobj, "classes");
9779 ClassDictionaryIterator class_iter(*this); 9807 ClassDictionaryIterator class_iter(*this);
(...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after
10546 KindAsStr(iter.Kind()), 10574 KindAsStr(iter.Kind()),
10547 iter.DeoptId(), 10575 iter.DeoptId(),
10548 iter.TokenPos(), 10576 iter.TokenPos(),
10549 iter.TryIndex()); 10577 iter.TryIndex());
10550 } 10578 }
10551 return buffer; 10579 return buffer;
10552 } 10580 }
10553 10581
10554 10582
10555 void PcDescriptors::PrintToJSONObject(JSONObject* jsobj) const { 10583 void PcDescriptors::PrintToJSONObject(JSONObject* jsobj) const {
10556 jsobj->AddProperty("type", JSONType(false)); 10584 AddTypeProperties(jsobj, "Object", JSONType(), false);
10557 // TODO(johnmccutchan): Generate a valid ID. 10585 // TODO(johnmccutchan): Generate a valid ID.
10558 // PcDescriptors hang off a Code object but do not have a back reference to 10586 // PcDescriptors hang off a Code object but do not have a back reference to
10559 // generate an ID. Currently we only print PcDescriptors inline with a Code. 10587 // generate an ID. Currently we only print PcDescriptors inline with a Code.
10560 jsobj->AddProperty("id", ""); 10588 jsobj->AddProperty("id", "");
10561 JSONArray members(jsobj, "members"); 10589 JSONArray members(jsobj, "members");
10562 Iterator iter(*this, RawPcDescriptors::kAnyKind); 10590 Iterator iter(*this, RawPcDescriptors::kAnyKind);
10563 while (iter.MoveNext()) { 10591 while (iter.MoveNext()) {
10564 JSONObject descriptor(&members); 10592 JSONObject descriptor(&members);
10565 descriptor.AddPropertyF("pc", "%" Px "", iter.Pc()); 10593 descriptor.AddPropertyF("pc", "%" Px "", iter.Pc());
10566 descriptor.AddProperty("kind", KindAsStr(iter.Kind())); 10594 descriptor.AddProperty("kind", KindAsStr(iter.Kind()));
(...skipping 1707 matching lines...) Expand 10 before | Expand all | Expand 10 after
12274 } else { 12302 } else {
12275 ASSERT(obj.IsFunction()); 12303 ASSERT(obj.IsFunction());
12276 // Dart function. 12304 // Dart function.
12277 return Function::Cast(obj).QualifiedPrettyName(); 12305 return Function::Cast(obj).QualifiedPrettyName();
12278 } 12306 }
12279 } 12307 }
12280 12308
12281 12309
12282 void Code::PrintJSONImpl(JSONStream* stream, bool ref) const { 12310 void Code::PrintJSONImpl(JSONStream* stream, bool ref) const {
12283 JSONObject jsobj(stream); 12311 JSONObject jsobj(stream);
12284 jsobj.AddProperty("type", JSONType(ref)); 12312 AddTypeProperties(&jsobj, "Code", JSONType(), ref);
12285 jsobj.AddPropertyF("id", "code/%" Px64"-%" Px "", compile_timestamp(), 12313 jsobj.AddPropertyF("id", "code/%" Px64"-%" Px "", compile_timestamp(),
12286 EntryPoint()); 12314 EntryPoint());
12287 jsobj.AddPropertyF("start", "%" Px "", EntryPoint()); 12315 jsobj.AddPropertyF("start", "%" Px "", EntryPoint());
12288 jsobj.AddPropertyF("end", "%" Px "", EntryPoint() + Size()); 12316 jsobj.AddPropertyF("end", "%" Px "", EntryPoint() + Size());
12289 jsobj.AddProperty("optimized", is_optimized()); 12317 jsobj.AddProperty("optimized", is_optimized());
12290 jsobj.AddProperty("alive", is_alive()); 12318 jsobj.AddProperty("alive", is_alive());
12291 jsobj.AddProperty("kind", "Dart"); 12319 jsobj.AddProperty("kind", "Dart");
12292 const String& user_name = String::Handle(PrettyName()); 12320 const String& user_name = String::Handle(PrettyName());
12293 const String& vm_name = String::Handle(Name()); 12321 const String& vm_name = String::Handle(Name());
12294 AddNameProperties(&jsobj, user_name, vm_name); 12322 AddNameProperties(&jsobj, user_name, vm_name);
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
12437 if (!parent_ctx.IsNull()) { 12465 if (!parent_ctx.IsNull()) {
12438 parent_ctx.Dump(indent + 2); 12466 parent_ctx.Dump(indent + 2);
12439 } 12467 }
12440 IndentN(indent); 12468 IndentN(indent);
12441 OS::PrintErr("}\n"); 12469 OS::PrintErr("}\n");
12442 } 12470 }
12443 12471
12444 12472
12445 void Context::PrintJSONImpl(JSONStream* stream, bool ref) const { 12473 void Context::PrintJSONImpl(JSONStream* stream, bool ref) const {
12446 JSONObject jsobj(stream); 12474 JSONObject jsobj(stream);
12447 jsobj.AddProperty("type", JSONType(ref)); 12475 // TODO(turnidge): Should the user level type for Context be Context
12476 // or Object?
12477 AddTypeProperties(&jsobj, "Context", JSONType(), ref);
12448 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); 12478 ObjectIdRing* ring = Isolate::Current()->object_id_ring();
12449 const intptr_t id = ring->GetIdForObject(raw()); 12479 const intptr_t id = ring->GetIdForObject(raw());
12450 jsobj.AddPropertyF("id", "objects/%" Pd "", id); 12480 jsobj.AddPropertyF("id", "objects/%" Pd "", id);
12451 12481
12452 jsobj.AddProperty("length", num_variables()); 12482 jsobj.AddProperty("length", num_variables());
12453 12483
12454 if (ref) { 12484 if (ref) {
12455 return; 12485 return;
12456 } 12486 }
12457 12487
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
12837 } 12867 }
12838 12868
12839 12869
12840 const char* ApiError::ToCString() const { 12870 const char* ApiError::ToCString() const {
12841 return "ApiError"; 12871 return "ApiError";
12842 } 12872 }
12843 12873
12844 12874
12845 void ApiError::PrintJSONImpl(JSONStream* stream, bool ref) const { 12875 void ApiError::PrintJSONImpl(JSONStream* stream, bool ref) const {
12846 JSONObject jsobj(stream); 12876 JSONObject jsobj(stream);
12847 jsobj.AddProperty("type", "Error"); 12877 AddTypeProperties(&jsobj, "Error", JSONType(), ref);
12848 jsobj.AddProperty("id", ""); 12878 jsobj.AddProperty("id", "");
12849 jsobj.AddProperty("kind", JSONType(false));
12850 jsobj.AddProperty("message", ToErrorCString()); 12879 jsobj.AddProperty("message", ToErrorCString());
12851 } 12880 }
12852 12881
12853 12882
12854 RawLanguageError* LanguageError::New() { 12883 RawLanguageError* LanguageError::New() {
12855 ASSERT(Object::language_error_class() != Class::null()); 12884 ASSERT(Object::language_error_class() != Class::null());
12856 RawObject* raw = Object::Allocate(LanguageError::kClassId, 12885 RawObject* raw = Object::Allocate(LanguageError::kClassId,
12857 LanguageError::InstanceSize(), 12886 LanguageError::InstanceSize(),
12858 Heap::kOld); 12887 Heap::kOld);
12859 return reinterpret_cast<RawLanguageError*>(raw); 12888 return reinterpret_cast<RawLanguageError*>(raw);
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
12976 } 13005 }
12977 13006
12978 13007
12979 const char* LanguageError::ToCString() const { 13008 const char* LanguageError::ToCString() const {
12980 return "LanguageError"; 13009 return "LanguageError";
12981 } 13010 }
12982 13011
12983 13012
12984 void LanguageError::PrintJSONImpl(JSONStream* stream, bool ref) const { 13013 void LanguageError::PrintJSONImpl(JSONStream* stream, bool ref) const {
12985 JSONObject jsobj(stream); 13014 JSONObject jsobj(stream);
12986 jsobj.AddProperty("type", "Error"); 13015 AddTypeProperties(&jsobj, "Error", JSONType(), ref);
12987 jsobj.AddProperty("id", ""); 13016 jsobj.AddProperty("id", "");
12988 jsobj.AddProperty("kind", JSONType(false));
12989 jsobj.AddProperty("message", ToErrorCString()); 13017 jsobj.AddProperty("message", ToErrorCString());
12990 } 13018 }
12991 13019
12992 13020
12993 RawUnhandledException* UnhandledException::New(const Instance& exception, 13021 RawUnhandledException* UnhandledException::New(const Instance& exception,
12994 const Instance& stacktrace, 13022 const Instance& stacktrace,
12995 Heap::Space space) { 13023 Heap::Space space) {
12996 ASSERT(Object::unhandled_exception_class() != Class::null()); 13024 ASSERT(Object::unhandled_exception_class() != Class::null());
12997 UnhandledException& result = UnhandledException::Handle(); 13025 UnhandledException& result = UnhandledException::Handle();
12998 { 13026 {
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
13071 13099
13072 const char* UnhandledException::ToCString() const { 13100 const char* UnhandledException::ToCString() const {
13073 return "UnhandledException"; 13101 return "UnhandledException";
13074 } 13102 }
13075 13103
13076 13104
13077 13105
13078 void UnhandledException::PrintJSONImpl(JSONStream* stream, 13106 void UnhandledException::PrintJSONImpl(JSONStream* stream,
13079 bool ref) const { 13107 bool ref) const {
13080 JSONObject jsobj(stream); 13108 JSONObject jsobj(stream);
13081 jsobj.AddProperty("type", "Error"); 13109 AddTypeProperties(&jsobj, "Error", JSONType(), ref);
13082 jsobj.AddProperty("id", ""); 13110 jsobj.AddProperty("id", "");
13083 jsobj.AddProperty("kind", JSONType(false));
13084 jsobj.AddProperty("message", ToErrorCString()); 13111 jsobj.AddProperty("message", ToErrorCString());
13085 13112
13086 Instance& instance = Instance::Handle(); 13113 Instance& instance = Instance::Handle();
13087 instance = exception(); 13114 instance = exception();
13088 jsobj.AddProperty("exception", instance); 13115 jsobj.AddProperty("exception", instance);
13089 instance = stacktrace(); 13116 instance = stacktrace();
13090 jsobj.AddProperty("stacktrace", instance); 13117 jsobj.AddProperty("stacktrace", instance);
13091 } 13118 }
13092 13119
13093 13120
(...skipping 23 matching lines...) Expand all
13117 } 13144 }
13118 13145
13119 13146
13120 const char* UnwindError::ToCString() const { 13147 const char* UnwindError::ToCString() const {
13121 return "UnwindError"; 13148 return "UnwindError";
13122 } 13149 }
13123 13150
13124 13151
13125 void UnwindError::PrintJSONImpl(JSONStream* stream, bool ref) const { 13152 void UnwindError::PrintJSONImpl(JSONStream* stream, bool ref) const {
13126 JSONObject jsobj(stream); 13153 JSONObject jsobj(stream);
13127 jsobj.AddProperty("type", "Error"); 13154 AddTypeProperties(&jsobj, "Error", JSONType(), ref);
13128 jsobj.AddProperty("id", ""); 13155 jsobj.AddProperty("id", "");
13129 jsobj.AddProperty("kind", JSONType(false));
13130 jsobj.AddProperty("message", ToErrorCString()); 13156 jsobj.AddProperty("message", ToErrorCString());
13131 } 13157 }
13132 13158
13133 13159
13134 RawObject* Instance::Evaluate(const String& expr, 13160 RawObject* Instance::Evaluate(const String& expr,
13135 const Array& param_names, 13161 const Array& param_names,
13136 const Array& param_values) const { 13162 const Array& param_values) const {
13137 const Class& cls = Class::Handle(clazz()); 13163 const Class& cls = Class::Handle(clazz());
13138 const Function& eval_func = 13164 const Function& eval_func =
13139 Function::Handle(EvaluateHelper(cls, expr, param_names, false)); 13165 Function::Handle(EvaluateHelper(cls, expr, param_names, false));
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
13562 const String& type_name = String::Handle(type.UserVisibleName()); 13588 const String& type_name = String::Handle(type.UserVisibleName());
13563 // Calculate the size of the string. 13589 // Calculate the size of the string.
13564 intptr_t len = OS::SNPrint(NULL, 0, kFormat, type_name.ToCString()) + 1; 13590 intptr_t len = OS::SNPrint(NULL, 0, kFormat, type_name.ToCString()) + 1;
13565 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); 13591 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
13566 OS::SNPrint(chars, len, kFormat, type_name.ToCString()); 13592 OS::SNPrint(chars, len, kFormat, type_name.ToCString());
13567 return chars; 13593 return chars;
13568 } 13594 }
13569 } 13595 }
13570 13596
13571 13597
13572 void Instance::PrintSharedInstanceJSON(JSONObject* jsobj, bool ref) const { 13598 void Instance::PrintSharedInstanceJSON(JSONObject* jsobj,
13573 jsobj->AddProperty("type", JSONType(ref)); 13599 bool ref) const {
13574 Class& cls = Class::Handle(this->clazz()); 13600 Class& cls = Class::Handle(this->clazz());
13575 jsobj->AddProperty("class", cls); 13601 jsobj->AddProperty("class", cls);
13576 // TODO(turnidge): Provide the type arguments here too. 13602 // TODO(turnidge): Provide the type arguments here too.
13577 if (ref) { 13603 if (ref) {
13578 return; 13604 return;
13579 } 13605 }
13580 13606
13581 if (raw()->IsHeapObject()) { 13607 if (raw()->IsHeapObject()) {
13582 jsobj->AddProperty("size", raw()->Size()); 13608 jsobj->AddProperty("size", raw()->Size());
13583 } 13609 }
(...skipping 25 matching lines...) Expand all
13609 for (intptr_t i = 0; i < NumNativeFields(); i++) { 13635 for (intptr_t i = 0; i < NumNativeFields(); i++) {
13610 intptr_t value = GetNativeField(i); 13636 intptr_t value = GetNativeField(i);
13611 JSONObject jsfield(&jsarr); 13637 JSONObject jsfield(&jsarr);
13612 jsfield.AddProperty("index", i); 13638 jsfield.AddProperty("index", i);
13613 jsfield.AddProperty("value", value); 13639 jsfield.AddProperty("value", value);
13614 } 13640 }
13615 } 13641 }
13616 } 13642 }
13617 13643
13618 13644
13619 void Object::PrintJSONImpl(JSONStream* stream, bool ref) const {
13620 JSONObject jsobj(stream);
13621 jsobj.AddProperty("type", JSONType(ref));
13622 ObjectIdRing* ring = Isolate::Current()->object_id_ring();
13623 const intptr_t id = ring->GetIdForObject(raw());
13624 jsobj.AddPropertyF("id", "objects/%" Pd "", id);
13625 }
13626
13627
13628 void Instance::PrintJSONImpl(JSONStream* stream, bool ref) const { 13645 void Instance::PrintJSONImpl(JSONStream* stream, bool ref) const {
13629 JSONObject jsobj(stream); 13646 JSONObject jsobj(stream);
13630 13647
13631 // Handle certain special instance values. 13648 // Handle certain special instance values.
13632 if (raw() == Object::sentinel().raw()) { 13649 if (raw() == Object::sentinel().raw()) {
13633 jsobj.AddProperty("type", "Sentinel"); 13650 jsobj.AddProperty("type", "Sentinel");
13634 jsobj.AddProperty("id", "objects/not-initialized"); 13651 jsobj.AddProperty("id", "objects/not-initialized");
13635 jsobj.AddProperty("valueAsString", "<not initialized>"); 13652 jsobj.AddProperty("valueAsString", "<not initialized>");
13636 return; 13653 return;
13637 } else if (raw() == Object::transition_sentinel().raw()) { 13654 } else if (raw() == Object::transition_sentinel().raw()) {
13638 jsobj.AddProperty("type", "Sentinel"); 13655 jsobj.AddProperty("type", "Sentinel");
13639 jsobj.AddProperty("id", "objects/being-initialized"); 13656 jsobj.AddProperty("id", "objects/being-initialized");
13640 jsobj.AddProperty("valueAsString", "<being initialized>"); 13657 jsobj.AddProperty("valueAsString", "<being initialized>");
13641 return; 13658 return;
13642 } 13659 }
13643 13660
13661 AddTypeProperties(&jsobj, "Instance", JSONType(), ref);
13644 PrintSharedInstanceJSON(&jsobj, ref); 13662 PrintSharedInstanceJSON(&jsobj, ref);
13645 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); 13663 ObjectIdRing* ring = Isolate::Current()->object_id_ring();
13646 const intptr_t id = ring->GetIdForObject(raw()); 13664 const intptr_t id = ring->GetIdForObject(raw());
13647 if (IsClosure()) { 13665 if (IsClosure()) {
13648 const Function& closureFunc = Function::Handle(Closure::function(*this)); 13666 const Function& closureFunc = Function::Handle(Closure::function(*this));
13649 jsobj.AddProperty("closureFunc", closureFunc); 13667 jsobj.AddProperty("closureFunc", closureFunc);
13650 const Context& closureCtxt = Context::Handle(Closure::context(*this)); 13668 const Context& closureCtxt = Context::Handle(Closure::context(*this));
13651 jsobj.AddProperty("closureCtxt", closureCtxt); 13669 jsobj.AddProperty("closureCtxt", closureCtxt);
13652 } 13670 }
13653 jsobj.AddPropertyF("id", "objects/%" Pd "", id); 13671 jsobj.AddPropertyF("id", "objects/%" Pd "", id);
(...skipping 1047 matching lines...) Expand 10 before | Expand all | Expand 10 after
14701 return chars; 14719 return chars;
14702 } 14720 }
14703 } else { 14721 } else {
14704 return "Unresolved Type"; 14722 return "Unresolved Type";
14705 } 14723 }
14706 } 14724 }
14707 14725
14708 14726
14709 void Type::PrintJSONImpl(JSONStream* stream, bool ref) const { 14727 void Type::PrintJSONImpl(JSONStream* stream, bool ref) const {
14710 JSONObject jsobj(stream); 14728 JSONObject jsobj(stream);
14729 AddTypeProperties(&jsobj, "Type", JSONType(), ref);
14711 PrintSharedInstanceJSON(&jsobj, ref); 14730 PrintSharedInstanceJSON(&jsobj, ref);
14712 if (IsCanonical()) { 14731 if (IsCanonical()) {
14713 const Class& type_cls = Class::Handle(type_class()); 14732 const Class& type_cls = Class::Handle(type_class());
14714 intptr_t id = type_cls.FindCanonicalTypeIndex(*this); 14733 intptr_t id = type_cls.FindCanonicalTypeIndex(*this);
14715 ASSERT(id >= 0); 14734 ASSERT(id >= 0);
14716 intptr_t cid = type_cls.id(); 14735 intptr_t cid = type_cls.id();
14717 jsobj.AddPropertyF("id", "classes/%" Pd "/types/%" Pd "", cid, id); 14736 jsobj.AddPropertyF("id", "classes/%" Pd "/types/%" Pd "", cid, id);
14718 jsobj.AddProperty("typeClass", type_cls); 14737 jsobj.AddProperty("typeClass", type_cls);
14719 } else { 14738 } else {
14720 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); 14739 ObjectIdRing* ring = Isolate::Current()->object_id_ring();
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
14873 const intptr_t len = OS::SNPrint(NULL, 0, format, type_cstr) + 1; 14892 const intptr_t len = OS::SNPrint(NULL, 0, format, type_cstr) + 1;
14874 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); 14893 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
14875 OS::SNPrint(chars, len, format, type_cstr); 14894 OS::SNPrint(chars, len, format, type_cstr);
14876 return chars; 14895 return chars;
14877 } 14896 }
14878 } 14897 }
14879 14898
14880 14899
14881 void TypeRef::PrintJSONImpl(JSONStream* stream, bool ref) const { 14900 void TypeRef::PrintJSONImpl(JSONStream* stream, bool ref) const {
14882 JSONObject jsobj(stream); 14901 JSONObject jsobj(stream);
14902 AddTypeProperties(&jsobj, "TypeRef", JSONType(), ref);
14883 PrintSharedInstanceJSON(&jsobj, ref); 14903 PrintSharedInstanceJSON(&jsobj, ref);
14884 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); 14904 ObjectIdRing* ring = Isolate::Current()->object_id_ring();
14885 const intptr_t id = ring->GetIdForObject(raw()); 14905 const intptr_t id = ring->GetIdForObject(raw());
14886 jsobj.AddPropertyF("id", "objects/%" Pd "", id); 14906 jsobj.AddPropertyF("id", "objects/%" Pd "", id);
14887 const String& user_name = String::Handle(PrettyName()); 14907 const String& user_name = String::Handle(PrettyName());
14888 const String& vm_name = String::Handle(Name()); 14908 const String& vm_name = String::Handle(Name());
14889 AddNameProperties(&jsobj, user_name, vm_name); 14909 AddNameProperties(&jsobj, user_name, vm_name);
14890 if (ref) { 14910 if (ref) {
14891 return; 14911 return;
14892 } 14912 }
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
15089 intptr_t len = OS::SNPrint( 15109 intptr_t len = OS::SNPrint(
15090 NULL, 0, format, name_cstr, index(), cls_cstr, bound_cstr) + 1; 15110 NULL, 0, format, name_cstr, index(), cls_cstr, bound_cstr) + 1;
15091 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); 15111 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
15092 OS::SNPrint(chars, len, format, name_cstr, index(), cls_cstr, bound_cstr); 15112 OS::SNPrint(chars, len, format, name_cstr, index(), cls_cstr, bound_cstr);
15093 return chars; 15113 return chars;
15094 } 15114 }
15095 15115
15096 15116
15097 void TypeParameter::PrintJSONImpl(JSONStream* stream, bool ref) const { 15117 void TypeParameter::PrintJSONImpl(JSONStream* stream, bool ref) const {
15098 JSONObject jsobj(stream); 15118 JSONObject jsobj(stream);
15119 AddTypeProperties(&jsobj, "TypeParameter", JSONType(), ref);
15099 PrintSharedInstanceJSON(&jsobj, ref); 15120 PrintSharedInstanceJSON(&jsobj, ref);
15100 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); 15121 ObjectIdRing* ring = Isolate::Current()->object_id_ring();
15101 const intptr_t id = ring->GetIdForObject(raw()); 15122 const intptr_t id = ring->GetIdForObject(raw());
15102 jsobj.AddPropertyF("id", "objects/%" Pd "", id); 15123 jsobj.AddPropertyF("id", "objects/%" Pd "", id);
15103 const String& user_name = String::Handle(PrettyName()); 15124 const String& user_name = String::Handle(PrettyName());
15104 const String& vm_name = String::Handle(Name()); 15125 const String& vm_name = String::Handle(Name());
15105 AddNameProperties(&jsobj, user_name, vm_name); 15126 AddNameProperties(&jsobj, user_name, vm_name);
15106 const Class& param_cls = Class::Handle(parameterized_class()); 15127 const Class& param_cls = Class::Handle(parameterized_class());
15107 jsobj.AddProperty("parameterizedClass", param_cls); 15128 jsobj.AddProperty("parameterizedClass", param_cls);
15108 if (ref) { 15129 if (ref) {
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
15292 NULL, 0, format, type_cstr, bound_cstr, type_param_cstr, cls_cstr) + 1; 15313 NULL, 0, format, type_cstr, bound_cstr, type_param_cstr, cls_cstr) + 1;
15293 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); 15314 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
15294 OS::SNPrint( 15315 OS::SNPrint(
15295 chars, len, format, type_cstr, bound_cstr, type_param_cstr, cls_cstr); 15316 chars, len, format, type_cstr, bound_cstr, type_param_cstr, cls_cstr);
15296 return chars; 15317 return chars;
15297 } 15318 }
15298 15319
15299 15320
15300 void BoundedType::PrintJSONImpl(JSONStream* stream, bool ref) const { 15321 void BoundedType::PrintJSONImpl(JSONStream* stream, bool ref) const {
15301 JSONObject jsobj(stream); 15322 JSONObject jsobj(stream);
15323 AddTypeProperties(&jsobj, "BoundedType", JSONType(), ref);
15302 PrintSharedInstanceJSON(&jsobj, ref); 15324 PrintSharedInstanceJSON(&jsobj, ref);
15303 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); 15325 ObjectIdRing* ring = Isolate::Current()->object_id_ring();
15304 const intptr_t id = ring->GetIdForObject(raw()); 15326 const intptr_t id = ring->GetIdForObject(raw());
15305 jsobj.AddPropertyF("id", "objects/%" Pd "", id); 15327 jsobj.AddPropertyF("id", "objects/%" Pd "", id);
15306 const String& user_name = String::Handle(PrettyName()); 15328 const String& user_name = String::Handle(PrettyName());
15307 const String& vm_name = String::Handle(Name()); 15329 const String& vm_name = String::Handle(Name());
15308 AddNameProperties(&jsobj, user_name, vm_name); 15330 AddNameProperties(&jsobj, user_name, vm_name);
15309 if (ref) { 15331 if (ref) {
15310 return; 15332 return;
15311 } 15333 }
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
15385 15407
15386 15408
15387 const char* Number::ToCString() const { 15409 const char* Number::ToCString() const {
15388 // Number is an interface. No instances of Number should exist. 15410 // Number is an interface. No instances of Number should exist.
15389 UNREACHABLE(); 15411 UNREACHABLE();
15390 return "Number"; 15412 return "Number";
15391 } 15413 }
15392 15414
15393 15415
15394 void Number::PrintJSONImpl(JSONStream* stream, bool ref) const { 15416 void Number::PrintJSONImpl(JSONStream* stream, bool ref) const {
15395 JSONObject jsobj(stream); 15417 UNREACHABLE();
15396 PrintSharedInstanceJSON(&jsobj, ref);
15397 ObjectIdRing* ring = Isolate::Current()->object_id_ring();
15398 const intptr_t id = ring->GetIdForObject(raw());
15399 jsobj.AddPropertyF("id", "objects/%" Pd "", id);
15400 jsobj.AddProperty("valueAsString", ToCString());
15401 } 15418 }
15402 15419
15403 15420
15404 const char* Integer::ToCString() const { 15421 const char* Integer::ToCString() const {
15405 // Integer is an interface. No instances of Integer should exist. 15422 // Integer is an interface. No instances of Integer should exist.
15406 UNREACHABLE(); 15423 UNREACHABLE();
15407 return "Integer"; 15424 return "Integer";
15408 } 15425 }
15409 15426
15410 15427
15411 void Integer::PrintJSONImpl(JSONStream* stream, bool ref) const { 15428 void Integer::PrintJSONImpl(JSONStream* stream, bool ref) const {
15412 Number::PrintJSONImpl(stream, ref); 15429 JSONObject jsobj(stream);
15430 AddTypeProperties(&jsobj, "int", JSONType(), ref);
15431 PrintSharedInstanceJSON(&jsobj, ref);
15432 ObjectIdRing* ring = Isolate::Current()->object_id_ring();
15433 const intptr_t id = ring->GetIdForObject(raw());
15434 jsobj.AddPropertyF("id", "objects/%" Pd "", id);
15435 jsobj.AddProperty("valueAsString", ToCString());
15413 } 15436 }
15414 15437
15415 15438
15416 // Throw JavascriptIntegerOverflow exception. 15439 // Throw JavascriptIntegerOverflow exception.
15417 static void ThrowJavascriptIntegerOverflow(const Integer& i) { 15440 static void ThrowJavascriptIntegerOverflow(const Integer& i) {
15418 const Array& exc_args = Array::Handle(Array::New(1)); 15441 const Array& exc_args = Array::Handle(Array::New(1));
15419 const String& i_str = String::Handle(String::New(i.ToCString())); 15442 const String& i_str = String::Handle(String::New(i.ToCString()));
15420 exc_args.SetAt(0, i_str); 15443 exc_args.SetAt(0, i_str);
15421 Exceptions::ThrowByType(Exceptions::kJavascriptIntegerOverflowError, 15444 Exceptions::ThrowByType(Exceptions::kJavascriptIntegerOverflowError,
15422 exc_args); 15445 exc_args);
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
15835 // Calculate the size of the string. 15858 // Calculate the size of the string.
15836 intptr_t len = OS::SNPrint(NULL, 0, kFormat, Value()) + 1; 15859 intptr_t len = OS::SNPrint(NULL, 0, kFormat, Value()) + 1;
15837 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); 15860 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
15838 OS::SNPrint(chars, len, kFormat, Value()); 15861 OS::SNPrint(chars, len, kFormat, Value());
15839 return chars; 15862 return chars;
15840 } 15863 }
15841 15864
15842 15865
15843 void Smi::PrintJSONImpl(JSONStream* stream, bool ref) const { 15866 void Smi::PrintJSONImpl(JSONStream* stream, bool ref) const {
15844 JSONObject jsobj(stream); 15867 JSONObject jsobj(stream);
15868 AddTypeProperties(&jsobj, "int", JSONType(), ref);
15845 PrintSharedInstanceJSON(&jsobj, ref); 15869 PrintSharedInstanceJSON(&jsobj, ref);
15846 jsobj.AddPropertyF("id", "objects/int-%" Pd "", Value()); 15870 jsobj.AddPropertyF("id", "objects/int-%" Pd "", Value());
15847 jsobj.AddPropertyF("valueAsString", "%" Pd "", Value()); 15871 jsobj.AddPropertyF("valueAsString", "%" Pd "", Value());
15848 } 15872 }
15849 15873
15850 15874
15851 RawClass* Smi::Class() { 15875 RawClass* Smi::Class() {
15852 return Isolate::Current()->object_store()->smi_class(); 15876 return Isolate::Current()->object_store()->smi_class();
15853 } 15877 }
15854 15878
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
15961 const char* kFormat = "%lld"; 15985 const char* kFormat = "%lld";
15962 // Calculate the size of the string. 15986 // Calculate the size of the string.
15963 intptr_t len = OS::SNPrint(NULL, 0, kFormat, value()) + 1; 15987 intptr_t len = OS::SNPrint(NULL, 0, kFormat, value()) + 1;
15964 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); 15988 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
15965 OS::SNPrint(chars, len, kFormat, value()); 15989 OS::SNPrint(chars, len, kFormat, value());
15966 return chars; 15990 return chars;
15967 } 15991 }
15968 15992
15969 15993
15970 void Mint::PrintJSONImpl(JSONStream* stream, bool ref) const { 15994 void Mint::PrintJSONImpl(JSONStream* stream, bool ref) const {
15971 Number::PrintJSONImpl(stream, ref); 15995 Integer::PrintJSONImpl(stream, ref);
15972 } 15996 }
15973 15997
15974 15998
15975 void Double::set_value(double value) const { 15999 void Double::set_value(double value) const {
15976 raw_ptr()->value_ = value; 16000 raw_ptr()->value_ = value;
15977 } 16001 }
15978 16002
15979 16003
15980 bool Double::BitwiseEqualsToDouble(double value) const { 16004 bool Double::BitwiseEqualsToDouble(double value) const {
15981 intptr_t value_offset = Double::value_offset(); 16005 intptr_t value_offset = Double::value_offset();
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
16093 } 16117 }
16094 const int kBufferSize = 128; 16118 const int kBufferSize = 128;
16095 char* buffer = Isolate::Current()->current_zone()->Alloc<char>(kBufferSize); 16119 char* buffer = Isolate::Current()->current_zone()->Alloc<char>(kBufferSize);
16096 buffer[kBufferSize - 1] = '\0'; 16120 buffer[kBufferSize - 1] = '\0';
16097 DoubleToCString(value(), buffer, kBufferSize); 16121 DoubleToCString(value(), buffer, kBufferSize);
16098 return buffer; 16122 return buffer;
16099 } 16123 }
16100 16124
16101 16125
16102 void Double::PrintJSONImpl(JSONStream* stream, bool ref) const { 16126 void Double::PrintJSONImpl(JSONStream* stream, bool ref) const {
16103 Number::PrintJSONImpl(stream, ref); 16127 JSONObject jsobj(stream);
16128 // Suppress the fact that the internal vm name for this type is
16129 // "Double". Return "double" instead.
16130 AddTypeProperties(&jsobj, "double", "double", ref);
16131 PrintSharedInstanceJSON(&jsobj, ref);
16132 ObjectIdRing* ring = Isolate::Current()->object_id_ring();
16133 const intptr_t id = ring->GetIdForObject(raw());
16134 jsobj.AddPropertyF("id", "objects/%" Pd "", id);
16135 jsobj.AddProperty("valueAsString", ToCString());
16104 } 16136 }
16105 16137
16106 16138
16107 RawBigint* Integer::AsBigint() const { 16139 RawBigint* Integer::AsBigint() const {
16108 ASSERT(!IsNull()); 16140 ASSERT(!IsNull());
16109 if (IsSmi()) { 16141 if (IsSmi()) {
16110 Smi& smi = Smi::Handle(); 16142 Smi& smi = Smi::Handle();
16111 smi ^= raw(); 16143 smi ^= raw();
16112 return BigintOperations::NewFromSmi(smi); 16144 return BigintOperations::NewFromSmi(smi);
16113 } else if (IsMint()) { 16145 } else if (IsMint()) {
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
16269 return zone->AllocUnsafe(size); 16301 return zone->AllocUnsafe(size);
16270 } 16302 }
16271 16303
16272 16304
16273 const char* Bigint::ToCString() const { 16305 const char* Bigint::ToCString() const {
16274 return BigintOperations::ToDecimalCString(*this, &BigintAllocator); 16306 return BigintOperations::ToDecimalCString(*this, &BigintAllocator);
16275 } 16307 }
16276 16308
16277 16309
16278 void Bigint::PrintJSONImpl(JSONStream* stream, bool ref) const { 16310 void Bigint::PrintJSONImpl(JSONStream* stream, bool ref) const {
16279 Number::PrintJSONImpl(stream, ref); 16311 Integer::PrintJSONImpl(stream, ref);
16280 } 16312 }
16281 16313
16282 16314
16283 // Synchronize with implementation in compiler (intrinsifier). 16315 // Synchronize with implementation in compiler (intrinsifier).
16284 class StringHasher : ValueObject { 16316 class StringHasher : ValueObject {
16285 public: 16317 public:
16286 StringHasher() : hash_(0) {} 16318 StringHasher() : hash_(0) {}
16287 void Add(int32_t ch) { 16319 void Add(int32_t ch) {
16288 hash_ = CombineHashes(hash_, ch); 16320 hash_ = CombineHashes(hash_, ch);
16289 } 16321 }
(...skipping 894 matching lines...) Expand 10 before | Expand all | Expand 10 after
17184 JSONObject jsobj(stream); 17216 JSONObject jsobj(stream);
17185 if (raw() == Symbols::OptimizedOut().raw()) { 17217 if (raw() == Symbols::OptimizedOut().raw()) {
17186 // TODO(turnidge): This is a hack. The user could have this 17218 // TODO(turnidge): This is a hack. The user could have this
17187 // special string in their program. Fixing this involves updating 17219 // special string in their program. Fixing this involves updating
17188 // the debugging api a bit. 17220 // the debugging api a bit.
17189 jsobj.AddProperty("type", "Sentinel"); 17221 jsobj.AddProperty("type", "Sentinel");
17190 jsobj.AddProperty("id", "objects/optimized-out"); 17222 jsobj.AddProperty("id", "objects/optimized-out");
17191 jsobj.AddProperty("valueAsString", "<optimized out>"); 17223 jsobj.AddProperty("valueAsString", "<optimized out>");
17192 return; 17224 return;
17193 } 17225 }
17226 AddTypeProperties(&jsobj, "String", JSONType(), ref);
17194 PrintSharedInstanceJSON(&jsobj, ref); 17227 PrintSharedInstanceJSON(&jsobj, ref);
17195 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); 17228 ObjectIdRing* ring = Isolate::Current()->object_id_ring();
17196 const intptr_t id = ring->GetIdForObject(raw()); 17229 const intptr_t id = ring->GetIdForObject(raw());
17197 jsobj.AddPropertyF("id", "objects/%" Pd "", id); 17230 jsobj.AddPropertyF("id", "objects/%" Pd "", id);
17198 jsobj.AddProperty("valueAsString", ToUserCString(1024)); 17231 jsobj.AddProperty("valueAsString", ToUserCString(1024));
17199 } 17232 }
17200 17233
17201 17234
17202 void String::ToUTF8(uint8_t* utf8_array, intptr_t array_len) const { 17235 void String::ToUTF8(uint8_t* utf8_array, intptr_t array_len) const {
17203 ASSERT(array_len >= Utf8::Length(*this)); 17236 ASSERT(array_len >= Utf8::Length(*this));
(...skipping 849 matching lines...) Expand 10 before | Expand all | Expand 10 after
18053 18086
18054 18087
18055 const char* Bool::ToCString() const { 18088 const char* Bool::ToCString() const {
18056 return value() ? "true" : "false"; 18089 return value() ? "true" : "false";
18057 } 18090 }
18058 18091
18059 18092
18060 void Bool::PrintJSONImpl(JSONStream* stream, bool ref) const { 18093 void Bool::PrintJSONImpl(JSONStream* stream, bool ref) const {
18061 const char* str = ToCString(); 18094 const char* str = ToCString();
18062 JSONObject jsobj(stream); 18095 JSONObject jsobj(stream);
18063 jsobj.AddProperty("type", JSONType(ref)); 18096 // Suppress the fact that the internal vm name for this type is
18097 // "Bool". Return "bool" instead.
18098 AddTypeProperties(&jsobj, "bool", "bool", ref);
18099 PrintSharedInstanceJSON(&jsobj, ref);
18064 jsobj.AddPropertyF("id", "objects/bool-%s", str); 18100 jsobj.AddPropertyF("id", "objects/bool-%s", str);
18065 const Class& cls = Class::Handle(this->clazz());
18066 jsobj.AddProperty("class", cls);
18067 jsobj.AddPropertyF("valueAsString", "%s", str); 18101 jsobj.AddPropertyF("valueAsString", "%s", str);
18068 } 18102 }
18069 18103
18070 18104
18071 bool Array::CanonicalizeEquals(const Instance& other) const { 18105 bool Array::CanonicalizeEquals(const Instance& other) const {
18072 if (this->raw() == other.raw()) { 18106 if (this->raw() == other.raw()) {
18073 // Both handles point to the same raw instance. 18107 // Both handles point to the same raw instance.
18074 return true; 18108 return true;
18075 } 18109 }
18076 18110
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
18174 "_ImmutableList len:%" Pd : "_List len:%" Pd; 18208 "_ImmutableList len:%" Pd : "_List len:%" Pd;
18175 intptr_t len = OS::SNPrint(NULL, 0, format, Length()) + 1; 18209 intptr_t len = OS::SNPrint(NULL, 0, format, Length()) + 1;
18176 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); 18210 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
18177 OS::SNPrint(chars, len, format, Length()); 18211 OS::SNPrint(chars, len, format, Length());
18178 return chars; 18212 return chars;
18179 } 18213 }
18180 18214
18181 18215
18182 void Array::PrintJSONImpl(JSONStream* stream, bool ref) const { 18216 void Array::PrintJSONImpl(JSONStream* stream, bool ref) const {
18183 JSONObject jsobj(stream); 18217 JSONObject jsobj(stream);
18218 AddTypeProperties(&jsobj, "List", JSONType(), ref);
18184 PrintSharedInstanceJSON(&jsobj, ref); 18219 PrintSharedInstanceJSON(&jsobj, ref);
18185 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); 18220 ObjectIdRing* ring = Isolate::Current()->object_id_ring();
18186 const intptr_t id = ring->GetIdForObject(raw()); 18221 const intptr_t id = ring->GetIdForObject(raw());
18187 jsobj.AddPropertyF("id", "objects/%" Pd "", id); 18222 jsobj.AddPropertyF("id", "objects/%" Pd "", id);
18188 jsobj.AddProperty("length", Length()); 18223 jsobj.AddProperty("length", Length());
18189 if (ref) { 18224 if (ref) {
18190 return; 18225 return;
18191 } 18226 }
18192 { 18227 {
18193 JSONArray jsarr(&jsobj, "elements"); 18228 JSONArray jsarr(&jsobj, "elements");
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
18418 intptr_t len = OS::SNPrint(NULL, 0, format, Length()) + 1; 18453 intptr_t len = OS::SNPrint(NULL, 0, format, Length()) + 1;
18419 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); 18454 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
18420 OS::SNPrint(chars, len, format, Length()); 18455 OS::SNPrint(chars, len, format, Length());
18421 return chars; 18456 return chars;
18422 } 18457 }
18423 18458
18424 18459
18425 void GrowableObjectArray::PrintJSONImpl(JSONStream* stream, 18460 void GrowableObjectArray::PrintJSONImpl(JSONStream* stream,
18426 bool ref) const { 18461 bool ref) const {
18427 JSONObject jsobj(stream); 18462 JSONObject jsobj(stream);
18463 AddTypeProperties(&jsobj, "List", JSONType(), ref);
18428 PrintSharedInstanceJSON(&jsobj, ref); 18464 PrintSharedInstanceJSON(&jsobj, ref);
18429 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); 18465 ObjectIdRing* ring = Isolate::Current()->object_id_ring();
18430 const intptr_t id = ring->GetIdForObject(raw()); 18466 const intptr_t id = ring->GetIdForObject(raw());
18431 jsobj.AddPropertyF("id", "objects/%" Pd "", id); 18467 jsobj.AddPropertyF("id", "objects/%" Pd "", id);
18432 jsobj.AddProperty("length", Length()); 18468 jsobj.AddProperty("length", Length());
18433 if (ref) { 18469 if (ref) {
18434 return; 18470 return;
18435 } 18471 }
18436 { 18472 {
18437 JSONArray jsarr(&jsobj, "elements"); 18473 JSONArray jsarr(&jsobj, "elements");
(...skipping 1039 matching lines...) Expand 10 before | Expand all | Expand 10 after
19477 } 19513 }
19478 19514
19479 19515
19480 const char* WeakProperty::ToCString() const { 19516 const char* WeakProperty::ToCString() const {
19481 return "_WeakProperty"; 19517 return "_WeakProperty";
19482 } 19518 }
19483 19519
19484 19520
19485 void WeakProperty::PrintJSONImpl(JSONStream* stream, bool ref) const { 19521 void WeakProperty::PrintJSONImpl(JSONStream* stream, bool ref) const {
19486 JSONObject jsobj(stream); 19522 JSONObject jsobj(stream);
19523 AddTypeProperties(&jsobj, "Instance", JSONType(), ref);
19487 PrintSharedInstanceJSON(&jsobj, ref); 19524 PrintSharedInstanceJSON(&jsobj, ref);
19488 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); 19525 ObjectIdRing* ring = Isolate::Current()->object_id_ring();
19489 const intptr_t id = ring->GetIdForObject(raw()); 19526 const intptr_t id = ring->GetIdForObject(raw());
19490 jsobj.AddPropertyF("id", "objects/%" Pd "", id); 19527 jsobj.AddPropertyF("id", "objects/%" Pd "", id);
19491 19528
19492 if (ref) { 19529 if (ref) {
19493 return; 19530 return;
19494 } 19531 }
19495 19532
19496 const Object& key_handle = Object::Handle(key()); 19533 const Object& key_handle = Object::Handle(key());
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
19550 } 19587 }
19551 19588
19552 19589
19553 const char* MirrorReference::ToCString() const { 19590 const char* MirrorReference::ToCString() const {
19554 return "_MirrorReference"; 19591 return "_MirrorReference";
19555 } 19592 }
19556 19593
19557 19594
19558 void MirrorReference::PrintJSONImpl(JSONStream* stream, bool ref) const { 19595 void MirrorReference::PrintJSONImpl(JSONStream* stream, bool ref) const {
19559 JSONObject jsobj(stream); 19596 JSONObject jsobj(stream);
19597 AddTypeProperties(&jsobj, "Instance", JSONType(), ref);
19560 PrintSharedInstanceJSON(&jsobj, ref); 19598 PrintSharedInstanceJSON(&jsobj, ref);
19561 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); 19599 ObjectIdRing* ring = Isolate::Current()->object_id_ring();
19562 const intptr_t id = ring->GetIdForObject(raw()); 19600 const intptr_t id = ring->GetIdForObject(raw());
19563 jsobj.AddPropertyF("id", "objects/%" Pd "", id); 19601 jsobj.AddPropertyF("id", "objects/%" Pd "", id);
19564 19602
19565 if (ref) { 19603 if (ref) {
19566 return; 19604 return;
19567 } 19605 }
19568 19606
19569 const Object& referent_handle = Object::Handle(referent()); 19607 const Object& referent_handle = Object::Handle(referent());
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
19699 return tag_label.ToCString(); 19737 return tag_label.ToCString();
19700 } 19738 }
19701 19739
19702 19740
19703 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { 19741 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const {
19704 Instance::PrintJSONImpl(stream, ref); 19742 Instance::PrintJSONImpl(stream, ref);
19705 } 19743 }
19706 19744
19707 19745
19708 } // namespace dart 19746 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698