| 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 VM_FLAGS_H_ | 5 #ifndef VM_FLAGS_H_ |
| 6 #define VM_FLAGS_H_ | 6 #define VM_FLAGS_H_ |
| 7 | 7 |
| 8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
| 9 #include "vm/flag_list.h" |
| 9 #include "vm/globals.h" | 10 #include "vm/globals.h" |
| 10 | 11 |
| 12 |
| 11 typedef const char* charp; | 13 typedef const char* charp; |
| 12 | 14 |
| 13 #define DECLARE_FLAG(type, name) \ | 15 #define DECLARE_FLAG(type, name) \ |
| 14 extern type FLAG_##name | 16 extern type FLAG_##name |
| 15 | 17 |
| 16 #define DEFINE_FLAG(type, name, default_value, comment) \ | 18 #define DEFINE_FLAG(type, name, default_value, comment) \ |
| 17 type FLAG_##name = Flags::Register_##type(&FLAG_##name, \ | 19 type FLAG_##name = Flags::Register_##type(&FLAG_##name, \ |
| 18 #name, \ | 20 #name, \ |
| 19 default_value, \ | 21 default_value, \ |
| 20 comment) | 22 comment); |
| 21 | 23 |
| 22 #define DEFINE_FLAG_HANDLER(handler, name, comment) \ | 24 #define DEFINE_FLAG_HANDLER(handler, name, comment) \ |
| 23 bool DUMMY_##name = Flags::Register_func(handler, #name, comment) | 25 bool DUMMY_##name = Flags::Register_func(handler, #name, comment); |
| 24 | 26 |
| 25 | 27 |
| 26 #if defined(DEBUG) | |
| 27 #define DECLARE_DEBUG_FLAG(type, name) DECLARE_FLAG(type, name) | |
| 28 #define DEFINE_DEBUG_FLAG(type, name, default_value, comment) \ | |
| 29 DEFINE_FLAG(type, name, default_value, comment) | |
| 30 #else | |
| 31 #define DECLARE_DEBUG_FLAG(type, name) | |
| 32 #define DEFINE_DEBUG_FLAG(type, name, default_value, comment) | |
| 33 #endif | |
| 34 | |
| 35 namespace dart { | 28 namespace dart { |
| 36 | 29 |
| 37 typedef void (*FlagHandler)(bool value); | 30 typedef void (*FlagHandler)(bool value); |
| 38 | 31 |
| 39 // Forward declarations. | 32 // Forward declarations. |
| 40 class Flag; | 33 class Flag; |
| 41 class JSONArray; | 34 class JSONArray; |
| 42 class JSONStream; | 35 class JSONStream; |
| 43 | 36 |
| 44 class Flags { | 37 class Flags { |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 | 93 |
| 101 static void PrintFlagToJSONArray(JSONArray* jsarr, const Flag* flag); | 94 static void PrintFlagToJSONArray(JSONArray* jsarr, const Flag* flag); |
| 102 | 95 |
| 103 // Testing needs direct access to private methods. | 96 // Testing needs direct access to private methods. |
| 104 friend void Dart_TestParseFlags(); | 97 friend void Dart_TestParseFlags(); |
| 105 | 98 |
| 106 DISALLOW_ALLOCATION(); | 99 DISALLOW_ALLOCATION(); |
| 107 DISALLOW_IMPLICIT_CONSTRUCTORS(Flags); | 100 DISALLOW_IMPLICIT_CONSTRUCTORS(Flags); |
| 108 }; | 101 }; |
| 109 | 102 |
| 103 #define PRODUCT_FLAG_MARCO(name, type, default_value, comment) \ |
| 104 extern type FLAG_##name; |
| 105 |
| 106 #if defined(DEBUG) |
| 107 #define DEBUG_FLAG_MARCO(name, type, default_value, comment) \ |
| 108 extern type FLAG_##name; |
| 109 #else // defined(DEBUG) |
| 110 #define DEBUG_FLAG_MARCO(name, type, default_value, comment) \ |
| 111 const type FLAG_##name = default_value; |
| 112 #endif // defined(DEBUG) |
| 113 |
| 114 #if defined(PRODUCT) |
| 115 #define RELEASE_FLAG_MARCO(name, product_value, type, default_value, comment) \ |
| 116 const type FLAG_##name = product_value; |
| 117 |
| 118 #else // defined(PRODUCT) |
| 119 |
| 120 #define RELEASE_FLAG_MARCO(name, product_value, type, default_value, comment) \ |
| 121 extern type FLAG_##name; |
| 122 |
| 123 #endif // defined(PRODUCT) |
| 124 |
| 125 // Now declare all flags here. |
| 126 FLAG_LIST(PRODUCT_FLAG_MARCO, RELEASE_FLAG_MARCO, DEBUG_FLAG_MARCO) |
| 127 |
| 128 #undef RELEASE_FLAG_MARCO |
| 129 #undef DEBUG_FLAG_MARCO |
| 130 #undef PRODUCT_FLAG_MARCO |
| 131 |
| 110 } // namespace dart | 132 } // namespace dart |
| 111 | 133 |
| 112 #endif // VM_FLAGS_H_ | 134 #endif // VM_FLAGS_H_ |
| OLD | NEW |