| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 13 matching lines...) Expand all Loading... |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #include <ctype.h> | 28 #include <ctype.h> |
| 29 #include <stdlib.h> | 29 #include <stdlib.h> |
| 30 | 30 |
| 31 #include "v8.h" | 31 #include "v8.h" |
| 32 | 32 |
| 33 #include "platform.h" | 33 #include "platform.h" |
| 34 #include "smart-pointer.h" | 34 #include "smart-array-pointer.h" |
| 35 #include "string-stream.h" | 35 #include "string-stream.h" |
| 36 | 36 |
| 37 | 37 |
| 38 namespace v8 { | 38 namespace v8 { |
| 39 namespace internal { | 39 namespace internal { |
| 40 | 40 |
| 41 // Define all of our flags. | 41 // Define all of our flags. |
| 42 #define FLAG_MODE_DEFINE | 42 #define FLAG_MODE_DEFINE |
| 43 #include "flag-definitions.h" | 43 #include "flag-definitions.h" |
| 44 | 44 |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 case Flag::TYPE_INT: return "int"; | 186 case Flag::TYPE_INT: return "int"; |
| 187 case Flag::TYPE_FLOAT: return "float"; | 187 case Flag::TYPE_FLOAT: return "float"; |
| 188 case Flag::TYPE_STRING: return "string"; | 188 case Flag::TYPE_STRING: return "string"; |
| 189 case Flag::TYPE_ARGS: return "arguments"; | 189 case Flag::TYPE_ARGS: return "arguments"; |
| 190 } | 190 } |
| 191 UNREACHABLE(); | 191 UNREACHABLE(); |
| 192 return NULL; | 192 return NULL; |
| 193 } | 193 } |
| 194 | 194 |
| 195 | 195 |
| 196 static SmartPointer<const char> ToString(Flag* flag) { | 196 static SmartArrayPointer<const char> ToString(Flag* flag) { |
| 197 HeapStringAllocator string_allocator; | 197 HeapStringAllocator string_allocator; |
| 198 StringStream buffer(&string_allocator); | 198 StringStream buffer(&string_allocator); |
| 199 switch (flag->type()) { | 199 switch (flag->type()) { |
| 200 case Flag::TYPE_BOOL: | 200 case Flag::TYPE_BOOL: |
| 201 buffer.Add("%s", (*flag->bool_variable() ? "true" : "false")); | 201 buffer.Add("%s", (*flag->bool_variable() ? "true" : "false")); |
| 202 break; | 202 break; |
| 203 case Flag::TYPE_INT: | 203 case Flag::TYPE_INT: |
| 204 buffer.Add("%d", *flag->int_variable()); | 204 buffer.Add("%d", *flag->int_variable()); |
| 205 break; | 205 break; |
| 206 case Flag::TYPE_FLOAT: | 206 case Flag::TYPE_FLOAT: |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 521 printf(" shell [options]\n"); | 521 printf(" shell [options]\n"); |
| 522 printf(" shell [options] --shell [file1 file2 ... filek]\n"); | 522 printf(" shell [options] --shell [file1 file2 ... filek]\n"); |
| 523 printf(" run an interactive JavaScript shell\n"); | 523 printf(" run an interactive JavaScript shell\n"); |
| 524 printf(" d8 [options] file1 file2 ... filek\n"); | 524 printf(" d8 [options] file1 file2 ... filek\n"); |
| 525 printf(" d8 [options]\n"); | 525 printf(" d8 [options]\n"); |
| 526 printf(" d8 [options] --shell [file1 file2 ... filek]\n"); | 526 printf(" d8 [options] --shell [file1 file2 ... filek]\n"); |
| 527 printf(" run the new debugging shell\n\n"); | 527 printf(" run the new debugging shell\n\n"); |
| 528 printf("Options:\n"); | 528 printf("Options:\n"); |
| 529 for (size_t i = 0; i < num_flags; ++i) { | 529 for (size_t i = 0; i < num_flags; ++i) { |
| 530 Flag* f = &flags[i]; | 530 Flag* f = &flags[i]; |
| 531 SmartPointer<const char> value = ToString(f); | 531 SmartArrayPointer<const char> value = ToString(f); |
| 532 printf(" --%s (%s)\n type: %s default: %s\n", | 532 printf(" --%s (%s)\n type: %s default: %s\n", |
| 533 f->name(), f->comment(), Type2String(f->type()), *value); | 533 f->name(), f->comment(), Type2String(f->type()), *value); |
| 534 } | 534 } |
| 535 } | 535 } |
| 536 | 536 |
| 537 JSArguments::JSArguments() | 537 JSArguments::JSArguments() |
| 538 : argc_(0), argv_(NULL) {} | 538 : argc_(0), argv_(NULL) {} |
| 539 JSArguments::JSArguments(int argc, const char** argv) | 539 JSArguments::JSArguments(int argc, const char** argv) |
| 540 : argc_(argc), argv_(argv) {} | 540 : argc_(argc), argv_(argv) {} |
| 541 int JSArguments::argc() const { return argc_; } | 541 int JSArguments::argc() const { return argc_; } |
| 542 const char** JSArguments::argv() { return argv_; } | 542 const char** JSArguments::argv() { return argv_; } |
| 543 const char*& JSArguments::operator[](int idx) { return argv_[idx]; } | 543 const char*& JSArguments::operator[](int idx) { return argv_[idx]; } |
| 544 JSArguments& JSArguments::operator=(JSArguments args) { | 544 JSArguments& JSArguments::operator=(JSArguments args) { |
| 545 argc_ = args.argc_; | 545 argc_ = args.argc_; |
| 546 argv_ = args.argv_; | 546 argv_ = args.argv_; |
| 547 return *this; | 547 return *this; |
| 548 } | 548 } |
| 549 | 549 |
| 550 | 550 |
| 551 } } // namespace v8::internal | 551 } } // namespace v8::internal |
| OLD | NEW |