| 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/globals.h" | 9 #include "vm/globals.h" |
| 10 | 10 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 DEFINE_FLAG(type, name, default_value, comment) | 29 DEFINE_FLAG(type, name, default_value, comment) |
| 30 #else | 30 #else |
| 31 #define DECLARE_DEBUG_FLAG(type, name) | 31 #define DECLARE_DEBUG_FLAG(type, name) |
| 32 #define DEFINE_DEBUG_FLAG(type, name, default_value, comment) | 32 #define DEFINE_DEBUG_FLAG(type, name, default_value, comment) |
| 33 #endif | 33 #endif |
| 34 | 34 |
| 35 namespace dart { | 35 namespace dart { |
| 36 | 36 |
| 37 typedef void (*FlagHandler)(bool value); | 37 typedef void (*FlagHandler)(bool value); |
| 38 | 38 |
| 39 // Forward declaration. | 39 // Forward declarations. |
| 40 class Flag; | 40 class Flag; |
| 41 class JSONArray; |
| 42 class JSONStream; |
| 41 | 43 |
| 42 class Flags { | 44 class Flags { |
| 43 public: | 45 public: |
| 44 static bool Register_bool(bool* addr, | 46 static bool Register_bool(bool* addr, |
| 45 const char* name, | 47 const char* name, |
| 46 bool default_value, | 48 bool default_value, |
| 47 const char* comment); | 49 const char* comment); |
| 48 | 50 |
| 49 static int Register_int(int* addr, | 51 static int Register_int(int* addr, |
| 50 const char* name, | 52 const char* name, |
| 51 int default_value, | 53 int default_value, |
| 52 const char* comment); | 54 const char* comment); |
| 53 | 55 |
| 54 static const char* Register_charp(charp* addr, | 56 static const char* Register_charp(charp* addr, |
| 55 const char* name, | 57 const char* name, |
| 56 const char* default_value, | 58 const char* default_value, |
| 57 const char* comment); | 59 const char* comment); |
| 58 | 60 |
| 59 static bool Register_func(FlagHandler handler, | 61 static bool Register_func(FlagHandler handler, |
| 60 const char* name, | 62 const char* name, |
| 61 const char* comment); | 63 const char* comment); |
| 62 | 64 |
| 63 static bool ProcessCommandLineFlags(int argc, const char** argv); | 65 static bool ProcessCommandLineFlags(int argc, const char** argv); |
| 64 | 66 |
| 65 static Flag* Lookup(const char* name); | 67 static Flag* Lookup(const char* name); |
| 66 | 68 |
| 67 static bool Initialized() { return initialized_; } | 69 static bool Initialized() { return initialized_; } |
| 68 | 70 |
| 71 static void PrintJSON(JSONStream* js); |
| 72 |
| 73 static bool SetFlag(const char* name, |
| 74 const char* value, |
| 75 const char** error); |
| 76 |
| 69 private: | 77 private: |
| 70 static Flag* flags_; | 78 static Flag** flags_; |
| 79 static intptr_t capacity_; |
| 80 static intptr_t num_flags_; |
| 71 | 81 |
| 72 static bool initialized_; | 82 static bool initialized_; |
| 73 | 83 |
| 84 static void AddFlag(Flag* flag); |
| 85 |
| 86 static bool SetFlagFromString(Flag* flag, const char* argument); |
| 87 |
| 74 static void Parse(const char* option); | 88 static void Parse(const char* option); |
| 75 | 89 |
| 76 static int CompareFlagNames(const void* left, const void* right); | 90 static int CompareFlagNames(const void* left, const void* right); |
| 77 | 91 |
| 78 static void PrintFlags(); | 92 static void PrintFlags(); |
| 79 | 93 |
| 94 static void PrintFlagToJSONArray(JSONArray* jsarr, const Flag* flag); |
| 95 |
| 80 // Testing needs direct access to private methods. | 96 // Testing needs direct access to private methods. |
| 81 friend void Dart_TestParseFlags(); | 97 friend void Dart_TestParseFlags(); |
| 82 | 98 |
| 83 DISALLOW_ALLOCATION(); | 99 DISALLOW_ALLOCATION(); |
| 84 DISALLOW_IMPLICIT_CONSTRUCTORS(Flags); | 100 DISALLOW_IMPLICIT_CONSTRUCTORS(Flags); |
| 85 }; | 101 }; |
| 86 | 102 |
| 87 } // namespace dart | 103 } // namespace dart |
| 88 | 104 |
| 89 #endif // VM_FLAGS_H_ | 105 #endif // VM_FLAGS_H_ |
| OLD | NEW |