OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 #define FLAG_READONLY(ftype, ctype, nam, def, cmt) | 74 #define FLAG_READONLY(ftype, ctype, nam, def, cmt) |
75 #define DEFINE_implication(whenflag, thenflag) \ | 75 #define DEFINE_implication(whenflag, thenflag) \ |
76 if (FLAG_##whenflag) FLAG_##thenflag = true; | 76 if (FLAG_##whenflag) FLAG_##thenflag = true; |
77 | 77 |
78 #else | 78 #else |
79 #error No mode supplied when including flags.defs | 79 #error No mode supplied when including flags.defs |
80 #endif | 80 #endif |
81 | 81 |
82 #ifdef FLAG_MODE_DECLARE | 82 #ifdef FLAG_MODE_DECLARE |
83 // Structure used to hold a collection of arguments to the JavaScript code. | 83 // Structure used to hold a collection of arguments to the JavaScript code. |
| 84 #define JSARGUMENTS_INIT {{}} |
84 struct JSArguments { | 85 struct JSArguments { |
85 public: | 86 public: |
86 JSArguments(); | 87 inline int argc() const { |
87 JSArguments(int argc, const char** argv); | 88 return static_cast<int>(storage_[0]); |
88 int argc() const; | 89 } |
89 const char** argv(); | 90 inline const char** argv() const { |
90 const char*& operator[](int idx); | 91 return reinterpret_cast<const char**>(storage_[1]); |
91 JSArguments& operator=(JSArguments args); | 92 } |
| 93 inline const char*& operator[] (int idx) const { |
| 94 return argv()[idx]; |
| 95 } |
| 96 inline JSArguments& operator=(JSArguments args) { |
| 97 set_argc(args.argc()); |
| 98 set_argv(args.argv()); |
| 99 return *this; |
| 100 } |
| 101 static JSArguments Create(int argc, const char** argv) { |
| 102 JSArguments args; |
| 103 args.set_argc(argc); |
| 104 args.set_argv(argv); |
| 105 return args; |
| 106 } |
92 private: | 107 private: |
93 int argc_; | 108 void set_argc(int argc) { |
94 const char** argv_; | 109 storage_[0] = argc; |
| 110 } |
| 111 void set_argv(const char** argv) { |
| 112 storage_[1] = reinterpret_cast<AtomicWord>(argv); |
| 113 } |
| 114 public: |
| 115 // Contains argc and argv. Unfortunately we have to store these two fields |
| 116 // into a single one to avoid making the initialization macro (which would be |
| 117 // "{ 0, NULL }") contain a coma. |
| 118 AtomicWord storage_[2]; |
95 }; | 119 }; |
96 #endif | 120 #endif |
97 | 121 |
98 #define DEFINE_bool(nam, def, cmt) FLAG(BOOL, bool, nam, def, cmt) | 122 #define DEFINE_bool(nam, def, cmt) FLAG(BOOL, bool, nam, def, cmt) |
99 #define DEFINE_int(nam, def, cmt) FLAG(INT, int, nam, def, cmt) | 123 #define DEFINE_int(nam, def, cmt) FLAG(INT, int, nam, def, cmt) |
100 #define DEFINE_float(nam, def, cmt) FLAG(FLOAT, double, nam, def, cmt) | 124 #define DEFINE_float(nam, def, cmt) FLAG(FLOAT, double, nam, def, cmt) |
101 #define DEFINE_string(nam, def, cmt) FLAG(STRING, const char*, nam, def, cmt) | 125 #define DEFINE_string(nam, def, cmt) FLAG(STRING, const char*, nam, def, cmt) |
102 #define DEFINE_args(nam, def, cmt) FLAG(ARGS, JSArguments, nam, def, cmt) | 126 #define DEFINE_args(nam, def, cmt) FLAG(ARGS, JSArguments, nam, def, cmt) |
103 | 127 |
104 // | 128 // |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 | 420 |
397 #ifdef ENABLE_DEBUGGER_SUPPORT | 421 #ifdef ENABLE_DEBUGGER_SUPPORT |
398 DEFINE_bool(debugger, false, "Enable JavaScript debugger") | 422 DEFINE_bool(debugger, false, "Enable JavaScript debugger") |
399 DEFINE_bool(remote_debugger, false, "Connect JavaScript debugger to the " | 423 DEFINE_bool(remote_debugger, false, "Connect JavaScript debugger to the " |
400 "debugger agent in another process") | 424 "debugger agent in another process") |
401 DEFINE_bool(debugger_agent, false, "Enable debugger agent") | 425 DEFINE_bool(debugger_agent, false, "Enable debugger agent") |
402 DEFINE_int(debugger_port, 5858, "Port to use for remote debugging") | 426 DEFINE_int(debugger_port, 5858, "Port to use for remote debugging") |
403 #endif // ENABLE_DEBUGGER_SUPPORT | 427 #endif // ENABLE_DEBUGGER_SUPPORT |
404 | 428 |
405 DEFINE_string(map_counters, "", "Map counters to a file") | 429 DEFINE_string(map_counters, "", "Map counters to a file") |
406 DEFINE_args(js_arguments, JSArguments(), | 430 DEFINE_args(js_arguments, JSARGUMENTS_INIT, |
407 "Pass all remaining arguments to the script. Alias for \"--\".") | 431 "Pass all remaining arguments to the script. Alias for \"--\".") |
408 | 432 |
409 #if defined(WEBOS__) | 433 #if defined(WEBOS__) |
410 DEFINE_bool(debug_compile_events, false, "Enable debugger compile events") | 434 DEFINE_bool(debug_compile_events, false, "Enable debugger compile events") |
411 DEFINE_bool(debug_script_collected_events, false, | 435 DEFINE_bool(debug_script_collected_events, false, |
412 "Enable debugger script collected events") | 436 "Enable debugger script collected events") |
413 #else | 437 #else |
414 DEFINE_bool(debug_compile_events, true, "Enable debugger compile events") | 438 DEFINE_bool(debug_compile_events, true, "Enable debugger compile events") |
415 DEFINE_bool(debug_script_collected_events, true, | 439 DEFINE_bool(debug_script_collected_events, true, |
416 "Enable debugger script collected events") | 440 "Enable debugger script collected events") |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
587 #undef DEFINE_bool | 611 #undef DEFINE_bool |
588 #undef DEFINE_int | 612 #undef DEFINE_int |
589 #undef DEFINE_string | 613 #undef DEFINE_string |
590 #undef DEFINE_implication | 614 #undef DEFINE_implication |
591 | 615 |
592 #undef FLAG_MODE_DECLARE | 616 #undef FLAG_MODE_DECLARE |
593 #undef FLAG_MODE_DEFINE | 617 #undef FLAG_MODE_DEFINE |
594 #undef FLAG_MODE_DEFINE_DEFAULTS | 618 #undef FLAG_MODE_DEFINE_DEFAULTS |
595 #undef FLAG_MODE_META | 619 #undef FLAG_MODE_META |
596 #undef FLAG_MODE_DEFINE_IMPLICATIONS | 620 #undef FLAG_MODE_DEFINE_IMPLICATIONS |
OLD | NEW |