• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef V8_FLAGS_H_
6 #define V8_FLAGS_H_
7 
8 #include "src/globals.h"
9 
10 namespace v8 {
11 namespace internal {
12 
13 // Declare all of our flags.
14 #define FLAG_MODE_DECLARE
15 #include "src/flag-definitions.h"
16 
17 // The global list of all flags.
18 class FlagList {
19  public:
20   // The list of all flags with a value different from the default
21   // and their values. The format of the list is like the format of the
22   // argv array passed to the main function, e.g.
23   // ("--prof", "--log-file", "v8.prof", "--nolazy").
24   //
25   // The caller is responsible for disposing the list, as well
26   // as every element of it.
27   static List<const char*>* argv();
28 
29   // Set the flag values by parsing the command line. If remove_flags is
30   // set, the flags and associated values are removed from (argc,
31   // argv). Returns 0 if no error occurred. Otherwise, returns the argv
32   // index > 0 for the argument where an error occurred. In that case,
33   // (argc, argv) will remain unchanged independent of the remove_flags
34   // value, and no assumptions about flag settings should be made.
35   //
36   // The following syntax for flags is accepted (both '-' and '--' are ok):
37   //
38   //   --flag        (bool flags only)
39   //   --noflag      (bool flags only)
40   //   --flag=value  (non-bool flags only, no spaces around '=')
41   //   --flag value  (non-bool flags only)
42   //   --            (equivalent to --js_arguments, captures all remaining args)
43   static int SetFlagsFromCommandLine(int* argc,
44                                      char** argv,
45                                      bool remove_flags);
46 
47   // Set the flag values by parsing the string str. Splits string into argc
48   // substrings argv[], each of which consisting of non-white-space chars,
49   // and then calls SetFlagsFromCommandLine() and returns its result.
50   static int SetFlagsFromString(const char* str, int len);
51 
52   // Reset all flags to their default value.
53   static void ResetAllFlags();
54 
55   // Print help to stdout with flags, types, and default values.
56   static void PrintHelp();
57 
58   // Set flags as consequence of being implied by another flag.
59   static void EnforceFlagImplications();
60 };
61 
62 } }  // namespace v8::internal
63 
64 #endif  // V8_FLAGS_H_
65