| OLD | NEW |
| 1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 i::Factory::NewStringFromUtf8(i::CStrVector(js_args[j])); | 439 i::Factory::NewStringFromUtf8(i::CStrVector(js_args[j])); |
| 440 arguments_array->set(j, *arg); | 440 arguments_array->set(j, *arg); |
| 441 } | 441 } |
| 442 i::Handle<i::JSArray> arguments_jsarray = | 442 i::Handle<i::JSArray> arguments_jsarray = |
| 443 i::Factory::NewJSArrayWithElements(arguments_array); | 443 i::Factory::NewJSArrayWithElements(arguments_array); |
| 444 global_template->Set(String::New("arguments"), | 444 global_template->Set(String::New("arguments"), |
| 445 Utils::ToLocal(arguments_jsarray)); | 445 Utils::ToLocal(arguments_jsarray)); |
| 446 | 446 |
| 447 #ifdef ENABLE_DEBUGGER_SUPPORT | 447 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 448 // Install the debugger object in the utility scope | 448 // Install the debugger object in the utility scope |
| 449 i::Debug::Load(); | 449 i::Debug* debug = i::Isolate::Current()->debug(); |
| 450 i::Handle<i::JSObject> debug | 450 debug->Load(); |
| 451 = i::Handle<i::JSObject>(i::Debug::debug_context()->global()); | 451 i::Handle<i::JSObject> js_debug |
| 452 = i::Handle<i::JSObject>(debug->debug_context()->global()); |
| 452 utility_context_->Global()->Set(String::New("$debug"), | 453 utility_context_->Global()->Set(String::New("$debug"), |
| 453 Utils::ToLocal(debug)); | 454 Utils::ToLocal(js_debug)); |
| 454 #endif | 455 #endif |
| 455 | 456 |
| 456 // Run the d8 shell utility script in the utility context | 457 // Run the d8 shell utility script in the utility context |
| 457 int source_index = i::NativesCollection<i::D8>::GetIndex("d8"); | 458 int source_index = i::NativesCollection<i::D8>::GetIndex("d8"); |
| 458 i::Vector<const char> shell_source | 459 i::Vector<const char> shell_source |
| 459 = i::NativesCollection<i::D8>::GetScriptSource(source_index); | 460 = i::NativesCollection<i::D8>::GetScriptSource(source_index); |
| 460 i::Vector<const char> shell_source_name | 461 i::Vector<const char> shell_source_name |
| 461 = i::NativesCollection<i::D8>::GetScriptName(source_index); | 462 = i::NativesCollection<i::D8>::GetScriptName(source_index); |
| 462 Handle<String> source = String::New(shell_source.start(), | 463 Handle<String> source = String::New(shell_source.start(), |
| 463 shell_source.length()); | 464 shell_source.length()); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 475 : i::Handle<i::Script>(i::Script::cast( | 476 : i::Handle<i::Script>(i::Script::cast( |
| 476 i::SharedFunctionInfo::cast(*compiled_script)->script())); | 477 i::SharedFunctionInfo::cast(*compiled_script)->script())); |
| 477 script_object->set_type(i::Smi::FromInt(i::Script::TYPE_NATIVE)); | 478 script_object->set_type(i::Smi::FromInt(i::Script::TYPE_NATIVE)); |
| 478 | 479 |
| 479 // Create the evaluation context | 480 // Create the evaluation context |
| 480 evaluation_context_ = Context::New(NULL, global_template); | 481 evaluation_context_ = Context::New(NULL, global_template); |
| 481 evaluation_context_->SetSecurityToken(Undefined()); | 482 evaluation_context_->SetSecurityToken(Undefined()); |
| 482 | 483 |
| 483 #ifdef ENABLE_DEBUGGER_SUPPORT | 484 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 484 // Set the security token of the debug context to allow access. | 485 // Set the security token of the debug context to allow access. |
| 485 i::Debug::debug_context()->set_security_token(i::Heap::undefined_value()); | 486 debug->debug_context()->set_security_token(HEAP->undefined_value()); |
| 486 | 487 |
| 487 // Start the debugger agent if requested. | 488 // Start the debugger agent if requested. |
| 488 if (i::FLAG_debugger_agent) { | 489 if (i::FLAG_debugger_agent) { |
| 489 v8::Debug::EnableAgent("d8 shell", i::FLAG_debugger_port); | 490 v8::Debug::EnableAgent("d8 shell", i::FLAG_debugger_port); |
| 490 } | 491 } |
| 491 | 492 |
| 492 // Start the in-process debugger if requested. | 493 // Start the in-process debugger if requested. |
| 493 if (i::FLAG_debugger && !i::FLAG_debugger_agent) { | 494 if (i::FLAG_debugger && !i::FLAG_debugger_agent) { |
| 494 v8::Debug::SetDebugEventListener(HandleDebugEvent); | 495 v8::Debug::SetDebugEventListener(HandleDebugEvent); |
| 495 } | 496 } |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 591 Handle<String> name = String::New("(d8)"); | 592 Handle<String> name = String::New("(d8)"); |
| 592 ExecuteString(String::New(*input), name, true, true); | 593 ExecuteString(String::New(*input), name, true, true); |
| 593 } | 594 } |
| 594 editor->Close(); | 595 editor->Close(); |
| 595 printf("\n"); | 596 printf("\n"); |
| 596 } | 597 } |
| 597 | 598 |
| 598 | 599 |
| 599 class ShellThread : public i::Thread { | 600 class ShellThread : public i::Thread { |
| 600 public: | 601 public: |
| 601 ShellThread(int no, i::Vector<const char> files) | 602 ShellThread(i::Isolate* isolate, int no, i::Vector<const char> files) |
| 602 : no_(no), files_(files) { } | 603 : i::Thread(isolate), no_(no), files_(files) { } |
| 603 virtual void Run(); | 604 virtual void Run(); |
| 604 private: | 605 private: |
| 605 int no_; | 606 int no_; |
| 606 i::Vector<const char> files_; | 607 i::Vector<const char> files_; |
| 607 }; | 608 }; |
| 608 | 609 |
| 609 | 610 |
| 610 void ShellThread::Run() { | 611 void ShellThread::Run() { |
| 611 // Prepare the context for this thread. | 612 // Prepare the context for this thread. |
| 612 Locker locker; | 613 Locker locker; |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 723 if (!ExecuteString(source, file_name, false, true)) { | 724 if (!ExecuteString(source, file_name, false, true)) { |
| 724 OnExit(); | 725 OnExit(); |
| 725 return 1; | 726 return 1; |
| 726 } | 727 } |
| 727 i++; | 728 i++; |
| 728 } else if (strcmp(str, "-p") == 0 && i + 1 < argc) { | 729 } else if (strcmp(str, "-p") == 0 && i + 1 < argc) { |
| 729 int size = 0; | 730 int size = 0; |
| 730 const char* files = ReadChars(argv[++i], &size); | 731 const char* files = ReadChars(argv[++i], &size); |
| 731 if (files == NULL) return 1; | 732 if (files == NULL) return 1; |
| 732 ShellThread* thread = | 733 ShellThread* thread = |
| 733 new ShellThread(threads.length(), | 734 new ShellThread(i::Isolate::Current(), |
| 735 threads.length(), |
| 734 i::Vector<const char>(files, size)); | 736 i::Vector<const char>(files, size)); |
| 735 thread->Start(); | 737 thread->Start(); |
| 736 threads.Add(thread); | 738 threads.Add(thread); |
| 737 } else { | 739 } else { |
| 738 // Use all other arguments as names of files to load and run. | 740 // Use all other arguments as names of files to load and run. |
| 739 HandleScope handle_scope; | 741 HandleScope handle_scope; |
| 740 Handle<String> file_name = v8::String::New(str); | 742 Handle<String> file_name = v8::String::New(str); |
| 741 Handle<String> source = ReadFile(str); | 743 Handle<String> source = ReadFile(str); |
| 742 if (source.IsEmpty()) { | 744 if (source.IsEmpty()) { |
| 743 printf("Error reading '%s'\n", str); | 745 printf("Error reading '%s'\n", str); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 774 return 0; | 776 return 0; |
| 775 } | 777 } |
| 776 | 778 |
| 777 | 779 |
| 778 } // namespace v8 | 780 } // namespace v8 |
| 779 | 781 |
| 780 | 782 |
| 781 int main(int argc, char* argv[]) { | 783 int main(int argc, char* argv[]) { |
| 782 return v8::Shell::Main(argc, argv); | 784 return v8::Shell::Main(argc, argv); |
| 783 } | 785 } |
| OLD | NEW |