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 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 | 427 |
404 #ifdef ENABLE_DEBUGGER_SUPPORT | 428 #ifdef ENABLE_DEBUGGER_SUPPORT |
405 DEFINE_bool(debugger, false, "Enable JavaScript debugger") | 429 DEFINE_bool(debugger, false, "Enable JavaScript debugger") |
406 DEFINE_bool(remote_debugger, false, "Connect JavaScript debugger to the " | 430 DEFINE_bool(remote_debugger, false, "Connect JavaScript debugger to the " |
407 "debugger agent in another process") | 431 "debugger agent in another process") |
408 DEFINE_bool(debugger_agent, false, "Enable debugger agent") | 432 DEFINE_bool(debugger_agent, false, "Enable debugger agent") |
409 DEFINE_int(debugger_port, 5858, "Port to use for remote debugging") | 433 DEFINE_int(debugger_port, 5858, "Port to use for remote debugging") |
410 #endif // ENABLE_DEBUGGER_SUPPORT | 434 #endif // ENABLE_DEBUGGER_SUPPORT |
411 | 435 |
412 DEFINE_string(map_counters, "", "Map counters to a file") | 436 DEFINE_string(map_counters, "", "Map counters to a file") |
413 DEFINE_args(js_arguments, JSArguments(), | 437 DEFINE_args(js_arguments, JSARGUMENTS_INIT, |
414 "Pass all remaining arguments to the script. Alias for \"--\".") | 438 "Pass all remaining arguments to the script. Alias for \"--\".") |
415 | 439 |
416 #if defined(WEBOS__) | 440 #if defined(WEBOS__) |
417 DEFINE_bool(debug_compile_events, false, "Enable debugger compile events") | 441 DEFINE_bool(debug_compile_events, false, "Enable debugger compile events") |
418 DEFINE_bool(debug_script_collected_events, false, | 442 DEFINE_bool(debug_script_collected_events, false, |
419 "Enable debugger script collected events") | 443 "Enable debugger script collected events") |
420 #else | 444 #else |
421 DEFINE_bool(debug_compile_events, true, "Enable debugger compile events") | 445 DEFINE_bool(debug_compile_events, true, "Enable debugger compile events") |
422 DEFINE_bool(debug_script_collected_events, true, | 446 DEFINE_bool(debug_script_collected_events, true, |
423 "Enable debugger script collected events") | 447 "Enable debugger script collected events") |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
594 #undef DEFINE_bool | 618 #undef DEFINE_bool |
595 #undef DEFINE_int | 619 #undef DEFINE_int |
596 #undef DEFINE_string | 620 #undef DEFINE_string |
597 #undef DEFINE_implication | 621 #undef DEFINE_implication |
598 | 622 |
599 #undef FLAG_MODE_DECLARE | 623 #undef FLAG_MODE_DECLARE |
600 #undef FLAG_MODE_DEFINE | 624 #undef FLAG_MODE_DEFINE |
601 #undef FLAG_MODE_DEFINE_DEFAULTS | 625 #undef FLAG_MODE_DEFINE_DEFAULTS |
602 #undef FLAG_MODE_META | 626 #undef FLAG_MODE_META |
603 #undef FLAG_MODE_DEFINE_IMPLICATIONS | 627 #undef FLAG_MODE_DEFINE_IMPLICATIONS |
OLD | NEW |