Chromium Code Reviews| 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 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 580 } else { | 580 } else { |
| 581 return String::Concat( | 581 return String::Concat( |
| 582 accumulator, String::NewFromUtf8(isolate, buffer, | 582 accumulator, String::NewFromUtf8(isolate, buffer, |
| 583 String::kNormalString, length - 1)); | 583 String::kNormalString, length - 1)); |
| 584 } | 584 } |
| 585 } | 585 } |
| 586 } | 586 } |
| 587 | 587 |
| 588 | 588 |
| 589 void Shell::Load(const v8::FunctionCallbackInfo<v8::Value>& args) { | 589 void Shell::Load(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 590 Isolate* isolate = args.GetIsolate(); | |
| 590 for (int i = 0; i < args.Length(); i++) { | 591 for (int i = 0; i < args.Length(); i++) { |
| 591 HandleScope handle_scope(args.GetIsolate()); | 592 HandleScope handle_scope(isolate); |
| 592 String::Utf8Value file(args[i]); | 593 String::Utf8Value file(args[i]); |
| 593 if (*file == NULL) { | 594 if (*file == NULL) { |
| 594 Throw(args.GetIsolate(), "Error loading file"); | 595 Throw(isolate, "Error loading file"); |
| 595 return; | 596 return; |
| 596 } | 597 } |
| 597 Handle<String> source = ReadFile(args.GetIsolate(), *file); | 598 Handle<String> source = ReadFile(isolate, *file); |
| 598 if (source.IsEmpty()) { | 599 if (source.IsEmpty()) { |
| 599 Throw(args.GetIsolate(), "Error loading file"); | 600 Throw(isolate, "Error loading file"); |
| 600 return; | 601 return; |
| 601 } | 602 } |
| 602 if (!ExecuteString(args.GetIsolate(), | 603 if (!ExecuteString(isolate, source, String::NewFromUtf8(isolate, *file), |
| 603 source, | 604 false, true)) { |
| 604 String::NewFromUtf8(args.GetIsolate(), *file), | 605 // Exception is already reported, so clear it before throwing another one. |
| 605 false, | 606 reinterpret_cast<i::Isolate*>(isolate)->clear_pending_exception(); |
|
Yang
2014/12/23 22:16:09
Can we assert that there is indeed a pending excep
| |
| 606 true)) { | 607 Throw(isolate, "Error executing file"); |
| 607 Throw(args.GetIsolate(), "Error executing file"); | |
| 608 return; | 608 return; |
| 609 } | 609 } |
| 610 } | 610 } |
| 611 } | 611 } |
| 612 | 612 |
| 613 | 613 |
| 614 void Shell::Quit(const v8::FunctionCallbackInfo<v8::Value>& args) { | 614 void Shell::Quit(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 615 int exit_code = args[0]->Int32Value(); | 615 int exit_code = args[0]->Int32Value(); |
| 616 OnExit(args.GetIsolate()); | 616 OnExit(args.GetIsolate()); |
| 617 exit(exit_code); | 617 exit(exit_code); |
| (...skipping 1132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1750 } | 1750 } |
| 1751 | 1751 |
| 1752 } // namespace v8 | 1752 } // namespace v8 |
| 1753 | 1753 |
| 1754 | 1754 |
| 1755 #ifndef GOOGLE3 | 1755 #ifndef GOOGLE3 |
| 1756 int main(int argc, char* argv[]) { | 1756 int main(int argc, char* argv[]) { |
| 1757 return v8::Shell::Main(argc, argv); | 1757 return v8::Shell::Main(argc, argv); |
| 1758 } | 1758 } |
| 1759 #endif | 1759 #endif |
| OLD | NEW |