| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 "vm/assert.h" | 7 #include "vm/assert.h" |
| 8 #include "vm/os.h" | 8 #include "vm/os.h" |
| 9 | 9 |
| 10 namespace dart { | 10 namespace dart { |
| 11 | 11 |
| 12 DEFINE_FLAG(bool, print_flags, false, "Print flags as they are being parsed."); | 12 DEFINE_FLAG(bool, print_flags, false, "Print flags as they are being parsed."); |
| 13 DEFINE_FLAG(bool, ignore_unrecognized_flags, false, | 13 DEFINE_FLAG(bool, ignore_unrecognized_flags, false, |
| 14 "Ignore unrecognized flags."); | 14 "Ignore unrecognized flags."); |
| 15 | 15 |
| 16 // List of registered flags. | 16 // List of registered flags. |
| 17 Flag* Flags::flags_ = NULL; | 17 Flag* Flags::flags_ = NULL; |
| 18 | 18 |
| 19 class Flag { | 19 class Flag { |
| 20 public: | 20 public: |
| 21 enum Type { | 21 enum FlagType { |
| 22 kBoolean, | 22 kBoolean, |
| 23 kInteger, | 23 kInteger, |
| 24 kString, | 24 kString, |
| 25 kNumFlagTypes | 25 kNumFlagTypes |
| 26 }; | 26 }; |
| 27 | 27 |
| 28 Flag(const char* name, const char* comment, void* addr, Type type) | 28 Flag(const char* name, const char* comment, void* addr, FlagType type) |
| 29 : name_(name), comment_(comment), addr_(addr), type_(type) { | 29 : name_(name), comment_(comment), addr_(addr), type_(type) { |
| 30 } | 30 } |
| 31 | 31 |
| 32 void Print() { | 32 void Print() { |
| 33 if (IsUnrecognized()) { | 33 if (IsUnrecognized()) { |
| 34 OS::Print("%s: unrecognized\n", name_); | 34 OS::Print("%s: unrecognized\n", name_); |
| 35 return; | 35 return; |
| 36 } | 36 } |
| 37 switch (type_) { | 37 switch (type_) { |
| 38 case kBoolean: { | 38 case kBoolean: { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 64 | 64 |
| 65 Flag* next_; | 65 Flag* next_; |
| 66 const char* name_; | 66 const char* name_; |
| 67 const char* comment_; | 67 const char* comment_; |
| 68 union { | 68 union { |
| 69 void* addr_; | 69 void* addr_; |
| 70 bool* bool_ptr_; | 70 bool* bool_ptr_; |
| 71 int* int_ptr_; | 71 int* int_ptr_; |
| 72 charp* charp_ptr_; | 72 charp* charp_ptr_; |
| 73 }; | 73 }; |
| 74 Type type_; | 74 FlagType type_; |
| 75 }; | 75 }; |
| 76 | 76 |
| 77 | 77 |
| 78 Flag* Flags::Lookup(const char* name) { | 78 Flag* Flags::Lookup(const char* name) { |
| 79 Flag* cur = Flags::flags_; | 79 Flag* cur = Flags::flags_; |
| 80 while (cur != NULL) { | 80 while (cur != NULL) { |
| 81 if (strcmp(cur->name_, name) == 0) { | 81 if (strcmp(cur->name_, name) == 0) { |
| 82 return cur; | 82 return cur; |
| 83 } | 83 } |
| 84 cur = cur->next_; | 84 cur = cur->next_; |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 OS::Print("Flag settings:\n"); | 261 OS::Print("Flag settings:\n"); |
| 262 Flag* flag = Flags::flags_; | 262 Flag* flag = Flags::flags_; |
| 263 while (flag != NULL) { | 263 while (flag != NULL) { |
| 264 flag->Print(); | 264 flag->Print(); |
| 265 flag = flag->next_; | 265 flag = flag->next_; |
| 266 } | 266 } |
| 267 } | 267 } |
| 268 } | 268 } |
| 269 | 269 |
| 270 } // namespace dart | 270 } // namespace dart |
| OLD | NEW |