Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(121)

Side by Side Diff: runtime/vm/json_stream.cc

Issue 217323006: Redo allocationprofile options (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/json_stream.h ('k') | runtime/vm/json_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 const char* JSONStream::LookupOption(const char* key) const { 132 const char* JSONStream::LookupOption(const char* key) const {
133 for (int i = 0; i < num_options(); i++) { 133 for (int i = 0; i < num_options(); i++) {
134 if (!strcmp(key, option_keys_[i])) { 134 if (!strcmp(key, option_keys_[i])) {
135 return option_values_[i]; 135 return option_values_[i];
136 } 136 }
137 } 137 }
138 return NULL; 138 return NULL;
139 } 139 }
140 140
141 141
142 bool JSONStream::HasOption(const char* key) const {
143 ASSERT(key);
144 return LookupOption(key) != NULL;
145 }
146
147
148 bool JSONStream::OptionIs(const char* key, const char* value) const {
149 ASSERT(key);
150 ASSERT(value);
151 const char* key_value = LookupOption(key);
152 return (key_value != NULL) && (strcmp(key_value, value) == 0);
153 }
154
155
142 void JSONStream::Clear() { 156 void JSONStream::Clear() {
143 buffer_.Clear(); 157 buffer_.Clear();
144 open_objects_ = 0; 158 open_objects_ = 0;
145 } 159 }
146 160
147 161
148 void JSONStream::OpenObject(const char* property_name) { 162 void JSONStream::OpenObject(const char* property_name) {
149 PrintCommaIfNeeded(); 163 PrintCommaIfNeeded();
150 open_objects_++; 164 open_objects_++;
151 if (property_name != NULL) { 165 if (property_name != NULL) {
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 free(p); 309 free(p);
296 } 310 }
297 311
298 312
299 void JSONStream::set_reply_port(Dart_Port port) { 313 void JSONStream::set_reply_port(Dart_Port port) {
300 reply_port_ = port; 314 reply_port_ = port;
301 } 315 }
302 316
303 317
304 void JSONStream::SetArguments(const char** arguments, intptr_t num_arguments) { 318 void JSONStream::SetArguments(const char** arguments, intptr_t num_arguments) {
319 if (num_arguments > 0) {
320 // Set command.
321 command_ = arguments[0];
322 }
305 arguments_ = arguments; 323 arguments_ = arguments;
306 num_arguments_ = num_arguments; 324 num_arguments_ = num_arguments;
307 } 325 }
308 326
309 327
310 void JSONStream::SetOptions(const char** option_keys, 328 void JSONStream::SetOptions(const char** option_keys,
311 const char** option_values, 329 const char** option_values,
312 intptr_t num_options) { 330 intptr_t num_options) {
313 option_keys_ = option_keys; 331 option_keys_ = option_keys;
314 option_values_ = option_values; 332 option_values_ = option_values;
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 intptr_t len2 = OS::VSNPrint(p, len+1, format, args); 420 intptr_t len2 = OS::VSNPrint(p, len+1, format, args);
403 va_end(args); 421 va_end(args);
404 ASSERT(len == len2); 422 ASSERT(len == len2);
405 stream_->buffer_.AddChar('"'); 423 stream_->buffer_.AddChar('"');
406 stream_->AddEscapedUTF8String(p); 424 stream_->AddEscapedUTF8String(p);
407 stream_->buffer_.AddChar('"'); 425 stream_->buffer_.AddChar('"');
408 free(p); 426 free(p);
409 } 427 }
410 428
411 } // namespace dart 429 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/json_stream.h ('k') | runtime/vm/json_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698