| 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 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 return result; | 289 return result; |
| 290 } | 290 } |
| 291 | 291 |
| 292 | 292 |
| 293 // Executes a string within the current v8 context. | 293 // Executes a string within the current v8 context. |
| 294 bool Shell::ExecuteString(Isolate* isolate, Local<String> source, | 294 bool Shell::ExecuteString(Isolate* isolate, Local<String> source, |
| 295 Local<Value> name, bool print_result, | 295 Local<Value> name, bool print_result, |
| 296 bool report_exceptions, SourceType source_type) { | 296 bool report_exceptions, SourceType source_type) { |
| 297 HandleScope handle_scope(isolate); | 297 HandleScope handle_scope(isolate); |
| 298 TryCatch try_catch(isolate); | 298 TryCatch try_catch(isolate); |
| 299 options.script_executed = true; | |
| 300 | 299 |
| 301 MaybeLocal<Value> maybe_result; | 300 MaybeLocal<Value> maybe_result; |
| 302 { | 301 { |
| 303 PerIsolateData* data = PerIsolateData::Get(isolate); | 302 PerIsolateData* data = PerIsolateData::Get(isolate); |
| 304 Local<Context> realm = | 303 Local<Context> realm = |
| 305 Local<Context>::New(isolate, data->realms_[data->realm_current_]); | 304 Local<Context>::New(isolate, data->realms_[data->realm_current_]); |
| 306 Context::Scope context_scope(realm); | 305 Context::Scope context_scope(realm); |
| 307 Local<Script> script; | 306 Local<Script> script; |
| 308 if (!Shell::CompileString(isolate, source, name, options.compile_options, | 307 if (!Shell::CompileString(isolate, source, name, options.compile_options, |
| 309 source_type).ToLocal(&script)) { | 308 source_type).ToLocal(&script)) { |
| (...skipping 1110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1420 Shell::SourceType source_type = Shell::SCRIPT; | 1419 Shell::SourceType source_type = Shell::SCRIPT; |
| 1421 if (strcmp(arg, "-e") == 0 && i + 1 < end_offset_) { | 1420 if (strcmp(arg, "-e") == 0 && i + 1 < end_offset_) { |
| 1422 // Execute argument given to -e option directly. | 1421 // Execute argument given to -e option directly. |
| 1423 HandleScope handle_scope(isolate); | 1422 HandleScope handle_scope(isolate); |
| 1424 Local<String> file_name = | 1423 Local<String> file_name = |
| 1425 String::NewFromUtf8(isolate, "unnamed", NewStringType::kNormal) | 1424 String::NewFromUtf8(isolate, "unnamed", NewStringType::kNormal) |
| 1426 .ToLocalChecked(); | 1425 .ToLocalChecked(); |
| 1427 Local<String> source = | 1426 Local<String> source = |
| 1428 String::NewFromUtf8(isolate, argv_[i + 1], NewStringType::kNormal) | 1427 String::NewFromUtf8(isolate, argv_[i + 1], NewStringType::kNormal) |
| 1429 .ToLocalChecked(); | 1428 .ToLocalChecked(); |
| 1429 Shell::options.script_executed = true; |
| 1430 if (!Shell::ExecuteString(isolate, source, file_name, false, true)) { | 1430 if (!Shell::ExecuteString(isolate, source, file_name, false, true)) { |
| 1431 exception_was_thrown = true; | 1431 exception_was_thrown = true; |
| 1432 break; | 1432 break; |
| 1433 } | 1433 } |
| 1434 ++i; | 1434 ++i; |
| 1435 continue; | 1435 continue; |
| 1436 } else if (strcmp(arg, "--module") == 0 && i + 1 < end_offset_) { | 1436 } else if (strcmp(arg, "--module") == 0 && i + 1 < end_offset_) { |
| 1437 // Treat the next file as a module. | 1437 // Treat the next file as a module. |
| 1438 source_type = Shell::MODULE; | 1438 source_type = Shell::MODULE; |
| 1439 arg = argv_[++i]; | 1439 arg = argv_[++i]; |
| 1440 } else if (arg[0] == '-') { | 1440 } else if (arg[0] == '-') { |
| 1441 // Ignore other options. They have been parsed already. | 1441 // Ignore other options. They have been parsed already. |
| 1442 continue; | 1442 continue; |
| 1443 } | 1443 } |
| 1444 | 1444 |
| 1445 // Use all other arguments as names of files to load and run. | 1445 // Use all other arguments as names of files to load and run. |
| 1446 HandleScope handle_scope(isolate); | 1446 HandleScope handle_scope(isolate); |
| 1447 Local<String> file_name = | 1447 Local<String> file_name = |
| 1448 String::NewFromUtf8(isolate, arg, NewStringType::kNormal) | 1448 String::NewFromUtf8(isolate, arg, NewStringType::kNormal) |
| 1449 .ToLocalChecked(); | 1449 .ToLocalChecked(); |
| 1450 Local<String> source = ReadFile(isolate, arg); | 1450 Local<String> source = ReadFile(isolate, arg); |
| 1451 if (source.IsEmpty()) { | 1451 if (source.IsEmpty()) { |
| 1452 printf("Error reading '%s'\n", arg); | 1452 printf("Error reading '%s'\n", arg); |
| 1453 Shell::Exit(1); | 1453 Shell::Exit(1); |
| 1454 } | 1454 } |
| 1455 Shell::options.script_executed = true; |
| 1455 if (!Shell::ExecuteString(isolate, source, file_name, false, true, | 1456 if (!Shell::ExecuteString(isolate, source, file_name, false, true, |
| 1456 source_type)) { | 1457 source_type)) { |
| 1457 exception_was_thrown = true; | 1458 exception_was_thrown = true; |
| 1458 break; | 1459 break; |
| 1459 } | 1460 } |
| 1460 } | 1461 } |
| 1461 if (exception_was_thrown != Shell::options.expected_to_throw) { | 1462 if (exception_was_thrown != Shell::options.expected_to_throw) { |
| 1462 Shell::Exit(1); | 1463 Shell::Exit(1); |
| 1463 } | 1464 } |
| 1464 } | 1465 } |
| (...skipping 989 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2454 } | 2455 } |
| 2455 | 2456 |
| 2456 } // namespace v8 | 2457 } // namespace v8 |
| 2457 | 2458 |
| 2458 | 2459 |
| 2459 #ifndef GOOGLE3 | 2460 #ifndef GOOGLE3 |
| 2460 int main(int argc, char* argv[]) { | 2461 int main(int argc, char* argv[]) { |
| 2461 return v8::Shell::Main(argc, argv); | 2462 return v8::Shell::Main(argc, argv); |
| 2462 } | 2463 } |
| 2463 #endif | 2464 #endif |
| OLD | NEW |