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 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 v8::String::Utf8Value str(str_obj); | 450 v8::String::Utf8Value str(str_obj); |
451 int n = static_cast<int>(fwrite(*str, sizeof(**str), str.length(), stdout)); | 451 int n = static_cast<int>(fwrite(*str, sizeof(**str), str.length(), stdout)); |
452 if (n != str.length()) { | 452 if (n != str.length()) { |
453 printf("Error in fwrite\n"); | 453 printf("Error in fwrite\n"); |
454 Exit(1); | 454 Exit(1); |
455 } | 455 } |
456 } | 456 } |
457 } | 457 } |
458 | 458 |
459 | 459 |
460 void Shell::EnableProfiler(const v8::FunctionCallbackInfo<v8::Value>& args) { | |
461 V8::ResumeProfiler(); | |
462 } | |
463 | |
464 | |
465 void Shell::DisableProfiler(const v8::FunctionCallbackInfo<v8::Value>& args) { | |
466 V8::PauseProfiler(); | |
467 } | |
468 | |
469 | |
470 void Shell::Read(const v8::FunctionCallbackInfo<v8::Value>& args) { | 460 void Shell::Read(const v8::FunctionCallbackInfo<v8::Value>& args) { |
471 String::Utf8Value file(args[0]); | 461 String::Utf8Value file(args[0]); |
472 if (*file == NULL) { | 462 if (*file == NULL) { |
473 Throw("Error loading file"); | 463 Throw("Error loading file"); |
474 return; | 464 return; |
475 } | 465 } |
476 Handle<String> source = ReadFile(args.GetIsolate(), *file); | 466 Handle<String> source = ReadFile(args.GetIsolate(), *file); |
477 if (source.IsEmpty()) { | 467 if (source.IsEmpty()) { |
478 Throw("Error loading file"); | 468 Throw("Error loading file"); |
479 return; | 469 return; |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
850 global_template->Set(String::New("print"), FunctionTemplate::New(Print)); | 840 global_template->Set(String::New("print"), FunctionTemplate::New(Print)); |
851 global_template->Set(String::New("write"), FunctionTemplate::New(Write)); | 841 global_template->Set(String::New("write"), FunctionTemplate::New(Write)); |
852 global_template->Set(String::New("read"), FunctionTemplate::New(Read)); | 842 global_template->Set(String::New("read"), FunctionTemplate::New(Read)); |
853 global_template->Set(String::New("readbuffer"), | 843 global_template->Set(String::New("readbuffer"), |
854 FunctionTemplate::New(ReadBuffer)); | 844 FunctionTemplate::New(ReadBuffer)); |
855 global_template->Set(String::New("readline"), | 845 global_template->Set(String::New("readline"), |
856 FunctionTemplate::New(ReadLine)); | 846 FunctionTemplate::New(ReadLine)); |
857 global_template->Set(String::New("load"), FunctionTemplate::New(Load)); | 847 global_template->Set(String::New("load"), FunctionTemplate::New(Load)); |
858 global_template->Set(String::New("quit"), FunctionTemplate::New(Quit)); | 848 global_template->Set(String::New("quit"), FunctionTemplate::New(Quit)); |
859 global_template->Set(String::New("version"), FunctionTemplate::New(Version)); | 849 global_template->Set(String::New("version"), FunctionTemplate::New(Version)); |
860 global_template->Set(String::New("enableProfiler"), | |
861 FunctionTemplate::New(EnableProfiler)); | |
862 global_template->Set(String::New("disableProfiler"), | |
863 FunctionTemplate::New(DisableProfiler)); | |
864 | 850 |
865 // Bind the Realm object. | 851 // Bind the Realm object. |
866 Handle<ObjectTemplate> realm_template = ObjectTemplate::New(); | 852 Handle<ObjectTemplate> realm_template = ObjectTemplate::New(); |
867 realm_template->Set(String::New("current"), | 853 realm_template->Set(String::New("current"), |
868 FunctionTemplate::New(RealmCurrent)); | 854 FunctionTemplate::New(RealmCurrent)); |
869 realm_template->Set(String::New("owner"), | 855 realm_template->Set(String::New("owner"), |
870 FunctionTemplate::New(RealmOwner)); | 856 FunctionTemplate::New(RealmOwner)); |
871 realm_template->Set(String::New("global"), | 857 realm_template->Set(String::New("global"), |
872 FunctionTemplate::New(RealmGlobal)); | 858 FunctionTemplate::New(RealmGlobal)); |
873 realm_template->Set(String::New("create"), | 859 realm_template->Set(String::New("create"), |
(...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1659 } | 1645 } |
1660 | 1646 |
1661 } // namespace v8 | 1647 } // namespace v8 |
1662 | 1648 |
1663 | 1649 |
1664 #ifndef GOOGLE3 | 1650 #ifndef GOOGLE3 |
1665 int main(int argc, char* argv[]) { | 1651 int main(int argc, char* argv[]) { |
1666 return v8::Shell::Main(argc, argv); | 1652 return v8::Shell::Main(argc, argv); |
1667 } | 1653 } |
1668 #endif | 1654 #endif |
OLD | NEW |