Lines Matching refs:v8
47 v8::Local<v8::Context> CreateShellContext(v8::Isolate* isolate);
48 void RunShell(v8::Local<v8::Context> context, v8::Platform* platform);
49 int RunMain(v8::Isolate* isolate, v8::Platform* platform, int argc,
51 bool ExecuteString(v8::Isolate* isolate, v8::Local<v8::String> source,
52 v8::Local<v8::Value> name, bool print_result,
54 void Print(const v8::FunctionCallbackInfo<v8::Value>& args);
55 void Read(const v8::FunctionCallbackInfo<v8::Value>& args);
56 void Load(const v8::FunctionCallbackInfo<v8::Value>& args);
57 void Quit(const v8::FunctionCallbackInfo<v8::Value>& args);
58 void Version(const v8::FunctionCallbackInfo<v8::Value>& args);
59 v8::MaybeLocal<v8::String> ReadFile(v8::Isolate* isolate, const char* name);
60 void ReportException(v8::Isolate* isolate, v8::TryCatch* handler);
67 v8::V8::InitializeICUDefaultLocation(argv[0]); in main()
68 v8::V8::InitializeExternalStartupData(argv[0]); in main()
69 std::unique_ptr<v8::Platform> platform = v8::platform::NewDefaultPlatform(); in main()
70 v8::V8::InitializePlatform(platform.get()); in main()
71 v8::V8::Initialize(); in main()
72 v8::V8::SetFlagsFromCommandLine(&argc, argv, true); in main()
73 v8::Isolate::CreateParams create_params; in main()
75 v8::ArrayBuffer::Allocator::NewDefaultAllocator(); in main()
76 v8::Isolate* isolate = v8::Isolate::New(create_params); in main()
80 v8::Isolate::Scope isolate_scope(isolate); in main()
81 v8::HandleScope handle_scope(isolate); in main()
82 v8::Local<v8::Context> context = CreateShellContext(isolate); in main()
87 v8::Context::Scope context_scope(context); in main()
92 v8::V8::Dispose(); in main()
93 v8::V8::ShutdownPlatform(); in main()
100 const char* ToCString(const v8::String::Utf8Value& value) { in ToCString()
107 v8::Local<v8::Context> CreateShellContext(v8::Isolate* isolate) { in CreateShellContext()
109 v8::Local<v8::ObjectTemplate> global = v8::ObjectTemplate::New(isolate); in CreateShellContext()
112 v8::String::NewFromUtf8(isolate, "print", v8::NewStringType::kNormal) in CreateShellContext()
114 v8::FunctionTemplate::New(isolate, Print)); in CreateShellContext()
116 global->Set(v8::String::NewFromUtf8( in CreateShellContext()
117 isolate, "read", v8::NewStringType::kNormal).ToLocalChecked(), in CreateShellContext()
118 v8::FunctionTemplate::New(isolate, Read)); in CreateShellContext()
120 global->Set(v8::String::NewFromUtf8( in CreateShellContext()
121 isolate, "load", v8::NewStringType::kNormal).ToLocalChecked(), in CreateShellContext()
122 v8::FunctionTemplate::New(isolate, Load)); in CreateShellContext()
124 global->Set(v8::String::NewFromUtf8( in CreateShellContext()
125 isolate, "quit", v8::NewStringType::kNormal).ToLocalChecked(), in CreateShellContext()
126 v8::FunctionTemplate::New(isolate, Quit)); in CreateShellContext()
129 v8::String::NewFromUtf8(isolate, "version", v8::NewStringType::kNormal) in CreateShellContext()
131 v8::FunctionTemplate::New(isolate, Version)); in CreateShellContext()
133 return v8::Context::New(isolate, NULL, global); in CreateShellContext()
140 void Print(const v8::FunctionCallbackInfo<v8::Value>& args) { in Print()
143 v8::HandleScope handle_scope(args.GetIsolate()); in Print()
149 v8::String::Utf8Value str(args.GetIsolate(), args[i]); in Print()
161 void Read(const v8::FunctionCallbackInfo<v8::Value>& args) { in Read()
164 v8::String::NewFromUtf8(args.GetIsolate(), "Bad parameters", in Read()
165 v8::NewStringType::kNormal).ToLocalChecked()); in Read()
168 v8::String::Utf8Value file(args.GetIsolate(), args[0]); in Read()
171 v8::String::NewFromUtf8(args.GetIsolate(), "Error loading file", in Read()
172 v8::NewStringType::kNormal).ToLocalChecked()); in Read()
175 v8::Local<v8::String> source; in Read()
178 v8::String::NewFromUtf8(args.GetIsolate(), "Error loading file", in Read()
179 v8::NewStringType::kNormal).ToLocalChecked()); in Read()
189 void Load(const v8::FunctionCallbackInfo<v8::Value>& args) { in Load()
191 v8::HandleScope handle_scope(args.GetIsolate()); in Load()
192 v8::String::Utf8Value file(args.GetIsolate(), args[i]); in Load()
195 v8::String::NewFromUtf8(args.GetIsolate(), "Error loading file", in Load()
196 v8::NewStringType::kNormal).ToLocalChecked()); in Load()
199 v8::Local<v8::String> source; in Load()
202 v8::String::NewFromUtf8(args.GetIsolate(), "Error loading file", in Load()
203 v8::NewStringType::kNormal).ToLocalChecked()); in Load()
208 v8::String::NewFromUtf8(args.GetIsolate(), "Error executing file", in Load()
209 v8::NewStringType::kNormal).ToLocalChecked()); in Load()
218 void Quit(const v8::FunctionCallbackInfo<v8::Value>& args) { in Quit()
229 void Version(const v8::FunctionCallbackInfo<v8::Value>& args) { in Version()
231 v8::String::NewFromUtf8(args.GetIsolate(), v8::V8::GetVersion(), in Version()
232 v8::NewStringType::kNormal).ToLocalChecked()); in Version()
237 v8::MaybeLocal<v8::String> ReadFile(v8::Isolate* isolate, const char* name) { in ReadFile()
239 if (file == NULL) return v8::MaybeLocal<v8::String>(); in ReadFile()
251 return v8::MaybeLocal<v8::String>(); in ReadFile()
255 v8::MaybeLocal<v8::String> result = v8::String::NewFromUtf8( in ReadFile()
256 isolate, chars, v8::NewStringType::kNormal, static_cast<int>(size)); in ReadFile()
263 int RunMain(v8::Isolate* isolate, v8::Platform* platform, int argc, in RunMain()
278 v8::Local<v8::String> file_name = in RunMain()
279 v8::String::NewFromUtf8(isolate, "unnamed", in RunMain()
280 v8::NewStringType::kNormal).ToLocalChecked(); in RunMain()
281 v8::Local<v8::String> source; in RunMain()
282 if (!v8::String::NewFromUtf8(isolate, argv[++i], in RunMain()
283 v8::NewStringType::kNormal) in RunMain()
288 while (v8::platform::PumpMessageLoop(platform, isolate)) continue; in RunMain()
292 v8::Local<v8::String> file_name = in RunMain()
293 v8::String::NewFromUtf8(isolate, str, v8::NewStringType::kNormal) in RunMain()
295 v8::Local<v8::String> source; in RunMain()
301 while (v8::platform::PumpMessageLoop(platform, isolate)) continue; in RunMain()
310 void RunShell(v8::Local<v8::Context> context, v8::Platform* platform) { in RunShell()
311 fprintf(stderr, "V8 version %s [sample shell]\n", v8::V8::GetVersion()); in RunShell()
314 v8::Context::Scope context_scope(context); in RunShell()
315 v8::Local<v8::String> name( in RunShell()
316 v8::String::NewFromUtf8(context->GetIsolate(), "(shell)", in RunShell()
317 v8::NewStringType::kNormal).ToLocalChecked()); in RunShell()
323 v8::HandleScope handle_scope(context->GetIsolate()); in RunShell()
326 v8::String::NewFromUtf8(context->GetIsolate(), str, in RunShell()
327 v8::NewStringType::kNormal).ToLocalChecked(), in RunShell()
329 while (v8::platform::PumpMessageLoop(platform, context->GetIsolate())) in RunShell()
337 bool ExecuteString(v8::Isolate* isolate, v8::Local<v8::String> source, in ExecuteString()
338 v8::Local<v8::Value> name, bool print_result, in ExecuteString()
340 v8::HandleScope handle_scope(isolate); in ExecuteString()
341 v8::TryCatch try_catch(isolate); in ExecuteString()
342 v8::ScriptOrigin origin(name); in ExecuteString()
343 v8::Local<v8::Context> context(isolate->GetCurrentContext()); in ExecuteString()
344 v8::Local<v8::Script> script; in ExecuteString()
345 if (!v8::Script::Compile(context, source, &origin).ToLocal(&script)) { in ExecuteString()
351 v8::Local<v8::Value> result; in ExecuteString()
363 v8::String::Utf8Value str(isolate, result); in ExecuteString()
373 void ReportException(v8::Isolate* isolate, v8::TryCatch* try_catch) { in ReportException()
374 v8::HandleScope handle_scope(isolate); in ReportException()
375 v8::String::Utf8Value exception(isolate, try_catch->Exception()); in ReportException()
377 v8::Local<v8::Message> message = try_catch->Message(); in ReportException()
384 v8::String::Utf8Value filename(isolate, in ReportException()
386 v8::Local<v8::Context> context(isolate->GetCurrentContext()); in ReportException()
391 v8::String::Utf8Value sourceline( in ReportException()
405 v8::Local<v8::Value> stack_trace_string; in ReportException()
408 v8::Local<v8::String>::Cast(stack_trace_string)->Length() > 0) { in ReportException()
409 v8::String::Utf8Value stack_trace(isolate, stack_trace_string); in ReportException()