#include #include #include #include #include #include #include "js_shell.h" void print_usage() { std::cout << "javascript [-i] [-jsc|-v8] [-l module] " << std::endl; } int main(int argc, char* argv[]) { std::string scriptPath = ""; bool interactive = false; JSShell* shell = 0; for (int idx = 1; idx < argc; ++idx) { if(strcmp(argv[idx], "-v8") == 0) { shell = JSShell::Create(JSShell::V8); } else if(strcmp(argv[idx], "-jsc") == 0) { shell = JSShell::Create(JSShell::JSC); } else if(strcmp(argv[idx], "-i") == 0) { interactive = true; } else { scriptPath = argv[idx]; } } if (shell == 0) { shell = JSShell::Create(); } bool failed = false; if(interactive) { failed = !(shell->RunShell()); } else { failed = !(shell->RunScript(scriptPath)); } if (failed) { delete shell; printf("FAIL: Error during execution of script.\n"); return 1; } delete shell; return 0; }