| 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 907 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 918 const char* exception_string = ToCString(exception); | 918 const char* exception_string = ToCString(exception); |
| 919 Local<Message> message = try_catch->Message(); | 919 Local<Message> message = try_catch->Message(); |
| 920 if (message.IsEmpty()) { | 920 if (message.IsEmpty()) { |
| 921 // V8 didn't provide any extra information about this error; just | 921 // V8 didn't provide any extra information about this error; just |
| 922 // print the exception. | 922 // print the exception. |
| 923 printf("%s\n", exception_string); | 923 printf("%s\n", exception_string); |
| 924 } else { | 924 } else { |
| 925 // Print (filename):(line number): (message). | 925 // Print (filename):(line number): (message). |
| 926 v8::String::Utf8Value filename(message->GetScriptOrigin().ResourceName()); | 926 v8::String::Utf8Value filename(message->GetScriptOrigin().ResourceName()); |
| 927 const char* filename_string = ToCString(filename); | 927 const char* filename_string = ToCString(filename); |
| 928 int linenum = | 928 Maybe<int> maybeline = message->GetLineNumber(isolate->GetCurrentContext()); |
| 929 message->GetLineNumber(isolate->GetCurrentContext()).FromJust(); | 929 int linenum = maybeline.IsJust() ? maybeline.FromJust() : -1; |
| 930 printf("%s:%i: %s\n", filename_string, linenum, exception_string); | 930 printf("%s:%i: %s\n", filename_string, linenum, exception_string); |
| 931 // Print line of source code. | 931 if (maybeline.IsJust()) { |
| 932 v8::String::Utf8Value sourceline( | 932 // Print line of source code. |
| 933 message->GetSourceLine(isolate->GetCurrentContext()).ToLocalChecked()); | 933 v8::String::Utf8Value sourceline( |
| 934 const char* sourceline_string = ToCString(sourceline); | 934 message->GetSourceLine(isolate->GetCurrentContext()) |
| 935 printf("%s\n", sourceline_string); | 935 .ToLocalChecked()); |
| 936 // Print wavy underline (GetUnderline is deprecated). | 936 const char* sourceline_string = ToCString(sourceline); |
| 937 int start = | 937 printf("%s\n", sourceline_string); |
| 938 message->GetStartColumn(isolate->GetCurrentContext()).FromJust(); | 938 // Print wavy underline (GetUnderline is deprecated). |
| 939 for (int i = 0; i < start; i++) { | 939 int start = |
| 940 printf(" "); | 940 message->GetStartColumn(isolate->GetCurrentContext()).FromJust(); |
| 941 for (int i = 0; i < start; i++) { |
| 942 printf(" "); |
| 943 } |
| 944 int end = message->GetEndColumn(isolate->GetCurrentContext()).FromJust(); |
| 945 for (int i = start; i < end; i++) { |
| 946 printf("^"); |
| 947 } |
| 948 printf("\n"); |
| 941 } | 949 } |
| 942 int end = message->GetEndColumn(isolate->GetCurrentContext()).FromJust(); | |
| 943 for (int i = start; i < end; i++) { | |
| 944 printf("^"); | |
| 945 } | |
| 946 printf("\n"); | |
| 947 Local<Value> stack_trace_string; | 950 Local<Value> stack_trace_string; |
| 948 if (try_catch->StackTrace(isolate->GetCurrentContext()) | 951 if (try_catch->StackTrace(isolate->GetCurrentContext()) |
| 949 .ToLocal(&stack_trace_string) && | 952 .ToLocal(&stack_trace_string) && |
| 950 stack_trace_string->IsString()) { | 953 stack_trace_string->IsString()) { |
| 951 v8::String::Utf8Value stack_trace( | 954 v8::String::Utf8Value stack_trace( |
| 952 Local<String>::Cast(stack_trace_string)); | 955 Local<String>::Cast(stack_trace_string)); |
| 953 printf("%s\n", ToCString(stack_trace)); | 956 printf("%s\n", ToCString(stack_trace)); |
| 954 } | 957 } |
| 955 } | 958 } |
| 956 printf("\n"); | 959 printf("\n"); |
| (...skipping 1590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2547 } | 2550 } |
| 2548 | 2551 |
| 2549 } // namespace v8 | 2552 } // namespace v8 |
| 2550 | 2553 |
| 2551 | 2554 |
| 2552 #ifndef GOOGLE3 | 2555 #ifndef GOOGLE3 |
| 2553 int main(int argc, char* argv[]) { | 2556 int main(int argc, char* argv[]) { |
| 2554 return v8::Shell::Main(argc, argv); | 2557 return v8::Shell::Main(argc, argv); |
| 2555 } | 2558 } |
| 2556 #endif | 2559 #endif |
| OLD | NEW |