| OLD | NEW |
| 1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 2008 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 26 matching lines...) Expand all Loading... |
| 37 | 37 |
| 38 | 38 |
| 39 namespace v8 { | 39 namespace v8 { |
| 40 | 40 |
| 41 | 41 |
| 42 namespace i = v8::internal; | 42 namespace i = v8::internal; |
| 43 | 43 |
| 44 | 44 |
| 45 class Counter { | 45 class Counter { |
| 46 public: | 46 public: |
| 47 explicit Counter(const wchar_t* name) | 47 explicit Counter(const char* name) |
| 48 : name_(name), value_(0) { } | 48 : name_(name), value_(0) { } |
| 49 int* GetValuePtr() { return &value_; } | 49 int* GetValuePtr() { return &value_; } |
| 50 const wchar_t* name() { return name_; } | 50 const char* name() { return name_; } |
| 51 int value() { return value_; } | 51 int value() { return value_; } |
| 52 private: | 52 private: |
| 53 const wchar_t* name_; | 53 const char* name_; |
| 54 int value_; | 54 int value_; |
| 55 }; | 55 }; |
| 56 | 56 |
| 57 | 57 |
| 58 class Shell: public i::AllStatic { | 58 class Shell: public i::AllStatic { |
| 59 public: | 59 public: |
| 60 static bool ExecuteString(Handle<String> source, | 60 static bool ExecuteString(Handle<String> source, |
| 61 Handle<Value> name, | 61 Handle<Value> name, |
| 62 bool print_result, | 62 bool print_result, |
| 63 bool report_exceptions); | 63 bool report_exceptions); |
| 64 static void ReportException(TryCatch* try_catch); | 64 static void ReportException(TryCatch* try_catch); |
| 65 static void Initialize(); | 65 static void Initialize(); |
| 66 static void OnExit(); | 66 static void OnExit(); |
| 67 static int* LookupCounter(const wchar_t* name); | 67 static int* LookupCounter(const char* name); |
| 68 static Handle<String> ReadFile(const char* name); | 68 static Handle<String> ReadFile(const char* name); |
| 69 static void RunShell(); | 69 static void RunShell(); |
| 70 static int Main(int argc, char* argv[]); | 70 static int Main(int argc, char* argv[]); |
| 71 static Handle<Array> GetCompletions(Handle<String> text, | 71 static Handle<Array> GetCompletions(Handle<String> text, |
| 72 Handle<String> full); | 72 Handle<String> full); |
| 73 | 73 |
| 74 static Handle<Value> Print(const Arguments& args); | 74 static Handle<Value> Print(const Arguments& args); |
| 75 static Handle<Value> Quit(const Arguments& args); | 75 static Handle<Value> Quit(const Arguments& args); |
| 76 static Handle<Value> Version(const Arguments& args); | 76 static Handle<Value> Version(const Arguments& args); |
| 77 static Handle<Value> Load(const Arguments& args); | 77 static Handle<Value> Load(const Arguments& args); |
| 78 | 78 |
| 79 static const char* kHistoryFileName; | 79 static const char* kHistoryFileName; |
| 80 static const char* kPrompt; | 80 static const char* kPrompt; |
| 81 private: | 81 private: |
| 82 static Persistent<Context> utility_context_; | 82 static Persistent<Context> utility_context_; |
| 83 static Persistent<Context> evaluation_context_; | 83 static Persistent<Context> evaluation_context_; |
| 84 typedef std::map<const wchar_t*, Counter*> CounterMap; | 84 typedef std::map<const char*, Counter*> CounterMap; |
| 85 static CounterMap counter_map_; | 85 static CounterMap counter_map_; |
| 86 }; | 86 }; |
| 87 | 87 |
| 88 | 88 |
| 89 class LineEditor { | 89 class LineEditor { |
| 90 public: | 90 public: |
| 91 enum Type { DUMB = 0, READLINE = 1 }; | 91 enum Type { DUMB = 0, READLINE = 1 }; |
| 92 LineEditor(Type type, const char* name); | 92 LineEditor(Type type, const char* name); |
| 93 virtual ~LineEditor() { } | 93 virtual ~LineEditor() { } |
| 94 | 94 |
| 95 virtual i::SmartPointer<char> Prompt(const char* prompt) = 0; | 95 virtual i::SmartPointer<char> Prompt(const char* prompt) = 0; |
| 96 virtual bool Open() { return true; } | 96 virtual bool Open() { return true; } |
| 97 virtual bool Close() { return true; } | 97 virtual bool Close() { return true; } |
| 98 virtual void AddHistory(const char* str) { } | 98 virtual void AddHistory(const char* str) { } |
| 99 | 99 |
| 100 const char* name() { return name_; } | 100 const char* name() { return name_; } |
| 101 static LineEditor* Get(); | 101 static LineEditor* Get(); |
| 102 private: | 102 private: |
| 103 Type type_; | 103 Type type_; |
| 104 const char* name_; | 104 const char* name_; |
| 105 LineEditor* next_; | 105 LineEditor* next_; |
| 106 static LineEditor* first_; | 106 static LineEditor* first_; |
| 107 }; | 107 }; |
| 108 | 108 |
| 109 | 109 |
| 110 } // namespace v8 | 110 } // namespace v8 |
| 111 | 111 |
| 112 | 112 |
| 113 #endif // V8_D8_H_ | 113 #endif // V8_D8_H_ |
| OLD | NEW |