| 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 10139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10150 *info = raw_ptr()->data_[var_index]; | 10150 *info = raw_ptr()->data_[var_index]; |
| 10151 } | 10151 } |
| 10152 | 10152 |
| 10153 | 10153 |
| 10154 const char* LocalVarDescriptors::ToCString() const { | 10154 const char* LocalVarDescriptors::ToCString() const { |
| 10155 intptr_t len = 1; // Trailing '\0'. | 10155 intptr_t len = 1; // Trailing '\0'. |
| 10156 const char* kFormat = | 10156 const char* kFormat = |
| 10157 "%2" Pd " kind=%d scope=0x%04x begin=%" Pd " end=%" Pd " name=%s\n"; | 10157 "%2" Pd " kind=%d scope=0x%04x begin=%" Pd " end=%" Pd " name=%s\n"; |
| 10158 for (intptr_t i = 0; i < Length(); i++) { | 10158 for (intptr_t i = 0; i < Length(); i++) { |
| 10159 String& var_name = String::Handle(GetName(i)); | 10159 String& var_name = String::Handle(GetName(i)); |
| 10160 if (var_name.IsNull()) { |
| 10161 var_name = Symbols::Empty().raw(); |
| 10162 } |
| 10160 RawLocalVarDescriptors::VarInfo info; | 10163 RawLocalVarDescriptors::VarInfo info; |
| 10161 GetInfo(i, &info); | 10164 GetInfo(i, &info); |
| 10162 len += OS::SNPrint(NULL, 0, kFormat, | 10165 len += OS::SNPrint(NULL, 0, kFormat, |
| 10163 i, | 10166 i, |
| 10164 info.kind, | 10167 info.kind, |
| 10165 info.scope_id, | 10168 info.scope_id, |
| 10166 info.begin_pos, | 10169 info.begin_pos, |
| 10167 info.end_pos, | 10170 info.end_pos, |
| 10168 var_name.ToCString()); | 10171 var_name.ToCString()); |
| 10169 } | 10172 } |
| 10170 char* buffer = Isolate::Current()->current_zone()->Alloc<char>(len); | 10173 char* buffer = Isolate::Current()->current_zone()->Alloc<char>(len); |
| 10171 intptr_t num_chars = 0; | 10174 intptr_t num_chars = 0; |
| 10172 for (intptr_t i = 0; i < Length(); i++) { | 10175 for (intptr_t i = 0; i < Length(); i++) { |
| 10173 String& var_name = String::Handle(GetName(i)); | 10176 String& var_name = String::Handle(GetName(i)); |
| 10177 if (var_name.IsNull()) { |
| 10178 var_name = Symbols::Empty().raw(); |
| 10179 } |
| 10174 RawLocalVarDescriptors::VarInfo info; | 10180 RawLocalVarDescriptors::VarInfo info; |
| 10175 GetInfo(i, &info); | 10181 GetInfo(i, &info); |
| 10176 num_chars += OS::SNPrint((buffer + num_chars), | 10182 num_chars += OS::SNPrint((buffer + num_chars), |
| 10177 (len - num_chars), | 10183 (len - num_chars), |
| 10178 kFormat, | 10184 kFormat, |
| 10179 i, | 10185 i, |
| 10180 info.kind, | 10186 info.kind, |
| 10181 info.scope_id, | 10187 info.scope_id, |
| 10182 info.begin_pos, | 10188 info.begin_pos, |
| 10183 info.end_pos, | 10189 info.end_pos, |
| (...skipping 977 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11161 } | 11167 } |
| 11162 result.set_isolate(Isolate::Current()); | 11168 result.set_isolate(Isolate::Current()); |
| 11163 return result.raw(); | 11169 return result.raw(); |
| 11164 } | 11170 } |
| 11165 | 11171 |
| 11166 | 11172 |
| 11167 const char* Context::ToCString() const { | 11173 const char* Context::ToCString() const { |
| 11168 if (IsNull()) { | 11174 if (IsNull()) { |
| 11169 return "Context (Null)"; | 11175 return "Context (Null)"; |
| 11170 } | 11176 } |
| 11177 Zone* zone = Isolate::Current()->current_zone(); |
| 11171 const Context& parent_ctx = Context::Handle(parent()); | 11178 const Context& parent_ctx = Context::Handle(parent()); |
| 11172 if (parent_ctx.IsNull()) { | 11179 if (parent_ctx.IsNull()) { |
| 11173 const char* kFormat = "Context num_variables:% " Pd ""; | 11180 return zone->PrintToString("Context@%p num_variables:% " Pd "", |
| 11174 intptr_t len = OS::SNPrint(NULL, 0, kFormat, num_variables()) + 1; | 11181 this->raw(), num_variables()); |
| 11175 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | |
| 11176 OS::SNPrint(chars, len, kFormat, num_variables()); | |
| 11177 return chars; | |
| 11178 } else { | 11182 } else { |
| 11179 const char* parent_str = parent_ctx.ToCString(); | 11183 const char* parent_str = parent_ctx.ToCString(); |
| 11180 const char* kFormat = "Context num_variables:% " Pd " parent:{ %s }"; | 11184 return zone->PrintToString( |
| 11181 intptr_t len = OS::SNPrint(NULL, 0, kFormat, | 11185 "Context@%p num_variables:% " Pd " parent:{ %s }", |
| 11182 num_variables(), parent_str) + 1; | 11186 this->raw(), num_variables(), parent_str); |
| 11183 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | |
| 11184 OS::SNPrint(chars, len, kFormat, num_variables(), parent_str); | |
| 11185 return chars; | |
| 11186 } | 11187 } |
| 11187 } | 11188 } |
| 11188 | 11189 |
| 11189 | 11190 |
| 11191 static void IndentN(int count) { |
| 11192 for (int i = 0; i < count; i++) { |
| 11193 OS::PrintErr(" "); |
| 11194 } |
| 11195 } |
| 11196 |
| 11197 |
| 11198 void Context::Dump(int indent) const { |
| 11199 if (IsNull()) { |
| 11200 IndentN(indent); |
| 11201 OS::PrintErr("Context@null\n"); |
| 11202 return; |
| 11203 } |
| 11204 |
| 11205 IndentN(indent); |
| 11206 OS::PrintErr("Context@%p vars(%" Pd ") {\n", this->raw(), num_variables()); |
| 11207 Object& obj = Object::Handle(); |
| 11208 for (intptr_t i = 0; i < num_variables(); i++) { |
| 11209 IndentN(indent + 2); |
| 11210 obj = At(i); |
| 11211 OS::PrintErr("[%" Pd "] = %s\n", i, obj.ToCString()); |
| 11212 } |
| 11213 |
| 11214 const Context& parent_ctx = Context::Handle(parent()); |
| 11215 if (!parent_ctx.IsNull()) { |
| 11216 parent_ctx.Dump(indent + 2); |
| 11217 } |
| 11218 IndentN(indent); |
| 11219 OS::PrintErr("}\n"); |
| 11220 } |
| 11221 |
| 11222 |
| 11190 void Context::PrintToJSONStream(JSONStream* stream, bool ref) const { | 11223 void Context::PrintToJSONStream(JSONStream* stream, bool ref) const { |
| 11191 Object::PrintToJSONStream(stream, ref); | 11224 Object::PrintToJSONStream(stream, ref); |
| 11192 } | 11225 } |
| 11193 | 11226 |
| 11194 | 11227 |
| 11195 RawContextScope* ContextScope::New(intptr_t num_variables) { | 11228 RawContextScope* ContextScope::New(intptr_t num_variables) { |
| 11196 ASSERT(Object::context_scope_class() != Class::null()); | 11229 ASSERT(Object::context_scope_class() != Class::null()); |
| 11197 if (num_variables < 0 || num_variables > kMaxElements) { | 11230 if (num_variables < 0 || num_variables > kMaxElements) { |
| 11198 // This should be caught before we reach here. | 11231 // This should be caught before we reach here. |
| 11199 FATAL1("Fatal error in ContextScope::New: invalid num_variables %" Pd "\n", | 11232 FATAL1("Fatal error in ContextScope::New: invalid num_variables %" Pd "\n", |
| (...skipping 7060 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 18260 return "_MirrorReference"; | 18293 return "_MirrorReference"; |
| 18261 } | 18294 } |
| 18262 | 18295 |
| 18263 | 18296 |
| 18264 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { | 18297 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { |
| 18265 Instance::PrintToJSONStream(stream, ref); | 18298 Instance::PrintToJSONStream(stream, ref); |
| 18266 } | 18299 } |
| 18267 | 18300 |
| 18268 | 18301 |
| 18269 } // namespace dart | 18302 } // namespace dart |
| OLD | NEW |