| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/object.h" | 5 #include "vm/object.h" |
| 6 | 6 |
| 7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
| 8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
| 9 #include "vm/assembler.h" | 9 #include "vm/assembler.h" |
| 10 #include "vm/cpu.h" | 10 #include "vm/cpu.h" |
| (...skipping 2908 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2919 const char* library_name = lib.IsNull() ? "" : lib.ToCString(); | 2919 const char* library_name = lib.IsNull() ? "" : lib.ToCString(); |
| 2920 const char* class_name = String::Handle(Name()).ToCString(); | 2920 const char* class_name = String::Handle(Name()).ToCString(); |
| 2921 intptr_t len = OS::SNPrint(NULL, 0, format, library_name, class_name) + 1; | 2921 intptr_t len = OS::SNPrint(NULL, 0, format, library_name, class_name) + 1; |
| 2922 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 2922 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
| 2923 OS::SNPrint(chars, len, format, library_name, class_name); | 2923 OS::SNPrint(chars, len, format, library_name, class_name); |
| 2924 return chars; | 2924 return chars; |
| 2925 } | 2925 } |
| 2926 | 2926 |
| 2927 | 2927 |
| 2928 void Class::PrintToJSONStream(JSONStream* stream, bool ref) const { | 2928 void Class::PrintToJSONStream(JSONStream* stream, bool ref) const { |
| 2929 const char* class_name = String::Handle(UserVisibleName()).ToCString(); | |
| 2930 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); | |
| 2931 intptr_t id = ring->GetIdForObject(raw()); | |
| 2932 JSONObject jsobj(stream); | 2929 JSONObject jsobj(stream); |
| 2930 if ((raw() == Class::null()) || (id() == kFreeListElement)) { |
| 2931 jsobj.AddProperty("type", "Null"); |
| 2932 return; |
| 2933 } |
| 2934 const char* internal_class_name = String::Handle(Name()).ToCString(); |
| 2935 const char* user_visible_class_name = |
| 2936 String::Handle(UserVisibleName()).ToCString(); |
| 2933 jsobj.AddProperty("type", JSONType(ref)); | 2937 jsobj.AddProperty("type", JSONType(ref)); |
| 2934 jsobj.AddProperty("id", id); | 2938 jsobj.AddProperty("id", id()); |
| 2935 jsobj.AddProperty("name", class_name); | 2939 jsobj.AddProperty("name", internal_class_name); |
| 2940 jsobj.AddProperty("user_name", user_visible_class_name); |
| 2936 if (!ref) { | 2941 if (!ref) { |
| 2942 jsobj.AddProperty("implemented", is_implemented()); |
| 2943 jsobj.AddProperty("abstract", is_abstract()); |
| 2944 jsobj.AddProperty("patch", is_patch()); |
| 2945 jsobj.AddProperty("finalized", is_finalized()); |
| 2946 jsobj.AddProperty("const", is_const()); |
| 2947 jsobj.AddProperty("super", Class::Handle(SuperClass())); |
| 2937 jsobj.AddProperty("library", Object::Handle(library())); | 2948 jsobj.AddProperty("library", Object::Handle(library())); |
| 2949 { |
| 2950 JSONArray fields_array(&jsobj, "fields"); |
| 2951 const Array& field_array = Array::Handle(fields()); |
| 2952 Field& field = Field::Handle(); |
| 2953 if (!field_array.IsNull()) { |
| 2954 for (intptr_t i = 0; i < field_array.Length(); ++i) { |
| 2955 field ^= field_array.At(i); |
| 2956 fields_array.AddValue(field); |
| 2957 } |
| 2958 } |
| 2959 } |
| 2960 { |
| 2961 JSONArray functions_array(&jsobj, "functions"); |
| 2962 const Array& function_array = Array::Handle(functions()); |
| 2963 Function& function = Function::Handle(); |
| 2964 if (!function_array.IsNull()) { |
| 2965 for (intptr_t i = 0; i < function_array.Length(); i++) { |
| 2966 function ^= function_array.At(i); |
| 2967 functions_array.AddValue(function); |
| 2968 } |
| 2969 } |
| 2970 } |
| 2938 } | 2971 } |
| 2939 } | 2972 } |
| 2940 | 2973 |
| 2941 | 2974 |
| 2942 void Class::InsertCanonicalConstant(intptr_t index, | 2975 void Class::InsertCanonicalConstant(intptr_t index, |
| 2943 const Instance& constant) const { | 2976 const Instance& constant) const { |
| 2944 // The constant needs to be added to the list. Grow the list if it is full. | 2977 // The constant needs to be added to the list. Grow the list if it is full. |
| 2945 Array& canonical_list = Array::Handle(constants()); | 2978 Array& canonical_list = Array::Handle(constants()); |
| 2946 const intptr_t list_len = canonical_list.Length(); | 2979 const intptr_t list_len = canonical_list.Length(); |
| 2947 if (index >= list_len) { | 2980 if (index >= list_len) { |
| (...skipping 2135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5083 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, | 5116 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, |
| 5084 static_str, abstract_str, kind_str, const_str) + 1; | 5117 static_str, abstract_str, kind_str, const_str) + 1; |
| 5085 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 5118 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
| 5086 OS::SNPrint(chars, len, kFormat, function_name, | 5119 OS::SNPrint(chars, len, kFormat, function_name, |
| 5087 static_str, abstract_str, kind_str, const_str); | 5120 static_str, abstract_str, kind_str, const_str); |
| 5088 return chars; | 5121 return chars; |
| 5089 } | 5122 } |
| 5090 | 5123 |
| 5091 | 5124 |
| 5092 void Function::PrintToJSONStream(JSONStream* stream, bool ref) const { | 5125 void Function::PrintToJSONStream(JSONStream* stream, bool ref) const { |
| 5126 const char* internal_function_name = String::Handle(name()).ToCString(); |
| 5093 const char* function_name = | 5127 const char* function_name = |
| 5094 String::Handle(QualifiedUserVisibleName()).ToCString(); | 5128 String::Handle(QualifiedUserVisibleName()).ToCString(); |
| 5095 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); | 5129 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); |
| 5096 intptr_t id = ring->GetIdForObject(raw()); | 5130 intptr_t id = ring->GetIdForObject(raw()); |
| 5097 JSONObject jsobj(stream); | 5131 JSONObject jsobj(stream); |
| 5098 jsobj.AddProperty("type", JSONType(ref)); | 5132 jsobj.AddProperty("type", JSONType(ref)); |
| 5099 jsobj.AddProperty("id", id); | 5133 jsobj.AddProperty("id", id); |
| 5100 jsobj.AddProperty("name", function_name); | 5134 jsobj.AddProperty("name", internal_function_name); |
| 5135 jsobj.AddProperty("user_name", function_name); |
| 5101 if (ref) return; | 5136 if (ref) return; |
| 5102 jsobj.AddProperty("is_static", is_static()); | 5137 jsobj.AddProperty("is_static", is_static()); |
| 5103 jsobj.AddProperty("is_const", is_const()); | 5138 jsobj.AddProperty("is_const", is_const()); |
| 5104 jsobj.AddProperty("is_optimizable", is_optimizable()); | 5139 jsobj.AddProperty("is_optimizable", is_optimizable()); |
| 5105 jsobj.AddProperty("is_inlinable", IsInlineable()); | 5140 jsobj.AddProperty("is_inlinable", IsInlineable()); |
| 5106 const char* kind_string = NULL; | 5141 const char* kind_string = NULL; |
| 5107 switch (kind()) { | 5142 switch (kind()) { |
| 5108 case RawFunction::kRegularFunction: | 5143 case RawFunction::kRegularFunction: |
| 5109 kind_string = "regular"; | 5144 kind_string = "regular"; |
| 5110 break; | 5145 break; |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5405 intptr_t len = | 5440 intptr_t len = |
| 5406 OS::SNPrint(NULL, 0, kFormat, cls_name, field_name, kF0, kF1, kF2) + 1; | 5441 OS::SNPrint(NULL, 0, kFormat, cls_name, field_name, kF0, kF1, kF2) + 1; |
| 5407 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 5442 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
| 5408 OS::SNPrint(chars, len, kFormat, cls_name, field_name, kF0, kF1, kF2); | 5443 OS::SNPrint(chars, len, kFormat, cls_name, field_name, kF0, kF1, kF2); |
| 5409 return chars; | 5444 return chars; |
| 5410 } | 5445 } |
| 5411 | 5446 |
| 5412 | 5447 |
| 5413 void Field::PrintToJSONStream(JSONStream* stream, bool ref) const { | 5448 void Field::PrintToJSONStream(JSONStream* stream, bool ref) const { |
| 5414 JSONObject jsobj(stream); | 5449 JSONObject jsobj(stream); |
| 5450 const char* internal_field_name = String::Handle(name()).ToCString(); |
| 5451 const char* field_name = String::Handle(UserVisibleName()).ToCString(); |
| 5452 ObjectIdRing* ring = Isolate::Current()->object_id_ring(); |
| 5453 intptr_t id = ring->GetIdForObject(raw()); |
| 5454 jsobj.AddProperty("type", JSONType(ref)); |
| 5455 jsobj.AddProperty("id", id); |
| 5456 jsobj.AddProperty("name", internal_field_name); |
| 5457 jsobj.AddProperty("user_name", field_name); |
| 5458 if (ref) { |
| 5459 return; |
| 5460 } |
| 5461 Class& cls = Class::Handle(owner()); |
| 5462 jsobj.AddProperty("type", "Field"); |
| 5463 jsobj.AddProperty("id", id); |
| 5464 jsobj.AddProperty("name", internal_field_name); |
| 5465 jsobj.AddProperty("user_name", field_name); |
| 5466 jsobj.AddProperty("class", cls); |
| 5467 jsobj.AddProperty("static", is_static()); |
| 5468 jsobj.AddProperty("final", is_final()); |
| 5469 jsobj.AddProperty("const", is_const()); |
| 5470 jsobj.AddProperty("guard_nullable", is_nullable()); |
| 5471 if (guarded_cid() == kIllegalCid) { |
| 5472 jsobj.AddProperty("guard_class", "unknown"); |
| 5473 } else if (guarded_cid() == kDynamicCid) { |
| 5474 jsobj.AddProperty("guard_class", "dynamic"); |
| 5475 } else { |
| 5476 ClassTable* table = Isolate::Current()->class_table(); |
| 5477 ASSERT(table->IsValidIndex(guarded_cid())); |
| 5478 cls ^= table->At(guarded_cid()); |
| 5479 jsobj.AddProperty("guard_class", cls); |
| 5480 } |
| 5481 if (guarded_list_length() == kUnknownFixedLength) { |
| 5482 jsobj.AddProperty("guard_length", "unknown"); |
| 5483 } else if (guarded_list_length() == kNoFixedLength) { |
| 5484 jsobj.AddProperty("guard_length", "variable"); |
| 5485 } else { |
| 5486 jsobj.AddProperty("guard_length", guarded_list_length()); |
| 5487 } |
| 5415 } | 5488 } |
| 5416 | 5489 |
| 5417 | 5490 |
| 5418 RawArray* Field::dependent_code() const { | 5491 RawArray* Field::dependent_code() const { |
| 5419 return raw_ptr()->dependent_code_; | 5492 return raw_ptr()->dependent_code_; |
| 5420 } | 5493 } |
| 5421 | 5494 |
| 5422 | 5495 |
| 5423 void Field::set_dependent_code(const Array& array) const { | 5496 void Field::set_dependent_code(const Array& array) const { |
| 5424 raw_ptr()->dependent_code_ = array.raw(); | 5497 raw_ptr()->dependent_code_ = array.raw(); |
| (...skipping 9512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14937 return "_MirrorReference"; | 15010 return "_MirrorReference"; |
| 14938 } | 15011 } |
| 14939 | 15012 |
| 14940 | 15013 |
| 14941 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { | 15014 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { |
| 14942 JSONObject jsobj(stream); | 15015 JSONObject jsobj(stream); |
| 14943 } | 15016 } |
| 14944 | 15017 |
| 14945 | 15018 |
| 14946 } // namespace dart | 15019 } // namespace dart |
| OLD | NEW |