Changeset 122341 in webkit for trunk/Source/JavaScriptCore/jsc.cpp
- Timestamp:
- Jul 11, 2012, 10:50:15 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/jsc.cpp
r121798 r122341 114 114 }; 115 115 116 struct CommandLine { 117 CommandLine() 118 : interactive(false) 119 , dump(false) 120 , exitCode(false) 116 class CommandLine { 117 public: 118 CommandLine(int argc, char** argv) 119 : m_interactive(false) 120 , m_dump(false) 121 , m_exitCode(false) 121 122 { 122 } 123 124 bool interactive; 125 bool dump; 126 bool exitCode; 127 Vector<Script> scripts; 128 Vector<UString> arguments; 123 parseArguments(argc, argv); 124 } 125 126 bool m_interactive; 127 bool m_dump; 128 bool m_exitCode; 129 Vector<Script> m_scripts; 130 Vector<UString> m_arguments; 131 132 void parseArguments(int, char**); 129 133 }; 130 134 … … 624 628 } 625 629 626 static void parseArguments(int argc, char** argv, CommandLine& options)630 void CommandLine::parseArguments(int argc, char** argv) 627 631 { 628 632 int i = 1; … … 635 639 if (++i == argc) 636 640 printUsageStatement(); 637 options.scripts.append(Script(true, argv[i]));641 m_scripts.append(Script(true, argv[i])); 638 642 continue; 639 643 } … … 641 645 if (++i == argc) 642 646 printUsageStatement(); 643 options.scripts.append(Script(false, argv[i]));647 m_scripts.append(Script(false, argv[i])); 644 648 continue; 645 649 } 646 650 if (!strcmp(arg, "-i")) { 647 options.interactive = true;651 m_interactive = true; 648 652 continue; 649 653 } 650 654 if (!strcmp(arg, "-d")) { 651 options.dump = true;655 m_dump = true; 652 656 continue; 653 657 } … … 662 666 } 663 667 if (!strcmp(arg, "-x")) { 664 options.exitCode = true;668 m_exitCode = true; 665 669 continue; 666 670 } … … 691 695 // This arg is not recognized by the VM nor by jsc. Pass it on to the 692 696 // script. 693 options.scripts.append(Script(true, argv[i]));694 } 695 696 if ( options.scripts.isEmpty())697 options.interactive = true;697 m_scripts.append(Script(true, argv[i])); 698 } 699 700 if (m_scripts.isEmpty()) 701 m_interactive = true; 698 702 699 703 for (; i < argc; ++i) 700 options.arguments.append(argv[i]);704 m_arguments.append(argv[i]); 701 705 702 706 if (needToDumpOptions) … … 708 712 int jscmain(int argc, char** argv) 709 713 { 714 // Note that the options parsing can affect JSGlobalData creation, and thus 715 // comes first. 716 CommandLine options(argc, argv); 710 717 RefPtr<JSGlobalData> globalData = JSGlobalData::create(ThreadStackTypeLarge, LargeHeap); 711 718 JSLockHolder lock(globalData.get()); 712 719 int result; 713 720 714 CommandLine options; 715 parseArguments(argc, argv, options); 716 717 GlobalObject* globalObject = GlobalObject::create(*globalData, GlobalObject::createStructure(*globalData, jsNull()), options.arguments); 718 bool success = runWithScripts(globalObject, options.scripts, options.dump); 719 if (options.interactive && success) 721 GlobalObject* globalObject = GlobalObject::create(*globalData, GlobalObject::createStructure(*globalData, jsNull()), options.m_arguments); 722 bool success = runWithScripts(globalObject, options.m_scripts, options.m_dump); 723 if (options.m_interactive && success) 720 724 runInteractive(globalObject); 721 725 722 726 result = success ? 0 : 3; 723 727 724 if (options. exitCode)728 if (options.m_exitCode) 725 729 printf("jsc exiting %d\n", result); 726 730
Note:
See TracChangeset
for help on using the changeset viewer.