| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 "platform/assert.h" | 5 #include "platform/assert.h" |
| 6 | 6 |
| 7 #include "vm/dart_entry.h" | 7 #include "vm/dart_entry.h" |
| 8 #include "vm/debugger.h" | 8 #include "vm/debugger.h" |
| 9 #include "vm/json_stream.h" | 9 #include "vm/json_stream.h" |
| 10 #include "vm/message.h" | 10 #include "vm/message.h" |
| 11 #include "vm/metrics.h" | 11 #include "vm/metrics.h" |
| 12 #include "vm/object.h" | 12 #include "vm/object.h" |
| 13 #include "vm/service_event.h" | 13 #include "vm/service_event.h" |
| 14 #include "vm/service.h" |
| 14 #include "vm/unicode.h" | 15 #include "vm/unicode.h" |
| 15 | 16 |
| 16 | 17 |
| 17 namespace dart { | 18 namespace dart { |
| 18 | 19 |
| 19 DECLARE_FLAG(bool, trace_service); | 20 DECLARE_FLAG(bool, trace_service); |
| 20 | 21 |
| 21 JSONStream::JSONStream(intptr_t buf_size) | 22 JSONStream::JSONStream(intptr_t buf_size) |
| 22 : open_objects_(0), | 23 : open_objects_(0), |
| 23 buffer_(buf_size), | 24 buffer_(buf_size), |
| 25 ring_service_id_zone_(ObjectIdRing::kNewId), |
| 26 service_id_zone_(&ring_service_id_zone_), |
| 24 reply_port_(ILLEGAL_PORT), | 27 reply_port_(ILLEGAL_PORT), |
| 25 seq_(""), | 28 seq_(""), |
| 26 method_(""), | 29 method_(""), |
| 27 param_keys_(NULL), | 30 param_keys_(NULL), |
| 28 param_values_(NULL), | 31 param_values_(NULL), |
| 29 num_params_(0) { | 32 num_params_(0) { |
| 30 } | 33 } |
| 31 | 34 |
| 32 | 35 |
| 33 JSONStream::~JSONStream() { | 36 JSONStream::~JSONStream() { |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 queue->PrintJSON(this); | 281 queue->PrintJSON(this); |
| 279 } | 282 } |
| 280 | 283 |
| 281 | 284 |
| 282 void JSONStream::PrintValue(Isolate* isolate, bool ref) { | 285 void JSONStream::PrintValue(Isolate* isolate, bool ref) { |
| 283 PrintCommaIfNeeded(); | 286 PrintCommaIfNeeded(); |
| 284 isolate->PrintJSON(this, ref); | 287 isolate->PrintJSON(this, ref); |
| 285 } | 288 } |
| 286 | 289 |
| 287 | 290 |
| 291 void JSONStream::PrintServiceId(const char* name, const Object& o) { |
| 292 ASSERT(service_id_zone_ != NULL); |
| 293 PrintProperty(name, service_id_zone_->GetServiceId(o)); |
| 294 } |
| 295 |
| 296 |
| 288 void JSONStream::PrintPropertyBool(const char* name, bool b) { | 297 void JSONStream::PrintPropertyBool(const char* name, bool b) { |
| 289 PrintPropertyName(name); | 298 PrintPropertyName(name); |
| 290 PrintValueBool(b); | 299 PrintValueBool(b); |
| 291 } | 300 } |
| 292 | 301 |
| 293 | 302 |
| 294 void JSONStream::PrintProperty(const char* name, intptr_t i) { | 303 void JSONStream::PrintProperty(const char* name, intptr_t i) { |
| 295 ASSERT(Utils::IsJavascriptInt(i)); | 304 ASSERT(Utils::IsJavascriptInt(i)); |
| 296 PrintPropertyName(name); | 305 PrintPropertyName(name); |
| 297 PrintValue(i); | 306 PrintValue(i); |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 510 intptr_t len2 = OS::VSNPrint(p, len+1, format, args); | 519 intptr_t len2 = OS::VSNPrint(p, len+1, format, args); |
| 511 va_end(args); | 520 va_end(args); |
| 512 ASSERT(len == len2); | 521 ASSERT(len == len2); |
| 513 stream_->buffer_.AddChar('"'); | 522 stream_->buffer_.AddChar('"'); |
| 514 stream_->AddEscapedUTF8String(p); | 523 stream_->AddEscapedUTF8String(p); |
| 515 stream_->buffer_.AddChar('"'); | 524 stream_->buffer_.AddChar('"'); |
| 516 free(p); | 525 free(p); |
| 517 } | 526 } |
| 518 | 527 |
| 519 } // namespace dart | 528 } // namespace dart |
| OLD | NEW |