| 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 #ifndef RUNTIME_VM_FLAGS_H_ | 5 #ifndef RUNTIME_VM_FLAGS_H_ |
| 6 #define RUNTIME_VM_FLAGS_H_ | 6 #define RUNTIME_VM_FLAGS_H_ |
| 7 | 7 |
| 8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
| 9 #include "vm/flag_list.h" | 9 #include "vm/flag_list.h" |
| 10 #include "vm/globals.h" | 10 #include "vm/globals.h" |
| 11 | 11 |
| 12 typedef const char* charp; | 12 typedef const char* charp; |
| 13 | 13 |
| 14 #define DECLARE_FLAG(type, name) \ | 14 #define DECLARE_FLAG(type, name) extern type FLAG_##name |
| 15 extern type FLAG_##name | |
| 16 | 15 |
| 17 #define DEFINE_FLAG(type, name, default_value, comment) \ | 16 #define DEFINE_FLAG(type, name, default_value, comment) \ |
| 18 type FLAG_##name = Flags::Register_##type(&FLAG_##name, \ | 17 type FLAG_##name = \ |
| 19 #name, \ | 18 Flags::Register_##type(&FLAG_##name, #name, default_value, comment); |
| 20 default_value, \ | |
| 21 comment); | |
| 22 | 19 |
| 23 #define DEFINE_FLAG_HANDLER(handler, name, comment) \ | 20 #define DEFINE_FLAG_HANDLER(handler, name, comment) \ |
| 24 bool DUMMY_##name = Flags::Register_func(handler, #name, comment); | 21 bool DUMMY_##name = Flags::Register_func(handler, #name, comment); |
| 25 | 22 |
| 26 | 23 |
| 27 namespace dart { | 24 namespace dart { |
| 28 | 25 |
| 29 typedef void (*FlagHandler)(bool value); | 26 typedef void (*FlagHandler)(bool value); |
| 30 | 27 |
| 31 // Forward declarations. | 28 // Forward declarations. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 static Flag* Lookup(const char* name); | 61 static Flag* Lookup(const char* name); |
| 65 | 62 |
| 66 static bool IsSet(const char* name); | 63 static bool IsSet(const char* name); |
| 67 | 64 |
| 68 static bool Initialized() { return initialized_; } | 65 static bool Initialized() { return initialized_; } |
| 69 | 66 |
| 70 #ifndef PRODUCT | 67 #ifndef PRODUCT |
| 71 static void PrintJSON(JSONStream* js); | 68 static void PrintJSON(JSONStream* js); |
| 72 #endif // !PRODUCT | 69 #endif // !PRODUCT |
| 73 | 70 |
| 74 static bool SetFlag(const char* name, | 71 static bool SetFlag(const char* name, const char* value, const char** error); |
| 75 const char* value, | |
| 76 const char** error); | |
| 77 | 72 |
| 78 private: | 73 private: |
| 79 static Flag** flags_; | 74 static Flag** flags_; |
| 80 static intptr_t capacity_; | 75 static intptr_t capacity_; |
| 81 static intptr_t num_flags_; | 76 static intptr_t num_flags_; |
| 82 | 77 |
| 83 static bool initialized_; | 78 static bool initialized_; |
| 84 | 79 |
| 85 static void AddFlag(Flag* flag); | 80 static void AddFlag(Flag* flag); |
| 86 | 81 |
| 87 static bool SetFlagFromString(Flag* flag, const char* argument); | 82 static bool SetFlagFromString(Flag* flag, const char* argument); |
| 88 | 83 |
| 89 static void Parse(const char* option); | 84 static void Parse(const char* option); |
| 90 | 85 |
| 91 static int CompareFlagNames(const void* left, const void* right); | 86 static int CompareFlagNames(const void* left, const void* right); |
| 92 | 87 |
| 93 static void PrintFlags(); | 88 static void PrintFlags(); |
| 94 | 89 |
| 95 #ifndef PRODUCT | 90 #ifndef PRODUCT |
| 96 static void PrintFlagToJSONArray(JSONArray* jsarr, const Flag* flag); | 91 static void PrintFlagToJSONArray(JSONArray* jsarr, const Flag* flag); |
| 97 #endif // !PRODUCT | 92 #endif // !PRODUCT |
| 98 | 93 |
| 99 // Testing needs direct access to private methods. | 94 // Testing needs direct access to private methods. |
| 100 friend void Dart_TestParseFlags(); | 95 friend void Dart_TestParseFlags(); |
| 101 | 96 |
| 102 DISALLOW_ALLOCATION(); | 97 DISALLOW_ALLOCATION(); |
| 103 DISALLOW_IMPLICIT_CONSTRUCTORS(Flags); | 98 DISALLOW_IMPLICIT_CONSTRUCTORS(Flags); |
| 104 }; | 99 }; |
| 105 | 100 |
| 106 #define PRODUCT_FLAG_MARCO(name, type, default_value, comment) \ | 101 #define PRODUCT_FLAG_MARCO(name, type, default_value, comment) \ |
| 107 extern type FLAG_##name; | 102 extern type FLAG_##name; |
| 108 | 103 |
| 109 #if defined(DEBUG) | 104 #if defined(DEBUG) |
| 110 #define DEBUG_FLAG_MARCO(name, type, default_value, comment) \ | 105 #define DEBUG_FLAG_MARCO(name, type, default_value, comment) \ |
| 111 extern type FLAG_##name; | 106 extern type FLAG_##name; |
| 112 #else // defined(DEBUG) | 107 #else // defined(DEBUG) |
| 113 #define DEBUG_FLAG_MARCO(name, type, default_value, comment) \ | 108 #define DEBUG_FLAG_MARCO(name, type, default_value, comment) \ |
| 114 const type FLAG_##name = default_value; | 109 const type FLAG_##name = default_value; |
| 115 #endif // defined(DEBUG) | 110 #endif // defined(DEBUG) |
| 116 | 111 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 PRECOMPILE_FLAG_MARCO) | 146 PRECOMPILE_FLAG_MARCO) |
| 152 | 147 |
| 153 #undef RELEASE_FLAG_MARCO | 148 #undef RELEASE_FLAG_MARCO |
| 154 #undef DEBUG_FLAG_MARCO | 149 #undef DEBUG_FLAG_MARCO |
| 155 #undef PRODUCT_FLAG_MARCO | 150 #undef PRODUCT_FLAG_MARCO |
| 156 #undef PRECOMPILE_FLAG_MARCO | 151 #undef PRECOMPILE_FLAG_MARCO |
| 157 | 152 |
| 158 } // namespace dart | 153 } // namespace dart |
| 159 | 154 |
| 160 #endif // RUNTIME_VM_FLAGS_H_ | 155 #endif // RUNTIME_VM_FLAGS_H_ |
| OLD | NEW |