Chromium Code Reviews

Unified Diff: src/isolate.cc

Issue 885043002: [V8] Added line, column and script symbols for SyntaxError (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Test added Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
« no previous file with comments | « src/isolate.h ('k') | src/parser.cc » ('j') | test/cctest/test-api.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/isolate.cc
diff --git a/src/isolate.cc b/src/isolate.cc
index ea5e3a95c93eb46aaaccbdf9b74c1c9dc89dfa15..c5d27980399942ed42f8c4bec307a6439c663997 100644
--- a/src/isolate.cc
+++ b/src/isolate.cc
@@ -1069,6 +1069,33 @@ void Isolate::ComputeLocation(MessageLocation* target) {
}
+bool Isolate::ComputeLocationFromException(MessageLocation* target,
+ Handle<Object> exception) {
+ if (!exception->IsJSObject()) return false;
+
+ Handle<Name> start_pos_symbol = factory()->error_start_pos_symbol();
+ Handle<Object> start_pos = JSObject::GetDataProperty(
+ Handle<JSObject>::cast(exception), start_pos_symbol);
+ if (!start_pos->IsSmi()) return false;
+ const int start_pos_value = Handle<Smi>::cast(start_pos)->value();
yurys 2015/02/02 07:07:56 style: We normally don't mark local variables as c
kozy 2015/02/02 09:18:56 Done.
+
+ Handle<Name> end_pos_symbol = factory()->error_end_pos_symbol();
+ Handle<Object> end_pos = JSObject::GetDataProperty(
+ Handle<JSObject>::cast(exception), end_pos_symbol);
+ if (!end_pos->IsSmi()) return false;
+ const int end_pos_value = Handle<Smi>::cast(end_pos)->value();
+
+ Handle<Name> script_symbol = factory()->error_script_symbol();
+ Handle<Object> script = JSObject::GetDataProperty(
+ Handle<JSObject>::cast(exception), script_symbol);
+ if (!script->IsScript()) return false;
+
+ Handle<Script> casted_script(Script::cast(*script));
yurys 2015/02/02 07:07:56 typo: casted -> cast
kozy 2015/02/02 09:18:57 Done.
+ *target = MessageLocation(casted_script, start_pos_value, end_pos_value);
+ return true;
+}
+
+
bool Isolate::ComputeLocationFromStackTrace(MessageLocation* target,
Handle<Object> exception) {
*target = MessageLocation(Handle<Script>(heap_.empty_script()), -1, -1);
@@ -1181,9 +1208,12 @@ Handle<JSMessageObject> Isolate::CreateMessage(Handle<Object> exception,
}
}
if (!location) {
- if (!ComputeLocationFromStackTrace(&potential_computed_location,
- exception)) {
- ComputeLocation(&potential_computed_location);
+ if (!ComputeLocationFromException(&potential_computed_location,
+ exception)) {
+ if (!ComputeLocationFromStackTrace(&potential_computed_location,
+ exception)) {
+ ComputeLocation(&potential_computed_location);
+ }
}
location = &potential_computed_location;
}
« no previous file with comments | « src/isolate.h ('k') | src/parser.cc » ('j') | test/cctest/test-api.cc » ('J')

Powered by Google App Engine