OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 | 5 |
6 // Defined when linking against shared lib on Windows. | 6 // Defined when linking against shared lib on Windows. |
7 #if defined(USING_V8_SHARED) && !defined(V8_SHARED) | 7 #if defined(USING_V8_SHARED) && !defined(V8_SHARED) |
8 #define V8_SHARED | 8 #define V8_SHARED |
9 #endif | 9 #endif |
10 | 10 |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 return result; | 368 return result; |
369 } | 369 } |
370 | 370 |
371 | 371 |
372 // Executes a string within the current v8 context. | 372 // Executes a string within the current v8 context. |
373 bool Shell::ExecuteString(Isolate* isolate, Local<String> source, | 373 bool Shell::ExecuteString(Isolate* isolate, Local<String> source, |
374 Local<Value> name, bool print_result, | 374 Local<Value> name, bool print_result, |
375 bool report_exceptions, SourceType source_type) { | 375 bool report_exceptions, SourceType source_type) { |
376 HandleScope handle_scope(isolate); | 376 HandleScope handle_scope(isolate); |
377 TryCatch try_catch(isolate); | 377 TryCatch try_catch(isolate); |
378 try_catch.SetVerbose(true); | |
379 | 378 |
380 MaybeLocal<Value> maybe_result; | 379 MaybeLocal<Value> maybe_result; |
381 { | 380 { |
382 PerIsolateData* data = PerIsolateData::Get(isolate); | 381 PerIsolateData* data = PerIsolateData::Get(isolate); |
383 Local<Context> realm = | 382 Local<Context> realm = |
384 Local<Context>::New(isolate, data->realms_[data->realm_current_]); | 383 Local<Context>::New(isolate, data->realms_[data->realm_current_]); |
385 Context::Scope context_scope(realm); | 384 Context::Scope context_scope(realm); |
386 Local<Script> script; | 385 Local<Script> script; |
387 if (!Shell::CompileString(isolate, source, name, options.compile_options, | 386 if (!Shell::CompileString(isolate, source, name, options.compile_options, |
388 source_type).ToLocal(&script)) { | 387 source_type).ToLocal(&script)) { |
(...skipping 852 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1241 Local<ObjectTemplate> os_templ = ObjectTemplate::New(isolate); | 1240 Local<ObjectTemplate> os_templ = ObjectTemplate::New(isolate); |
1242 AddOSMethods(isolate, os_templ); | 1241 AddOSMethods(isolate, os_templ); |
1243 global_template->Set( | 1242 global_template->Set( |
1244 String::NewFromUtf8(isolate, "os", NewStringType::kNormal) | 1243 String::NewFromUtf8(isolate, "os", NewStringType::kNormal) |
1245 .ToLocalChecked(), | 1244 .ToLocalChecked(), |
1246 os_templ); | 1245 os_templ); |
1247 | 1246 |
1248 return global_template; | 1247 return global_template; |
1249 } | 1248 } |
1250 | 1249 |
1251 static void EmptyMessageCallback(Local<Message> message, Local<Value> error) { | |
1252 // Nothing to be done here, exceptions thrown up to the shell will be reported | |
1253 // separately by {Shell::ReportException} after they are caught. | |
1254 } | |
1255 | 1250 |
1256 void Shell::Initialize(Isolate* isolate) { | 1251 void Shell::Initialize(Isolate* isolate) { |
1257 #ifndef V8_SHARED | 1252 #ifndef V8_SHARED |
1258 // Set up counters | 1253 // Set up counters |
1259 if (i::StrLength(i::FLAG_map_counters) != 0) | 1254 if (i::StrLength(i::FLAG_map_counters) != 0) |
1260 MapCounters(isolate, i::FLAG_map_counters); | 1255 MapCounters(isolate, i::FLAG_map_counters); |
1261 #endif // !V8_SHARED | 1256 #endif // !V8_SHARED |
1262 // Disable default message reporting. | |
1263 isolate->AddMessageListener(EmptyMessageCallback); | |
1264 } | 1257 } |
1265 | 1258 |
1266 | 1259 |
1267 Local<Context> Shell::CreateEvaluationContext(Isolate* isolate) { | 1260 Local<Context> Shell::CreateEvaluationContext(Isolate* isolate) { |
1268 #ifndef V8_SHARED | 1261 #ifndef V8_SHARED |
1269 // This needs to be a critical section since this is not thread-safe | 1262 // This needs to be a critical section since this is not thread-safe |
1270 base::LockGuard<base::Mutex> lock_guard(context_mutex_.Pointer()); | 1263 base::LockGuard<base::Mutex> lock_guard(context_mutex_.Pointer()); |
1271 #endif // !V8_SHARED | 1264 #endif // !V8_SHARED |
1272 // Initialize the global objects | 1265 // Initialize the global objects |
1273 Local<ObjectTemplate> global_template = CreateGlobalTemplate(isolate); | 1266 Local<ObjectTemplate> global_template = CreateGlobalTemplate(isolate); |
(...skipping 1288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2562 } | 2555 } |
2563 | 2556 |
2564 } // namespace v8 | 2557 } // namespace v8 |
2565 | 2558 |
2566 | 2559 |
2567 #ifndef GOOGLE3 | 2560 #ifndef GOOGLE3 |
2568 int main(int argc, char* argv[]) { | 2561 int main(int argc, char* argv[]) { |
2569 return v8::Shell::Main(argc, argv); | 2562 return v8::Shell::Main(argc, argv); |
2570 } | 2563 } |
2571 #endif | 2564 #endif |
OLD | NEW |