| 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 10250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10261 case RawLocalVarDescriptors::kSavedCurrentContext: | 10261 case RawLocalVarDescriptors::kSavedCurrentContext: |
| 10262 return "SavedCurrentCtx"; | 10262 return "SavedCurrentCtx"; |
| 10263 break; | 10263 break; |
| 10264 default: | 10264 default: |
| 10265 UNREACHABLE(); | 10265 UNREACHABLE(); |
| 10266 return "Unknown"; | 10266 return "Unknown"; |
| 10267 } | 10267 } |
| 10268 } | 10268 } |
| 10269 | 10269 |
| 10270 | 10270 |
| 10271 const char* LocalVarDescriptors::ToCString() const { | 10271 static int PrintVarInfo(char* buffer, int len, |
| 10272 intptr_t len = 1; // Trailing '\0'. | 10272 intptr_t i, |
| 10273 const char* kFormat = | 10273 const String& var_name, |
| 10274 "%2" Pd " %-13s scope=%-3d index=%-3" Pd "" | 10274 const RawLocalVarDescriptors::VarInfo& info) { |
| 10275 " begin=%-3" Pd " end=%-3" Pd " name=%s\n"; | 10275 if (info.kind == RawLocalVarDescriptors::kContextLevel) { |
| 10276 const char* kFormatCtxLevel = | 10276 return OS::SNPrint(buffer, len, |
| 10277 "%1$2" Pd " %2$-13s level=%4$-3" Pd " scope=%3$-3d" | 10277 "%2" Pd " %-13s level=%-3" Pd " scope=%-3d" |
| 10278 " begin=%5$-3" Pd " end=%6$" Pd "\n"; | 10278 " begin=%-3" Pd " end=%" Pd "\n", |
| 10279 const char* kFormatCtxVar = | 10279 i, |
| 10280 "%2" Pd " %-13s level=%-3d index=%-3" Pd "" | 10280 VarKindString(info.kind), |
| 10281 " begin=%-3" Pd " end=%-3" Pd " name=%s\n"; | 10281 info.index, |
| 10282 for (intptr_t i = 0; i < Length(); i++) { | 10282 info.scope_id, |
| 10283 String& var_name = String::Handle(GetName(i)); | 10283 info.begin_pos, |
| 10284 if (var_name.IsNull()) { | 10284 info.end_pos); |
| 10285 var_name = Symbols::Empty().raw(); | 10285 } else if (info.kind == RawLocalVarDescriptors::kContextVar) { |
| 10286 } | 10286 return OS::SNPrint(buffer, len, |
| 10287 RawLocalVarDescriptors::VarInfo info; | 10287 "%2" Pd " %-13s level=%-3d index=%-3" Pd "" |
| 10288 GetInfo(i, &info); | 10288 " begin=%-3" Pd " end=%-3" Pd " name=%s\n", |
| 10289 const char* format = kFormat; | |
| 10290 if (info.kind == RawLocalVarDescriptors::kContextLevel) { | |
| 10291 format = kFormatCtxLevel; | |
| 10292 } else if (info.kind == RawLocalVarDescriptors::kContextVar) { | |
| 10293 format = kFormatCtxVar; | |
| 10294 } | |
| 10295 len += OS::SNPrint(NULL, 0, | |
| 10296 format, | |
| 10297 i, | 10289 i, |
| 10298 VarKindString(info.kind), | 10290 VarKindString(info.kind), |
| 10299 info.scope_id, | 10291 info.scope_id, |
| 10292 info.index, |
| 10293 info.begin_pos, |
| 10294 info.end_pos, |
| 10295 var_name.ToCString()); |
| 10296 } else { |
| 10297 return OS::SNPrint(buffer, len, |
| 10298 "%2" Pd " %-13s scope=%-3d index=%-3" Pd "" |
| 10299 " begin=%-3" Pd " end=%-3" Pd " name=%s\n", |
| 10300 i, |
| 10301 VarKindString(info.kind), |
| 10302 info.scope_id, |
| 10300 info.index, | 10303 info.index, |
| 10301 info.begin_pos, | 10304 info.begin_pos, |
| 10302 info.end_pos, | 10305 info.end_pos, |
| 10303 var_name.ToCString()); | 10306 var_name.ToCString()); |
| 10304 } | 10307 } |
| 10308 } |
| 10309 |
| 10310 |
| 10311 const char* LocalVarDescriptors::ToCString() const { |
| 10312 intptr_t len = 1; // Trailing '\0'. |
| 10313 String& var_name = String::Handle(); |
| 10314 for (intptr_t i = 0; i < Length(); i++) { |
| 10315 RawLocalVarDescriptors::VarInfo info; |
| 10316 var_name = GetName(i); |
| 10317 if (var_name.IsNull()) { |
| 10318 var_name = Symbols::Empty().raw(); |
| 10319 } |
| 10320 GetInfo(i, &info); |
| 10321 len += PrintVarInfo(NULL, 0, i, var_name, info); |
| 10322 } |
| 10305 char* buffer = Isolate::Current()->current_zone()->Alloc<char>(len); | 10323 char* buffer = Isolate::Current()->current_zone()->Alloc<char>(len); |
| 10306 intptr_t num_chars = 0; | 10324 intptr_t num_chars = 0; |
| 10307 for (intptr_t i = 0; i < Length(); i++) { | 10325 for (intptr_t i = 0; i < Length(); i++) { |
| 10308 String& var_name = String::Handle(GetName(i)); | 10326 RawLocalVarDescriptors::VarInfo info; |
| 10327 var_name = GetName(i); |
| 10309 if (var_name.IsNull()) { | 10328 if (var_name.IsNull()) { |
| 10310 var_name = Symbols::Empty().raw(); | 10329 var_name = Symbols::Empty().raw(); |
| 10311 } | 10330 } |
| 10312 RawLocalVarDescriptors::VarInfo info; | |
| 10313 GetInfo(i, &info); | 10331 GetInfo(i, &info); |
| 10314 const char* format = kFormat; | 10332 num_chars += PrintVarInfo((buffer + num_chars), |
| 10315 if (info.kind == RawLocalVarDescriptors::kContextLevel) { | 10333 (len - num_chars), |
| 10316 format = kFormatCtxLevel; | 10334 i, var_name, info); |
| 10317 } else if (info.kind == RawLocalVarDescriptors::kContextVar) { | |
| 10318 format = kFormatCtxVar; | |
| 10319 } | |
| 10320 num_chars += OS::SNPrint((buffer + num_chars), | |
| 10321 (len - num_chars), | |
| 10322 format, | |
| 10323 i, | |
| 10324 VarKindString(info.kind), | |
| 10325 info.scope_id, | |
| 10326 info.index, | |
| 10327 info.begin_pos, | |
| 10328 info.end_pos, | |
| 10329 var_name.ToCString()); | |
| 10330 } | 10335 } |
| 10331 return buffer; | 10336 return buffer; |
| 10332 } | 10337 } |
| 10333 | 10338 |
| 10334 | 10339 |
| 10335 void LocalVarDescriptors::PrintJSONImpl(JSONStream* stream, | 10340 void LocalVarDescriptors::PrintJSONImpl(JSONStream* stream, |
| 10336 bool ref) const { | 10341 bool ref) const { |
| 10337 Object::PrintJSONImpl(stream, ref); | 10342 Object::PrintJSONImpl(stream, ref); |
| 10338 } | 10343 } |
| 10339 | 10344 |
| (...skipping 8375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 18715 return tag_label.ToCString(); | 18720 return tag_label.ToCString(); |
| 18716 } | 18721 } |
| 18717 | 18722 |
| 18718 | 18723 |
| 18719 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 18724 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 18720 Instance::PrintJSONImpl(stream, ref); | 18725 Instance::PrintJSONImpl(stream, ref); |
| 18721 } | 18726 } |
| 18722 | 18727 |
| 18723 | 18728 |
| 18724 } // namespace dart | 18729 } // namespace dart |
| OLD | NEW |