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

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: Rebased Created 5 years, 11 months 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
« no previous file with comments | « src/isolate.h ('k') | src/parser.cc » ('j') | no next file with comments »
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 3479ae239263d596ddc3ec764efcc40ce1569cdc..259c2a2c24f62b4451f5bdd9e0771254923db832 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;
+ int start_pos_value = Handle<Smi>::cast(start_pos)->value();
+
+ 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;
+ 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> cast_script(Script::cast(*script));
+ *target = MessageLocation(cast_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') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698