Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(795)

Unified Diff: src/liveedit.cc

Issue 11421100: Issue 2429, core implementation and the protocol change (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: clean Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/liveedit.cc
diff --git a/src/liveedit.cc b/src/liveedit.cc
index 574a37691c0a0e99e0e46617455d734ff7e50d2c..f2b9977efa4fc42d4280bede710319d3cf989f57 100644
--- a/src/liveedit.cc
+++ b/src/liveedit.cc
@@ -925,11 +925,68 @@ JSArray* LiveEdit::GatherCompileInfo(Handle<Script> script,
Handle<Object> original_source = Handle<Object>(script->source());
script->set_source(*source);
isolate->set_active_function_info_listener(&listener);
- CompileScriptForTracker(isolate, script);
+
+ Handle<Object> rethrow_exception;
+ {
+ // Creating TryCatch from public API is currently the only way to get
+ // message object. Without TryCatch the message object won't even be
+ // prepared at all.
+ v8::TryCatch try_catch;
+ try_catch.SetVerbose(true);
+
+ // A logical 'try' section.
+ CompileScriptForTracker(isolate, script);
+
+ // A logical 'catch' section.
+ if (isolate->has_pending_exception()) {
+ isolate->ReportPendingMessages();
+ 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
+ isolate->clear_pending_message();
+ }
+ 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.
+ Handle<Object> exception =
+ Utils::OpenHandle(*try_catch.Exception(), false);
+
+ // If possible, copy positions from message object to exception object.
+ 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.
+ Handle<JSObject> exception_struct = Handle<JSObject>::cast(exception);
+
+ Factory* factory = isolate->factory();
+ JSReceiver::SetProperty(exception_struct,
+ factory->LookupAsciiSymbol("startLine"),
+ Handle<Smi>(Smi::FromInt(try_catch.Message()->GetLineNumber())),
+ NONE, kNonStrictMode);
+ JSReceiver::SetProperty(exception_struct,
+ factory->LookupAsciiSymbol("startPosition"),
+ Handle<Smi>(Smi::FromInt(try_catch.Message()->GetStartPosition())),
+ NONE, kNonStrictMode);
+ JSReceiver::SetProperty(exception_struct,
+ factory->LookupAsciiSymbol("endPosition"),
+ Handle<Smi>(Smi::FromInt(try_catch.Message()->GetEndPosition())),
+ NONE, kNonStrictMode);
+ JSReceiver::SetProperty(exception_struct,
+ factory->LookupAsciiSymbol("startColumn"),
+ Handle<Smi>(Smi::FromInt(try_catch.Message()->GetStartColumn())),
+ NONE, kNonStrictMode);
+ JSReceiver::SetProperty(exception_struct,
+ factory->LookupAsciiSymbol("endColumn"),
+ Handle<Smi>(Smi::FromInt(try_catch.Message()->GetEndColumn())),
+ NONE, kNonStrictMode);
+ }
+
+ rethrow_exception = exception;
+ }
+ }
+
isolate->set_active_function_info_listener(NULL);
script->set_source(*original_source);
- return *(listener.GetResult());
+ 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
+ return *(listener.GetResult());
+ } else {
+ isolate->Throw(*rethrow_exception);
+ return 0;
+ }
}
« no previous file with comments | « src/debug-debugger.js ('k') | src/liveedit-debugger.js » ('j') | src/liveedit-debugger.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698