OLD | NEW |
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/json_stream.h" | 8 #include "vm/json_stream.h" |
9 #include "vm/os.h" | 9 #include "vm/os.h" |
10 | 10 |
11 namespace dart { | 11 namespace dart { |
12 | 12 |
13 DEFINE_FLAG(bool, print_flags, false, "Print flags as they are being parsed."); | 13 DEFINE_FLAG(bool, print_flags, false, "Print flags as they are being parsed."); |
14 DEFINE_FLAG(bool, ignore_unrecognized_flags, false, | 14 DEFINE_FLAG(bool, ignore_unrecognized_flags, false, |
15 "Ignore unrecognized flags."); | 15 "Ignore unrecognized flags."); |
16 | 16 |
| 17 #define PRODUCT_FLAG_MARCO(name, type, default_value, comment) \ |
| 18 type FLAG_##name = Flags::Register_##type(&FLAG_##name, \ |
| 19 #name, \ |
| 20 default_value, \ |
| 21 comment); |
| 22 |
| 23 #if defined(DEBUG) |
| 24 #define DEBUG_FLAG_MARCO(name, type, default_value, comment) \ |
| 25 type FLAG_##name = Flags::Register_##type(&FLAG_##name, \ |
| 26 #name, \ |
| 27 default_value, \ |
| 28 comment); |
| 29 #else // defined(DEBUG) |
| 30 #define DEBUG_FLAG_MARCO(name, type, default_value, comment) |
| 31 #endif // defined(DEBUG) |
| 32 |
| 33 #if defined(PRODUCT) |
| 34 // Nothing to be done for the product flag definitions. |
| 35 #define RELEASE_FLAG_MARCO(name, product_value, type, default_value, comment) |
| 36 #else // defined(PRODUCT) |
| 37 #define RELEASE_FLAG_MARCO(name, product_value, type, default_value, comment) \ |
| 38 type FLAG_##name = Flags::Register_##type(&FLAG_##name, \ |
| 39 #name, \ |
| 40 default_value, \ |
| 41 comment); |
| 42 #endif // defined(PRODUCT) |
| 43 |
| 44 // Define all of the non-product flags here. |
| 45 FLAG_LIST(PRODUCT_FLAG_MARCO, RELEASE_FLAG_MARCO, DEBUG_FLAG_MARCO) |
| 46 |
| 47 #undef RELEASE_FLAG_MARCO |
| 48 #undef DEBUG_FLAG_MARCO |
| 49 #undef PRODUCT_FLAG_MARCO |
| 50 |
| 51 |
17 bool Flags::initialized_ = false; | 52 bool Flags::initialized_ = false; |
18 | 53 |
19 // List of registered flags. | 54 // List of registered flags. |
20 Flag** Flags::flags_ = NULL; | 55 Flag** Flags::flags_ = NULL; |
21 intptr_t Flags::capacity_ = 0; | 56 intptr_t Flags::capacity_ = 0; |
22 intptr_t Flags::num_flags_ = 0; | 57 intptr_t Flags::num_flags_ = 0; |
23 | 58 |
24 class Flag { | 59 class Flag { |
25 public: | 60 public: |
26 enum FlagType { | 61 enum FlagType { |
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 void Flags::PrintJSON(JSONStream* js) { | 499 void Flags::PrintJSON(JSONStream* js) { |
465 JSONObject jsobj(js); | 500 JSONObject jsobj(js); |
466 jsobj.AddProperty("type", "FlagList"); | 501 jsobj.AddProperty("type", "FlagList"); |
467 JSONArray jsarr(&jsobj, "flags"); | 502 JSONArray jsarr(&jsobj, "flags"); |
468 for (intptr_t i = 0; i < num_flags_; ++i) { | 503 for (intptr_t i = 0; i < num_flags_; ++i) { |
469 PrintFlagToJSONArray(&jsarr, flags_[i]); | 504 PrintFlagToJSONArray(&jsarr, flags_[i]); |
470 } | 505 } |
471 } | 506 } |
472 | 507 |
473 } // namespace dart | 508 } // namespace dart |
OLD | NEW |