OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 846 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
857 if (chars == NULL) return Handle<String>(); | 857 if (chars == NULL) return Handle<String>(); |
858 Handle<String> result = String::New(chars); | 858 Handle<String> result = String::New(chars); |
859 delete[] chars; | 859 delete[] chars; |
860 return result; | 860 return result; |
861 } | 861 } |
862 | 862 |
863 | 863 |
864 void Shell::RunShell() { | 864 void Shell::RunShell() { |
865 Locker locker; | 865 Locker locker; |
866 Context::Scope context_scope(evaluation_context_); | 866 Context::Scope context_scope(evaluation_context_); |
867 HandleScope handle_scope; | 867 HandleScope outer_scope; |
868 Handle<String> name = String::New("(d8)"); | 868 Handle<String> name = String::New("(d8)"); |
869 #ifndef V8_SHARED | 869 #ifndef V8_SHARED |
870 LineEditor* editor = LineEditor::Get(); | 870 LineEditor* editor = LineEditor::Get(); |
871 printf("V8 version %s [console: %s]\n", V8::GetVersion(), editor->name()); | 871 printf("V8 version %s [console: %s]\n", V8::GetVersion(), editor->name()); |
872 if (i::FLAG_debugger) { | 872 if (i::FLAG_debugger) { |
873 printf("JavaScript debugger enabled\n"); | 873 printf("JavaScript debugger enabled\n"); |
874 } | 874 } |
875 editor->Open(); | 875 editor->Open(); |
876 while (true) { | 876 while (true) { |
877 i::SmartPointer<char> input = editor->Prompt(Shell::kPrompt); | 877 i::SmartPointer<char> input = editor->Prompt(Shell::kPrompt); |
878 if (input.is_empty()) break; | 878 if (input.is_empty()) break; |
879 editor->AddHistory(*input); | 879 editor->AddHistory(*input); |
| 880 HandleScope inner_scope; |
880 ExecuteString(String::New(*input), name, true, true); | 881 ExecuteString(String::New(*input), name, true, true); |
881 } | 882 } |
882 editor->Close(); | 883 editor->Close(); |
883 #else | 884 #else |
884 printf("V8 version %s [D8 light using shared library]\n", V8::GetVersion()); | 885 printf("V8 version %s [D8 light using shared library]\n", V8::GetVersion()); |
885 static const int kBufferSize = 256; | 886 static const int kBufferSize = 256; |
886 while (true) { | 887 while (true) { |
887 char buffer[kBufferSize]; | 888 char buffer[kBufferSize]; |
888 printf("%s", Shell::kPrompt); | 889 printf("%s", Shell::kPrompt); |
889 if (fgets(buffer, kBufferSize, stdin) == NULL) break; | 890 if (fgets(buffer, kBufferSize, stdin) == NULL) break; |
| 891 HandleScope inner_scope; |
890 ExecuteString(String::New(buffer), name, true, true); | 892 ExecuteString(String::New(buffer), name, true, true); |
891 } | 893 } |
892 #endif // V8_SHARED | 894 #endif // V8_SHARED |
893 printf("\n"); | 895 printf("\n"); |
894 } | 896 } |
895 | 897 |
896 | 898 |
897 #ifndef V8_SHARED | 899 #ifndef V8_SHARED |
898 class ShellThread : public i::Thread { | 900 class ShellThread : public i::Thread { |
899 public: | 901 public: |
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1296 } | 1298 } |
1297 | 1299 |
1298 } // namespace v8 | 1300 } // namespace v8 |
1299 | 1301 |
1300 | 1302 |
1301 #ifndef GOOGLE3 | 1303 #ifndef GOOGLE3 |
1302 int main(int argc, char* argv[]) { | 1304 int main(int argc, char* argv[]) { |
1303 return v8::Shell::Main(argc, argv); | 1305 return v8::Shell::Main(argc, argv); |
1304 } | 1306 } |
1305 #endif | 1307 #endif |
OLD | NEW |