OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 } | 519 } |
520 | 520 |
521 | 521 |
522 Handle<Value> Shell::Version(const Arguments& args) { | 522 Handle<Value> Shell::Version(const Arguments& args) { |
523 return String::New(V8::GetVersion()); | 523 return String::New(V8::GetVersion()); |
524 } | 524 } |
525 | 525 |
526 | 526 |
527 void Shell::ReportException(v8::TryCatch* try_catch) { | 527 void Shell::ReportException(v8::TryCatch* try_catch) { |
528 HandleScope handle_scope; | 528 HandleScope handle_scope; |
| 529 bool enter_context = !Context::InContext(); |
| 530 if (enter_context) utility_context_->Enter(); |
529 v8::String::Utf8Value exception(try_catch->Exception()); | 531 v8::String::Utf8Value exception(try_catch->Exception()); |
530 const char* exception_string = ToCString(exception); | 532 const char* exception_string = ToCString(exception); |
531 Handle<Message> message = try_catch->Message(); | 533 Handle<Message> message = try_catch->Message(); |
532 if (message.IsEmpty()) { | 534 if (message.IsEmpty()) { |
533 // V8 didn't provide any extra information about this error; just | 535 // V8 didn't provide any extra information about this error; just |
534 // print the exception. | 536 // print the exception. |
535 printf("%s\n", exception_string); | 537 printf("%s\n", exception_string); |
536 } else { | 538 } else { |
537 // Print (filename):(line number): (message). | 539 // Print (filename):(line number): (message). |
538 v8::String::Utf8Value filename(message->GetScriptResourceName()); | 540 v8::String::Utf8Value filename(message->GetScriptResourceName()); |
(...skipping 14 matching lines...) Expand all Loading... |
553 printf("^"); | 555 printf("^"); |
554 } | 556 } |
555 printf("\n"); | 557 printf("\n"); |
556 v8::String::Utf8Value stack_trace(try_catch->StackTrace()); | 558 v8::String::Utf8Value stack_trace(try_catch->StackTrace()); |
557 if (stack_trace.length() > 0) { | 559 if (stack_trace.length() > 0) { |
558 const char* stack_trace_string = ToCString(stack_trace); | 560 const char* stack_trace_string = ToCString(stack_trace); |
559 printf("%s\n", stack_trace_string); | 561 printf("%s\n", stack_trace_string); |
560 } | 562 } |
561 } | 563 } |
562 printf("\n"); | 564 printf("\n"); |
| 565 if (enter_context) utility_context_->Exit(); |
563 } | 566 } |
564 | 567 |
565 | 568 |
566 #ifndef V8_SHARED | 569 #ifndef V8_SHARED |
567 Handle<Array> Shell::GetCompletions(Handle<String> text, Handle<String> full) { | 570 Handle<Array> Shell::GetCompletions(Handle<String> text, Handle<String> full) { |
568 HandleScope handle_scope; | 571 HandleScope handle_scope; |
569 Context::Scope context_scope(utility_context_); | 572 Context::Scope context_scope(utility_context_); |
570 Handle<Object> global = utility_context_->Global(); | 573 Handle<Object> global = utility_context_->Global(); |
571 Handle<Value> fun = global->Get(String::New("GetCompletions")); | 574 Handle<Value> fun = global->Get(String::New("GetCompletions")); |
572 static const int kArgc = 3; | 575 static const int kArgc = 3; |
(...skipping 912 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1485 } | 1488 } |
1486 | 1489 |
1487 } // namespace v8 | 1490 } // namespace v8 |
1488 | 1491 |
1489 | 1492 |
1490 #ifndef GOOGLE3 | 1493 #ifndef GOOGLE3 |
1491 int main(int argc, char* argv[]) { | 1494 int main(int argc, char* argv[]) { |
1492 return v8::Shell::Main(argc, argv); | 1495 return v8::Shell::Main(argc, argv); |
1493 } | 1496 } |
1494 #endif | 1497 #endif |
OLD | NEW |