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 {{}} | |
85 struct JSArguments { | 84 struct JSArguments { |
86 public: | 85 public: |
87 inline int argc() const { | 86 JSArguments(); |
88 return static_cast<int>(storage_[0]); | 87 JSArguments(int argc, const char** argv); |
89 } | 88 int argc() const; |
90 inline const char** argv() const { | 89 const char** argv(); |
91 return reinterpret_cast<const char**>(storage_[1]); | 90 const char*& operator[](int idx); |
92 } | 91 JSArguments& operator=(JSArguments args); |
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 } | |
107 private: | 92 private: |
108 void set_argc(int argc) { | 93 int argc_; |
109 storage_[0] = argc; | 94 const char** argv_; |
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]; | |
119 }; | 95 }; |
120 #endif | 96 #endif |
121 | 97 |
122 #define DEFINE_bool(nam, def, cmt) FLAG(BOOL, bool, nam, def, cmt) | 98 #define DEFINE_bool(nam, def, cmt) FLAG(BOOL, bool, nam, def, cmt) |
123 #define DEFINE_int(nam, def, cmt) FLAG(INT, int, nam, def, cmt) | 99 #define DEFINE_int(nam, def, cmt) FLAG(INT, int, nam, def, cmt) |
124 #define DEFINE_float(nam, def, cmt) FLAG(FLOAT, double, nam, def, cmt) | 100 #define DEFINE_float(nam, def, cmt) FLAG(FLOAT, double, nam, def, cmt) |
125 #define DEFINE_string(nam, def, cmt) FLAG(STRING, const char*, nam, def, cmt) | 101 #define DEFINE_string(nam, def, cmt) FLAG(STRING, const char*, nam, def, cmt) |
126 #define DEFINE_args(nam, def, cmt) FLAG(ARGS, JSArguments, nam, def, cmt) | 102 #define DEFINE_args(nam, def, cmt) FLAG(ARGS, JSArguments, nam, def, cmt) |
127 | 103 |
128 // | 104 // |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 | 415 |
440 #ifdef ENABLE_DEBUGGER_SUPPORT | 416 #ifdef ENABLE_DEBUGGER_SUPPORT |
441 DEFINE_bool(debugger, false, "Enable JavaScript debugger") | 417 DEFINE_bool(debugger, false, "Enable JavaScript debugger") |
442 DEFINE_bool(remote_debugger, false, "Connect JavaScript debugger to the " | 418 DEFINE_bool(remote_debugger, false, "Connect JavaScript debugger to the " |
443 "debugger agent in another process") | 419 "debugger agent in another process") |
444 DEFINE_bool(debugger_agent, false, "Enable debugger agent") | 420 DEFINE_bool(debugger_agent, false, "Enable debugger agent") |
445 DEFINE_int(debugger_port, 5858, "Port to use for remote debugging") | 421 DEFINE_int(debugger_port, 5858, "Port to use for remote debugging") |
446 #endif // ENABLE_DEBUGGER_SUPPORT | 422 #endif // ENABLE_DEBUGGER_SUPPORT |
447 | 423 |
448 DEFINE_string(map_counters, "", "Map counters to a file") | 424 DEFINE_string(map_counters, "", "Map counters to a file") |
449 DEFINE_args(js_arguments, JSARGUMENTS_INIT, | 425 DEFINE_args(js_arguments, JSArguments(), |
450 "Pass all remaining arguments to the script. Alias for \"--\".") | 426 "Pass all remaining arguments to the script. Alias for \"--\".") |
451 | 427 |
452 #if defined(WEBOS__) | 428 #if defined(WEBOS__) |
453 DEFINE_bool(debug_compile_events, false, "Enable debugger compile events") | 429 DEFINE_bool(debug_compile_events, false, "Enable debugger compile events") |
454 DEFINE_bool(debug_script_collected_events, false, | 430 DEFINE_bool(debug_script_collected_events, false, |
455 "Enable debugger script collected events") | 431 "Enable debugger script collected events") |
456 #else | 432 #else |
457 DEFINE_bool(debug_compile_events, true, "Enable debugger compile events") | 433 DEFINE_bool(debug_compile_events, true, "Enable debugger compile events") |
458 DEFINE_bool(debug_script_collected_events, true, | 434 DEFINE_bool(debug_script_collected_events, true, |
459 "Enable debugger script collected events") | 435 "Enable debugger script collected events") |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
642 #undef DEFINE_bool | 618 #undef DEFINE_bool |
643 #undef DEFINE_int | 619 #undef DEFINE_int |
644 #undef DEFINE_string | 620 #undef DEFINE_string |
645 #undef DEFINE_implication | 621 #undef DEFINE_implication |
646 | 622 |
647 #undef FLAG_MODE_DECLARE | 623 #undef FLAG_MODE_DECLARE |
648 #undef FLAG_MODE_DEFINE | 624 #undef FLAG_MODE_DEFINE |
649 #undef FLAG_MODE_DEFINE_DEFAULTS | 625 #undef FLAG_MODE_DEFINE_DEFAULTS |
650 #undef FLAG_MODE_META | 626 #undef FLAG_MODE_META |
651 #undef FLAG_MODE_DEFINE_IMPLICATIONS | 627 #undef FLAG_MODE_DEFINE_IMPLICATIONS |
OLD | NEW |