• Home
  • Raw
  • Download

Lines Matching refs:v8

48 v8::Persistent<v8::Context> CreateShellContext();
49 void RunShell(v8::Handle<v8::Context> context);
51 bool ExecuteString(v8::Handle<v8::String> source,
52 v8::Handle<v8::Value> name,
55 v8::Handle<v8::Value> Print(const v8::Arguments& args);
56 v8::Handle<v8::Value> Read(const v8::Arguments& args);
57 v8::Handle<v8::Value> Load(const v8::Arguments& args);
58 v8::Handle<v8::Value> Quit(const v8::Arguments& args);
59 v8::Handle<v8::Value> Version(const v8::Arguments& args);
60 v8::Handle<v8::String> ReadFile(const char* name);
61 void ReportException(v8::TryCatch* handler);
68 v8::V8::SetFlagsFromCommandLine(&argc, argv, true); in main()
70 v8::HandleScope handle_scope; in main()
71 v8::Persistent<v8::Context> context = CreateShellContext(); in main()
81 v8::V8::Dispose(); in main()
87 const char* ToCString(const v8::String::Utf8Value& value) { in ToCString()
94 v8::Persistent<v8::Context> CreateShellContext() { in CreateShellContext()
96 v8::Handle<v8::ObjectTemplate> global = v8::ObjectTemplate::New(); in CreateShellContext()
98 global->Set(v8::String::New("print"), v8::FunctionTemplate::New(Print)); in CreateShellContext()
100 global->Set(v8::String::New("read"), v8::FunctionTemplate::New(Read)); in CreateShellContext()
102 global->Set(v8::String::New("load"), v8::FunctionTemplate::New(Load)); in CreateShellContext()
104 global->Set(v8::String::New("quit"), v8::FunctionTemplate::New(Quit)); in CreateShellContext()
106 global->Set(v8::String::New("version"), v8::FunctionTemplate::New(Version)); in CreateShellContext()
108 return v8::Context::New(NULL, global); in CreateShellContext()
115 v8::Handle<v8::Value> Print(const v8::Arguments& args) { in Print()
118 v8::HandleScope handle_scope; in Print()
124 v8::String::Utf8Value str(args[i]); in Print()
130 return v8::Undefined(); in Print()
137 v8::Handle<v8::Value> Read(const v8::Arguments& args) { in Read()
139 return v8::ThrowException(v8::String::New("Bad parameters")); in Read()
141 v8::String::Utf8Value file(args[0]); in Read()
143 return v8::ThrowException(v8::String::New("Error loading file")); in Read()
145 v8::Handle<v8::String> source = ReadFile(*file); in Read()
147 return v8::ThrowException(v8::String::New("Error loading file")); in Read()
156 v8::Handle<v8::Value> Load(const v8::Arguments& args) { in Load()
158 v8::HandleScope handle_scope; in Load()
159 v8::String::Utf8Value file(args[i]); in Load()
161 return v8::ThrowException(v8::String::New("Error loading file")); in Load()
163 v8::Handle<v8::String> source = ReadFile(*file); in Load()
165 return v8::ThrowException(v8::String::New("Error loading file")); in Load()
167 if (!ExecuteString(source, v8::String::New(*file), false, false)) { in Load()
168 return v8::ThrowException(v8::String::New("Error executing file")); in Load()
171 return v8::Undefined(); in Load()
177 v8::Handle<v8::Value> Quit(const v8::Arguments& args) { in Quit()
184 return v8::Undefined(); in Quit()
188 v8::Handle<v8::Value> Version(const v8::Arguments& args) { in Version()
189 return v8::String::New(v8::V8::GetVersion()); in Version()
194 v8::Handle<v8::String> ReadFile(const char* name) { in ReadFile()
196 if (file == NULL) return v8::Handle<v8::String>(); in ReadFile()
209 v8::Handle<v8::String> result = v8::String::New(chars, size); in ReadFile()
229 v8::Handle<v8::String> file_name = v8::String::New("unnamed"); in RunMain()
230 v8::Handle<v8::String> source = v8::String::New(argv[++i]); in RunMain()
234 v8::Handle<v8::String> file_name = v8::String::New(str); in RunMain()
235 v8::Handle<v8::String> source = ReadFile(str); in RunMain()
248 void RunShell(v8::Handle<v8::Context> context) { in RunShell()
249 printf("V8 version %s [sample shell]\n", v8::V8::GetVersion()); in RunShell()
252 v8::Context::Scope context_scope(context); in RunShell()
253 v8::Local<v8::String> name(v8::String::New("(shell)")); in RunShell()
259 v8::HandleScope handle_scope; in RunShell()
260 ExecuteString(v8::String::New(str), name, true, true); in RunShell()
267 bool ExecuteString(v8::Handle<v8::String> source, in ExecuteString()
268 v8::Handle<v8::Value> name, in ExecuteString()
271 v8::HandleScope handle_scope; in ExecuteString()
272 v8::TryCatch try_catch; in ExecuteString()
273 v8::Handle<v8::Script> script = v8::Script::Compile(source, name); in ExecuteString()
280 v8::Handle<v8::Value> result = script->Run(); in ExecuteString()
292 v8::String::Utf8Value str(result); in ExecuteString()
302 void ReportException(v8::TryCatch* try_catch) { in ReportException()
303 v8::HandleScope handle_scope; in ReportException()
304 v8::String::Utf8Value exception(try_catch->Exception()); in ReportException()
306 v8::Handle<v8::Message> message = try_catch->Message(); in ReportException()
313 v8::String::Utf8Value filename(message->GetScriptResourceName()); in ReportException()
318 v8::String::Utf8Value sourceline(message->GetSourceLine()); in ReportException()
331 v8::String::Utf8Value stack_trace(try_catch->StackTrace()); in ReportException()