OLD | NEW |
1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 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 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 Handle<ObjectTemplate> global_template = ObjectTemplate::New(); | 454 Handle<ObjectTemplate> global_template = ObjectTemplate::New(); |
455 global_template->Set(String::New("print"), | 455 global_template->Set(String::New("print"), |
456 FunctionTemplate::New(Shell::Print)); | 456 FunctionTemplate::New(Shell::Print)); |
457 global_template->Set(String::New("load"), | 457 global_template->Set(String::New("load"), |
458 FunctionTemplate::New(Shell::Load)); | 458 FunctionTemplate::New(Shell::Load)); |
459 global_template->Set(String::New("version"), | 459 global_template->Set(String::New("version"), |
460 FunctionTemplate::New(Shell::Version)); | 460 FunctionTemplate::New(Shell::Version)); |
461 | 461 |
462 Persistent<Context> thread_context = Context::New(NULL, global_template); | 462 Persistent<Context> thread_context = Context::New(NULL, global_template); |
463 thread_context->SetSecurityToken(Undefined()); | 463 thread_context->SetSecurityToken(Undefined()); |
464 | 464 |
465 Context::Scope context_scope(thread_context); | 465 Context::Scope context_scope(thread_context); |
466 | 466 |
467 char* ptr = const_cast<char*>(files_.start()); | 467 char* ptr = const_cast<char*>(files_.start()); |
468 while ((ptr != NULL) && (*ptr != '\0')) { | 468 while ((ptr != NULL) && (*ptr != '\0')) { |
469 // For each newline-separated line. | 469 // For each newline-separated line. |
470 char *filename = ptr; | 470 char *filename = ptr; |
471 char* next = ::strchr(ptr, '\n'); | 471 char* next = ::strchr(ptr, '\n'); |
472 if (next != NULL) { | 472 if (next != NULL) { |
473 *next = '\0'; | 473 *next = '\0'; |
474 ptr = (next + 1); | 474 ptr = (next + 1); |
475 } else { | 475 } else { |
476 ptr = NULL; | 476 ptr = NULL; |
477 } | 477 } |
478 Handle<String> str = Shell::ReadFile(filename); | 478 Handle<String> str = Shell::ReadFile(filename); |
479 Shell::ExecuteString(str, String::New(filename), false, false); | 479 Shell::ExecuteString(str, String::New(filename), false, false); |
480 } | 480 } |
481 | 481 |
482 thread_context.Dispose(); | 482 thread_context.Dispose(); |
483 } | 483 } |
484 | 484 |
485 | 485 |
486 int Shell::Main(int argc, char* argv[]) { | 486 int Shell::Main(int argc, char* argv[]) { |
487 i::FlagList::SetFlagsFromCommandLine(&argc, argv, true); | 487 i::FlagList::SetFlagsFromCommandLine(&argc, argv, true); |
488 if (i::FLAG_help) { | 488 if (i::FLAG_help) { |
489 return 1; | 489 return 1; |
490 } | 490 } |
491 Initialize(); | 491 Initialize(); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
555 return 0; | 555 return 0; |
556 } | 556 } |
557 | 557 |
558 | 558 |
559 } // namespace v8 | 559 } // namespace v8 |
560 | 560 |
561 | 561 |
562 int main(int argc, char* argv[]) { | 562 int main(int argc, char* argv[]) { |
563 return v8::Shell::Main(argc, argv); | 563 return v8::Shell::Main(argc, argv); |
564 } | 564 } |
OLD | NEW |