Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(473)

Side by Side Diff: src/d8.cc

Issue 7888035: Fixed broken readline console history. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« src/d8.h ('K') | « src/d8.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 return i::SmartArrayPointer<char>(str ? i::StrDup(str) : str); 110 return i::SmartArrayPointer<char>(str ? i::StrDup(str) : str);
111 } 111 }
112 112
113 113
114 CounterMap* Shell::counter_map_; 114 CounterMap* Shell::counter_map_;
115 i::OS::MemoryMappedFile* Shell::counters_file_ = NULL; 115 i::OS::MemoryMappedFile* Shell::counters_file_ = NULL;
116 CounterCollection Shell::local_counters_; 116 CounterCollection Shell::local_counters_;
117 CounterCollection* Shell::counters_ = &local_counters_; 117 CounterCollection* Shell::counters_ = &local_counters_;
118 i::Mutex* Shell::context_mutex_(i::OS::CreateMutex()); 118 i::Mutex* Shell::context_mutex_(i::OS::CreateMutex());
119 Persistent<Context> Shell::utility_context_; 119 Persistent<Context> Shell::utility_context_;
120 LineEditor* Shell::console = NULL;
120 #endif // V8_SHARED 121 #endif // V8_SHARED
121 122
122 Persistent<Context> Shell::evaluation_context_; 123 Persistent<Context> Shell::evaluation_context_;
123 ShellOptions Shell::options; 124 ShellOptions Shell::options;
124 const char* Shell::kPrompt = "d8> "; 125 const char* Shell::kPrompt = "d8> ";
125 126
126 127
127 #ifndef V8_SHARED 128 #ifndef V8_SHARED
128 bool CounterMap::Match(void* key1, void* key2) { 129 bool CounterMap::Match(void* key1, void* key2) {
129 const char* name1 = reinterpret_cast<const char*>(key1); 130 const char* name1 = reinterpret_cast<const char*>(key1);
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after
784 // Use _exit instead of exit to avoid races between isolate 785 // Use _exit instead of exit to avoid races between isolate
785 // threads and static destructors. 786 // threads and static destructors.
786 fflush(stdout); 787 fflush(stdout);
787 fflush(stderr); 788 fflush(stderr);
788 _exit(exit_code); 789 _exit(exit_code);
789 } 790 }
790 791
791 792
792 #ifndef V8_SHARED 793 #ifndef V8_SHARED
793 void Shell::OnExit() { 794 void Shell::OnExit() {
795 console->Close();
794 if (i::FLAG_dump_counters) { 796 if (i::FLAG_dump_counters) {
795 printf("+----------------------------------------+-------------+\n"); 797 printf("+----------------------------------------+-------------+\n");
796 printf("| Name | Value |\n"); 798 printf("| Name | Value |\n");
797 printf("+----------------------------------------+-------------+\n"); 799 printf("+----------------------------------------+-------------+\n");
798 for (CounterMap::Iterator i(counter_map_); i.More(); i.Next()) { 800 for (CounterMap::Iterator i(counter_map_); i.More(); i.Next()) {
799 Counter* counter = i.CurrentValue(); 801 Counter* counter = i.CurrentValue();
800 if (counter->is_histogram()) { 802 if (counter->is_histogram()) {
801 printf("| c:%-36s | %11i |\n", i.CurrentKey(), counter->count()); 803 printf("| c:%-36s | %11i |\n", i.CurrentKey(), counter->count());
802 printf("| t:%-36s | %11i |\n", i.CurrentKey(), counter->sample_total()); 804 printf("| t:%-36s | %11i |\n", i.CurrentKey(), counter->sample_total());
803 } else { 805 } else {
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
888 return result; 890 return result;
889 } 891 }
890 892
891 893
892 void Shell::RunShell() { 894 void Shell::RunShell() {
893 Locker locker; 895 Locker locker;
894 Context::Scope context_scope(evaluation_context_); 896 Context::Scope context_scope(evaluation_context_);
895 HandleScope outer_scope; 897 HandleScope outer_scope;
896 Handle<String> name = String::New("(d8)"); 898 Handle<String> name = String::New("(d8)");
897 #ifndef V8_SHARED 899 #ifndef V8_SHARED
898 LineEditor* editor = LineEditor::Get(); 900 console = LineEditor::Get();
899 printf("V8 version %s [console: %s]\n", V8::GetVersion(), editor->name()); 901 printf("V8 version %s [console: %s]\n", V8::GetVersion(), console->name());
900 if (i::FLAG_debugger) { 902 if (i::FLAG_debugger) {
901 printf("JavaScript debugger enabled\n"); 903 printf("JavaScript debugger enabled\n");
902 } 904 }
903 editor->Open(); 905 console->Open();
904 while (true) { 906 while (true) {
905 i::SmartArrayPointer<char> input = editor->Prompt(Shell::kPrompt); 907 i::SmartArrayPointer<char> input = console->Prompt(Shell::kPrompt);
906 if (input.is_empty()) break; 908 if (input.is_empty()) break;
907 editor->AddHistory(*input); 909 console->AddHistory(*input);
908 HandleScope inner_scope; 910 HandleScope inner_scope;
909 ExecuteString(String::New(*input), name, true, true); 911 ExecuteString(String::New(*input), name, true, true);
910 } 912 }
911 editor->Close(); 913 console->Close();
912 #else 914 #else
913 printf("V8 version %s [D8 light using shared library]\n", V8::GetVersion()); 915 printf("V8 version %s [D8 light using shared library]\n", V8::GetVersion());
914 static const int kBufferSize = 256; 916 static const int kBufferSize = 256;
915 while (true) { 917 while (true) {
916 char buffer[kBufferSize]; 918 char buffer[kBufferSize];
917 printf("%s", Shell::kPrompt); 919 printf("%s", Shell::kPrompt);
918 if (fgets(buffer, kBufferSize, stdin) == NULL) break; 920 if (fgets(buffer, kBufferSize, stdin) == NULL) break;
919 HandleScope inner_scope; 921 HandleScope inner_scope;
920 ExecuteString(String::New(buffer), name, true, true); 922 ExecuteString(String::New(buffer), name, true, true);
921 } 923 }
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
1345 } 1347 }
1346 1348
1347 } // namespace v8 1349 } // namespace v8
1348 1350
1349 1351
1350 #ifndef GOOGLE3 1352 #ifndef GOOGLE3
1351 int main(int argc, char* argv[]) { 1353 int main(int argc, char* argv[]) {
1352 return v8::Shell::Main(argc, argv); 1354 return v8::Shell::Main(argc, argv);
1353 } 1355 }
1354 #endif 1356 #endif
OLDNEW
« src/d8.h ('K') | « src/d8.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698