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 // 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 907 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 918 | 918 |
| 919 | 919 |
| 920 JSArray* LiveEdit::GatherCompileInfo(Handle<Script> script, | 920 JSArray* LiveEdit::GatherCompileInfo(Handle<Script> script, |
| 921 Handle<String> source) { | 921 Handle<String> source) { |
| 922 Isolate* isolate = Isolate::Current(); | 922 Isolate* isolate = Isolate::Current(); |
| 923 | 923 |
| 924 FunctionInfoListener listener; | 924 FunctionInfoListener listener; |
| 925 Handle<Object> original_source = Handle<Object>(script->source()); | 925 Handle<Object> original_source = Handle<Object>(script->source()); |
| 926 script->set_source(*source); | 926 script->set_source(*source); |
| 927 isolate->set_active_function_info_listener(&listener); | 927 isolate->set_active_function_info_listener(&listener); |
| 928 CompileScriptForTracker(isolate, script); | 928 |
| 929 Handle<Object> rethrow_exception; | |
| 930 { | |
| 931 // Creating TryCatch from public API is currently the only way to get | |
| 932 // message object. Without TryCatch the message object won't even be | |
| 933 // prepared at all. | |
| 934 v8::TryCatch try_catch; | |
| 935 try_catch.SetVerbose(true); | |
| 936 | |
| 937 // A logical 'try' section. | |
| 938 CompileScriptForTracker(isolate, script); | |
| 939 | |
| 940 // A logical 'catch' section. | |
| 941 if (isolate->has_pending_exception()) { | |
| 942 isolate->ReportPendingMessages(); | |
| 943 isolate->clear_pending_exception(); | |
|
Yang
2012/11/29 16:38:57
If I'm not mistaken, ReportPendingMessages() alrea
Peter Rybin
2012/11/29 23:16:05
It does clear message. I don't see that it clears
| |
| 944 isolate->clear_pending_message(); | |
| 945 } | |
| 946 if (!try_catch.Exception().IsEmpty()) { | |
|
Yang
2012/11/29 16:38:57
use try_catch.HasCaught() seems cleaner.
Peter Rybin
2012/11/29 23:16:05
Done.
| |
| 947 Handle<Object> exception = | |
| 948 Utils::OpenHandle(*try_catch.Exception(), false); | |
| 949 | |
| 950 // If possible, copy positions from message object to exception object. | |
| 951 if (exception->IsJSObject() && !try_catch.Message().IsEmpty()) { | |
|
Yang
2012/11/29 16:38:57
It seems that GetLineNumber() and the Get*Column()
Peter Rybin
2012/11/29 23:16:05
Done.
| |
| 952 Handle<JSObject> exception_struct = Handle<JSObject>::cast(exception); | |
| 953 | |
| 954 Factory* factory = isolate->factory(); | |
| 955 JSReceiver::SetProperty(exception_struct, | |
| 956 factory->LookupAsciiSymbol("startLine"), | |
| 957 Handle<Smi>(Smi::FromInt(try_catch.Message()->GetLineNumber())), | |
| 958 NONE, kNonStrictMode); | |
| 959 JSReceiver::SetProperty(exception_struct, | |
| 960 factory->LookupAsciiSymbol("startPosition"), | |
| 961 Handle<Smi>(Smi::FromInt(try_catch.Message()->GetStartPosition())), | |
| 962 NONE, kNonStrictMode); | |
| 963 JSReceiver::SetProperty(exception_struct, | |
| 964 factory->LookupAsciiSymbol("endPosition"), | |
| 965 Handle<Smi>(Smi::FromInt(try_catch.Message()->GetEndPosition())), | |
| 966 NONE, kNonStrictMode); | |
| 967 JSReceiver::SetProperty(exception_struct, | |
| 968 factory->LookupAsciiSymbol("startColumn"), | |
| 969 Handle<Smi>(Smi::FromInt(try_catch.Message()->GetStartColumn())), | |
| 970 NONE, kNonStrictMode); | |
| 971 JSReceiver::SetProperty(exception_struct, | |
| 972 factory->LookupAsciiSymbol("endColumn"), | |
| 973 Handle<Smi>(Smi::FromInt(try_catch.Message()->GetEndColumn())), | |
| 974 NONE, kNonStrictMode); | |
| 975 } | |
| 976 | |
| 977 rethrow_exception = exception; | |
| 978 } | |
| 979 } | |
| 980 | |
| 929 isolate->set_active_function_info_listener(NULL); | 981 isolate->set_active_function_info_listener(NULL); |
| 930 script->set_source(*original_source); | 982 script->set_source(*original_source); |
| 931 | 983 |
| 932 return *(listener.GetResult()); | 984 if (rethrow_exception.is_null()) { |
|
Yang
2012/11/29 16:38:57
Would it be possible to use try_catch.ReThrow()?
Peter Rybin
2012/11/29 23:16:05
I don't see a nice way to reach TryCatch outside f
| |
| 985 return *(listener.GetResult()); | |
| 986 } else { | |
| 987 isolate->Throw(*rethrow_exception); | |
| 988 return 0; | |
| 989 } | |
| 933 } | 990 } |
| 934 | 991 |
| 935 | 992 |
| 936 void LiveEdit::WrapSharedFunctionInfos(Handle<JSArray> array) { | 993 void LiveEdit::WrapSharedFunctionInfos(Handle<JSArray> array) { |
| 937 HandleScope scope; | 994 HandleScope scope; |
| 938 int len = GetArrayLength(array); | 995 int len = GetArrayLength(array); |
| 939 for (int i = 0; i < len; i++) { | 996 for (int i = 0; i < len; i++) { |
| 940 Handle<SharedFunctionInfo> info( | 997 Handle<SharedFunctionInfo> info( |
| 941 SharedFunctionInfo::cast(array->GetElementNoExceptionThrown(i))); | 998 SharedFunctionInfo::cast(array->GetElementNoExceptionThrown(i))); |
| 942 SharedInfoWrapper info_wrapper = SharedInfoWrapper::Create(); | 999 SharedInfoWrapper info_wrapper = SharedInfoWrapper::Create(); |
| (...skipping 1113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2056 | 2113 |
| 2057 bool LiveEditFunctionTracker::IsActive(Isolate* isolate) { | 2114 bool LiveEditFunctionTracker::IsActive(Isolate* isolate) { |
| 2058 return false; | 2115 return false; |
| 2059 } | 2116 } |
| 2060 | 2117 |
| 2061 #endif // ENABLE_DEBUGGER_SUPPORT | 2118 #endif // ENABLE_DEBUGGER_SUPPORT |
| 2062 | 2119 |
| 2063 | 2120 |
| 2064 | 2121 |
| 2065 } } // namespace v8::internal | 2122 } } // namespace v8::internal |
| OLD | NEW |