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

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

Issue 13483009: Fix http://dartbug.com/9137 : (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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 | « no previous file | 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 cur = cur->next_; 95 cur = cur->next_;
96 } 96 }
97 return NULL; 97 return NULL;
98 } 98 }
99 99
100 100
101 bool Flags::Register_bool(bool* addr, 101 bool Flags::Register_bool(bool* addr,
102 const char* name, 102 const char* name,
103 bool default_value, 103 bool default_value,
104 const char* comment) { 104 const char* comment) {
105 ASSERT(Lookup(name) == NULL); 105 Flag* flag = Lookup(name);
106 106 if (flag != NULL) {
107 Flag* flag = new Flag(name, comment, addr, Flag::kBoolean); 107 ASSERT(flag->IsUnrecognized());
108 return default_value;
siva 2013/04/05 07:14:28 nobody seems to use the return value from this fun
Ivan Posva 2013/04/22 12:59:27 It is used in flags.h: #define DEFINE_FLAG(type,
109 }
110 flag = new Flag(name, comment, addr, Flag::kBoolean);
108 flag->next_ = Flags::flags_; 111 flag->next_ = Flags::flags_;
109 Flags::flags_ = flag; 112 Flags::flags_ = flag;
110 113
111 return default_value; 114 return default_value;
112 } 115 }
113 116
114 117
115 int Flags::Register_int(int* addr, 118 int Flags::Register_int(int* addr,
116 const char* name, 119 const char* name,
117 int default_value, 120 int default_value,
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 intptr_t name_len = equals - option; 197 intptr_t name_len = equals - option;
195 char* name = new char[name_len + 1]; 198 char* name = new char[name_len + 1];
196 strncpy(name, option, name_len); 199 strncpy(name, option, name_len);
197 name[name_len] = '\0'; 200 name[name_len] = '\0';
198 Normalize(name); 201 Normalize(name);
199 202
200 Flag* flag = Flags::Lookup(name); 203 Flag* flag = Flags::Lookup(name);
201 if (flag == NULL) { 204 if (flag == NULL) {
202 // Collect unrecognized flags. 205 // Collect unrecognized flags.
203 char* new_flag = new char[name_len + 1]; 206 char* new_flag = new char[name_len + 1];
204 strncpy(new_flag, name, name_len); 207 strncpy(new_flag, option, name_len);
205 new_flag[name_len] = '\0'; 208 new_flag[name_len] = '\0';
206 Flags::Register_bool(NULL, new_flag, true, NULL); 209 Flags::Register_bool(NULL, new_flag, true, NULL);
207 } else { 210 } else {
208 // Only set values for recognized flags, skip collected 211 // Only set values for recognized flags, skip collected
209 // unrecognized flags. 212 // unrecognized flags.
210 if (!flag->IsUnrecognized()) { 213 if (!flag->IsUnrecognized()) {
211 switch (flag->type_) { 214 switch (flag->type_) {
212 case Flag::kBoolean: { 215 case Flag::kBoolean: {
213 if (strcmp(argument, "true") == 0) { 216 if (strcmp(argument, "true") == 0) {
214 *flag->bool_ptr_ = true; 217 *flag->bool_ptr_ = true;
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 } 332 }
330 333
331 qsort(flag_array, num_flags, sizeof flag_array[0], CompareFlagNames); 334 qsort(flag_array, num_flags, sizeof flag_array[0], CompareFlagNames);
332 335
333 for (int i = 0; i < num_flags; ++i) { 336 for (int i = 0; i < num_flags; ++i) {
334 flag_array[i]->Print(); 337 flag_array[i]->Print();
335 } 338 }
336 delete[] flag_array; 339 delete[] flag_array;
337 } 340 }
338 } // namespace dart 341 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698