| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 i::Mutex Shell::context_mutex_; | 161 i::Mutex Shell::context_mutex_; |
| 162 const i::TimeTicks Shell::kInitialTicks = i::TimeTicks::HighResolutionNow(); | 162 const i::TimeTicks Shell::kInitialTicks = i::TimeTicks::HighResolutionNow(); |
| 163 Persistent<Context> Shell::utility_context_; | 163 Persistent<Context> Shell::utility_context_; |
| 164 #endif // V8_SHARED | 164 #endif // V8_SHARED |
| 165 | 165 |
| 166 Persistent<Context> Shell::evaluation_context_; | 166 Persistent<Context> Shell::evaluation_context_; |
| 167 ShellOptions Shell::options; | 167 ShellOptions Shell::options; |
| 168 const char* Shell::kPrompt = "d8> "; | 168 const char* Shell::kPrompt = "d8> "; |
| 169 | 169 |
| 170 | 170 |
| 171 #ifndef V8_SHARED |
| 171 const int MB = 1024 * 1024; | 172 const int MB = 1024 * 1024; |
| 172 | 173 |
| 173 | |
| 174 #ifndef V8_SHARED | |
| 175 bool CounterMap::Match(void* key1, void* key2) { | 174 bool CounterMap::Match(void* key1, void* key2) { |
| 176 const char* name1 = reinterpret_cast<const char*>(key1); | 175 const char* name1 = reinterpret_cast<const char*>(key1); |
| 177 const char* name2 = reinterpret_cast<const char*>(key2); | 176 const char* name2 = reinterpret_cast<const char*>(key2); |
| 178 return strcmp(name1, name2) == 0; | 177 return strcmp(name1, name2) == 0; |
| 179 } | 178 } |
| 180 #endif // V8_SHARED | 179 #endif // V8_SHARED |
| 181 | 180 |
| 182 | 181 |
| 183 // Converts a V8 value to a C string. | 182 // Converts a V8 value to a C string. |
| 184 const char* Shell::ToCString(const v8::String::Utf8Value& value) { | 183 const char* Shell::ToCString(const v8::String::Utf8Value& value) { |
| (...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 854 } | 853 } |
| 855 return result; | 854 return result; |
| 856 } | 855 } |
| 857 }; | 856 }; |
| 858 #endif | 857 #endif |
| 859 | 858 |
| 860 | 859 |
| 861 Handle<ObjectTemplate> Shell::CreateGlobalTemplate(Isolate* isolate) { | 860 Handle<ObjectTemplate> Shell::CreateGlobalTemplate(Isolate* isolate) { |
| 862 Handle<ObjectTemplate> global_template = ObjectTemplate::New(); | 861 Handle<ObjectTemplate> global_template = ObjectTemplate::New(); |
| 863 global_template->Set(String::NewFromUtf8(isolate, "print"), | 862 global_template->Set(String::NewFromUtf8(isolate, "print"), |
| 864 FunctionTemplate::New(Print)); | 863 FunctionTemplate::New(isolate, Print)); |
| 865 global_template->Set(String::NewFromUtf8(isolate, "write"), | 864 global_template->Set(String::NewFromUtf8(isolate, "write"), |
| 866 FunctionTemplate::New(Write)); | 865 FunctionTemplate::New(isolate, Write)); |
| 867 global_template->Set(String::NewFromUtf8(isolate, "read"), | 866 global_template->Set(String::NewFromUtf8(isolate, "read"), |
| 868 FunctionTemplate::New(Read)); | 867 FunctionTemplate::New(isolate, Read)); |
| 869 global_template->Set(String::NewFromUtf8(isolate, "readbuffer"), | 868 global_template->Set(String::NewFromUtf8(isolate, "readbuffer"), |
| 870 FunctionTemplate::New(ReadBuffer)); | 869 FunctionTemplate::New(isolate, ReadBuffer)); |
| 871 global_template->Set(String::NewFromUtf8(isolate, "readline"), | 870 global_template->Set(String::NewFromUtf8(isolate, "readline"), |
| 872 FunctionTemplate::New(ReadLine)); | 871 FunctionTemplate::New(isolate, ReadLine)); |
| 873 global_template->Set(String::NewFromUtf8(isolate, "load"), | 872 global_template->Set(String::NewFromUtf8(isolate, "load"), |
| 874 FunctionTemplate::New(Load)); | 873 FunctionTemplate::New(isolate, Load)); |
| 875 global_template->Set(String::NewFromUtf8(isolate, "quit"), | 874 global_template->Set(String::NewFromUtf8(isolate, "quit"), |
| 876 FunctionTemplate::New(Quit)); | 875 FunctionTemplate::New(isolate, Quit)); |
| 877 global_template->Set(String::NewFromUtf8(isolate, "version"), | 876 global_template->Set(String::NewFromUtf8(isolate, "version"), |
| 878 FunctionTemplate::New(Version)); | 877 FunctionTemplate::New(isolate, Version)); |
| 879 | 878 |
| 880 // Bind the Realm object. | 879 // Bind the Realm object. |
| 881 Handle<ObjectTemplate> realm_template = ObjectTemplate::New(); | 880 Handle<ObjectTemplate> realm_template = ObjectTemplate::New(); |
| 882 realm_template->Set(String::NewFromUtf8(isolate, "current"), | 881 realm_template->Set(String::NewFromUtf8(isolate, "current"), |
| 883 FunctionTemplate::New(RealmCurrent)); | 882 FunctionTemplate::New(isolate, RealmCurrent)); |
| 884 realm_template->Set(String::NewFromUtf8(isolate, "owner"), | 883 realm_template->Set(String::NewFromUtf8(isolate, "owner"), |
| 885 FunctionTemplate::New(RealmOwner)); | 884 FunctionTemplate::New(isolate, RealmOwner)); |
| 886 realm_template->Set(String::NewFromUtf8(isolate, "global"), | 885 realm_template->Set(String::NewFromUtf8(isolate, "global"), |
| 887 FunctionTemplate::New(RealmGlobal)); | 886 FunctionTemplate::New(isolate, RealmGlobal)); |
| 888 realm_template->Set(String::NewFromUtf8(isolate, "create"), | 887 realm_template->Set(String::NewFromUtf8(isolate, "create"), |
| 889 FunctionTemplate::New(RealmCreate)); | 888 FunctionTemplate::New(isolate, RealmCreate)); |
| 890 realm_template->Set(String::NewFromUtf8(isolate, "dispose"), | 889 realm_template->Set(String::NewFromUtf8(isolate, "dispose"), |
| 891 FunctionTemplate::New(RealmDispose)); | 890 FunctionTemplate::New(isolate, RealmDispose)); |
| 892 realm_template->Set(String::NewFromUtf8(isolate, "switch"), | 891 realm_template->Set(String::NewFromUtf8(isolate, "switch"), |
| 893 FunctionTemplate::New(RealmSwitch)); | 892 FunctionTemplate::New(isolate, RealmSwitch)); |
| 894 realm_template->Set(String::NewFromUtf8(isolate, "eval"), | 893 realm_template->Set(String::NewFromUtf8(isolate, "eval"), |
| 895 FunctionTemplate::New(RealmEval)); | 894 FunctionTemplate::New(isolate, RealmEval)); |
| 896 realm_template->SetAccessor(String::NewFromUtf8(isolate, "shared"), | 895 realm_template->SetAccessor(String::NewFromUtf8(isolate, "shared"), |
| 897 RealmSharedGet, RealmSharedSet); | 896 RealmSharedGet, RealmSharedSet); |
| 898 global_template->Set(String::NewFromUtf8(isolate, "Realm"), realm_template); | 897 global_template->Set(String::NewFromUtf8(isolate, "Realm"), realm_template); |
| 899 | 898 |
| 900 #ifndef V8_SHARED | 899 #ifndef V8_SHARED |
| 901 Handle<ObjectTemplate> performance_template = ObjectTemplate::New(); | 900 Handle<ObjectTemplate> performance_template = ObjectTemplate::New(); |
| 902 performance_template->Set(String::NewFromUtf8(isolate, "now"), | 901 performance_template->Set(String::NewFromUtf8(isolate, "now"), |
| 903 FunctionTemplate::New(PerformanceNow)); | 902 FunctionTemplate::New(isolate, PerformanceNow)); |
| 904 global_template->Set(String::NewFromUtf8(isolate, "performance"), | 903 global_template->Set(String::NewFromUtf8(isolate, "performance"), |
| 905 performance_template); | 904 performance_template); |
| 906 #endif // V8_SHARED | 905 #endif // V8_SHARED |
| 907 | 906 |
| 908 #if !defined(V8_SHARED) && !defined(_WIN32) && !defined(_WIN64) | 907 #if !defined(V8_SHARED) && !defined(_WIN32) && !defined(_WIN64) |
| 909 Handle<ObjectTemplate> os_templ = ObjectTemplate::New(); | 908 Handle<ObjectTemplate> os_templ = ObjectTemplate::New(); |
| 910 AddOSMethods(isolate, os_templ); | 909 AddOSMethods(isolate, os_templ); |
| 911 global_template->Set(String::NewFromUtf8(isolate, "os"), os_templ); | 910 global_template->Set(String::NewFromUtf8(isolate, "os"), os_templ); |
| 912 #endif // V8_SHARED | 911 #endif // V8_SHARED |
| 913 | 912 |
| (...skipping 849 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1763 } | 1762 } |
| 1764 | 1763 |
| 1765 } // namespace v8 | 1764 } // namespace v8 |
| 1766 | 1765 |
| 1767 | 1766 |
| 1768 #ifndef GOOGLE3 | 1767 #ifndef GOOGLE3 |
| 1769 int main(int argc, char* argv[]) { | 1768 int main(int argc, char* argv[]) { |
| 1770 return v8::Shell::Main(argc, argv); | 1769 return v8::Shell::Main(argc, argv); |
| 1771 } | 1770 } |
| 1772 #endif | 1771 #endif |
| OLD | NEW |