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 15083 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15094 | 15094 |
15095 | 15095 |
15096 void Type::set_type_state(int8_t state) const { | 15096 void Type::set_type_state(int8_t state) const { |
15097 ASSERT((state >= RawType::kAllocated) && | 15097 ASSERT((state >= RawType::kAllocated) && |
15098 (state <= RawType::kFinalizedUninstantiated)); | 15098 (state <= RawType::kFinalizedUninstantiated)); |
15099 StoreNonPointer(&raw_ptr()->type_state_, state); | 15099 StoreNonPointer(&raw_ptr()->type_state_, state); |
15100 } | 15100 } |
15101 | 15101 |
15102 | 15102 |
15103 const char* Type::ToCString() const { | 15103 const char* Type::ToCString() const { |
15104 if (IsResolved()) { | 15104 const char* unresolved = IsResolved() ? "" : "Unresolved "; |
15105 const TypeArguments& type_arguments = TypeArguments::Handle(arguments()); | 15105 const TypeArguments& type_arguments = TypeArguments::Handle(arguments()); |
15106 const char* class_name; | 15106 const char* class_name; |
15107 if (HasResolvedTypeClass()) { | 15107 if (HasResolvedTypeClass()) { |
15108 class_name = String::Handle( | 15108 class_name = String::Handle( |
15109 Class::Handle(type_class()).Name()).ToCString(); | 15109 Class::Handle(type_class()).Name()).ToCString(); |
15110 } else { | |
15111 class_name = UnresolvedClass::Handle(unresolved_class()).ToCString(); | |
15112 } | |
15113 if (type_arguments.IsNull()) { | |
15114 const char* format = "Type: class '%s'"; | |
15115 const intptr_t len = OS::SNPrint(NULL, 0, format, class_name) + 1; | |
15116 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | |
15117 OS::SNPrint(chars, len, format, class_name); | |
15118 return chars; | |
15119 } else if (IsFinalized() && IsRecursive()) { | |
15120 const char* format = "Type: (@%" Px " H%" Px ") class '%s', args:[%s]"; | |
15121 const intptr_t hash = Hash(); | |
15122 const char* args_cstr = TypeArguments::Handle(arguments()).ToCString(); | |
15123 const intptr_t len = | |
15124 OS::SNPrint(NULL, 0, format, raw(), hash, class_name, args_cstr) + 1; | |
15125 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | |
15126 OS::SNPrint(chars, len, format, raw(), hash, class_name, args_cstr); | |
15127 return chars; | |
15128 } else { | |
15129 const char* format = "Type: class '%s', args:[%s]"; | |
15130 const char* args_cstr = TypeArguments::Handle(arguments()).ToCString(); | |
15131 const intptr_t len = | |
15132 OS::SNPrint(NULL, 0, format, class_name, args_cstr) + 1; | |
15133 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | |
15134 OS::SNPrint(chars, len, format, class_name, args_cstr); | |
15135 return chars; | |
15136 } | |
15137 } else { | 15110 } else { |
15138 return "Unresolved Type"; | 15111 class_name = UnresolvedClass::Handle(unresolved_class()).ToCString(); |
| 15112 } |
| 15113 if (type_arguments.IsNull()) { |
| 15114 const char* format = "%sType: class '%s'"; |
| 15115 const intptr_t len = |
| 15116 OS::SNPrint(NULL, 0, format, unresolved, class_name) + 1; |
| 15117 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
| 15118 OS::SNPrint(chars, len, format, unresolved, class_name); |
| 15119 return chars; |
| 15120 } else if (IsResolved() && IsFinalized() && IsRecursive()) { |
| 15121 const char* format = "Type: (@%" Px " H%" Px ") class '%s', args:[%s]"; |
| 15122 const intptr_t hash = Hash(); |
| 15123 const char* args_cstr = TypeArguments::Handle(arguments()).ToCString(); |
| 15124 const intptr_t len = |
| 15125 OS::SNPrint(NULL, 0, format, raw(), hash, class_name, args_cstr) + 1; |
| 15126 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
| 15127 OS::SNPrint(chars, len, format, raw(), hash, class_name, args_cstr); |
| 15128 return chars; |
| 15129 } else { |
| 15130 const char* format = "%sType: class '%s', args:[%s]"; |
| 15131 const char* args_cstr = TypeArguments::Handle(arguments()).ToCString(); |
| 15132 const intptr_t len = |
| 15133 OS::SNPrint(NULL, 0, format, unresolved, class_name, args_cstr) + 1; |
| 15134 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
| 15135 OS::SNPrint(chars, len, format, unresolved, class_name, args_cstr); |
| 15136 return chars; |
15139 } | 15137 } |
15140 } | 15138 } |
15141 | 15139 |
15142 | 15140 |
15143 void Type::PrintJSONImpl(JSONStream* stream, bool ref) const { | 15141 void Type::PrintJSONImpl(JSONStream* stream, bool ref) const { |
15144 JSONObject jsobj(stream); | 15142 JSONObject jsobj(stream); |
15145 AddTypeProperties(&jsobj, "Type", JSONType(), ref); | 15143 AddTypeProperties(&jsobj, "Type", JSONType(), ref); |
15146 PrintSharedInstanceJSON(&jsobj, ref); | 15144 PrintSharedInstanceJSON(&jsobj, ref); |
15147 if (IsCanonical()) { | 15145 if (IsCanonical()) { |
15148 const Class& type_cls = Class::Handle(type_class()); | 15146 const Class& type_cls = Class::Handle(type_class()); |
(...skipping 5577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
20726 return tag_label.ToCString(); | 20724 return tag_label.ToCString(); |
20727 } | 20725 } |
20728 | 20726 |
20729 | 20727 |
20730 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 20728 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { |
20731 Instance::PrintJSONImpl(stream, ref); | 20729 Instance::PrintJSONImpl(stream, ref); |
20732 } | 20730 } |
20733 | 20731 |
20734 | 20732 |
20735 } // namespace dart | 20733 } // namespace dart |
OLD | NEW |