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

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

Issue 10854224: Sort the Dart vm flags before printing them out with the --print-flags option. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 4 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/flags.h ('k') | no next file » | 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) 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/flags.h" 5 #include "vm/flags.h"
6 6
7 #include "platform/assert.h" 7 #include "platform/assert.h"
8 #include "vm/os.h" 8 #include "vm/os.h"
9 9
10 namespace dart { 10 namespace dart {
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 unrecognized_count++; 294 unrecognized_count++;
295 } 295 }
296 flag = flag->next_; 296 flag = flag->next_;
297 } 297 }
298 if (unrecognized_count > 0) { 298 if (unrecognized_count > 0) {
299 OS::PrintErr("\n"); 299 OS::PrintErr("\n");
300 exit(255); 300 exit(255);
301 } 301 }
302 } 302 }
303 if (FLAG_print_flags) { 303 if (FLAG_print_flags) {
304 OS::Print("Flag settings:\n"); 304 PrintFlags();
305 Flag* flag = Flags::flags_;
306 while (flag != NULL) {
307 flag->Print();
308 flag = flag->next_;
309 }
310 } 305 }
311
312 return true; 306 return true;
313 } 307 }
314 308
309
310 int Flags::CompareFlagNames(const void* left, const void* right) {
311 const Flag* left_flag = *reinterpret_cast<const Flag* const *>(left);
312 const Flag* right_flag = *reinterpret_cast<const Flag* const *>(right);
313 return strcmp(left_flag->name_, right_flag->name_);
314 }
315
316
317 void Flags::PrintFlags() {
318 OS::Print("Flag settings:\n");
319 Flag* flag = Flags::flags_;
320 int num_flags = 0;
321 while (flag != NULL) {
322 num_flags++;
Ivan Posva 2012/08/20 23:50:35 You could increment this as part of registration o
323 flag = flag->next_;
324 }
325 Flag** flag_array = new Flag*[num_flags];
326 flag = Flags::flags_;
327 int flag_index = 0;
328 while (flag != NULL) {
Ivan Posva 2012/08/20 23:50:35 for (int i = 0; i < num_flags; i++) { ASSERT(fl
Bill Hesse 2012/08/21 09:21:02 Done.
329 flag_array[flag_index] = flag;
330 flag_index++;
331 flag = flag->next_;
332 }
333
334 qsort(flag_array, num_flags, sizeof flag_array[0], CompareFlagNames);
335
336 for (int i = 0; i < num_flags; ++i) {
337 flag_array[i]->Print();
338 }
339 delete[] flag_array;
340 }
315 } // namespace dart 341 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/flags.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698