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

Side by Side 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, 10 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 unified diff | Download patch
« no previous file with comments | « src/isolate.h ('k') | src/parser.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include <stdlib.h> 5 #include <stdlib.h>
6 6
7 #include <fstream> // NOLINT(readability/streams) 7 #include <fstream> // NOLINT(readability/streams)
8 #include <sstream> 8 #include <sstream>
9 9
10 #include "src/v8.h" 10 #include "src/v8.h"
(...skipping 1051 matching lines...) Expand 10 before | Expand all | Expand 10 after
1062 !(Script::cast(script)->source()->IsUndefined())) { 1062 !(Script::cast(script)->source()->IsUndefined())) {
1063 int pos = frame->LookupCode()->SourcePosition(frame->pc()); 1063 int pos = frame->LookupCode()->SourcePosition(frame->pc());
1064 // Compute the location from the function and the reloc info. 1064 // Compute the location from the function and the reloc info.
1065 Handle<Script> casted_script(Script::cast(script)); 1065 Handle<Script> casted_script(Script::cast(script));
1066 *target = MessageLocation(casted_script, pos, pos + 1, handle(fun)); 1066 *target = MessageLocation(casted_script, pos, pos + 1, handle(fun));
1067 } 1067 }
1068 } 1068 }
1069 } 1069 }
1070 1070
1071 1071
1072 bool Isolate::ComputeLocationFromException(MessageLocation* target,
1073 Handle<Object> exception) {
1074 if (!exception->IsJSObject()) return false;
1075
1076 Handle<Name> start_pos_symbol = factory()->error_start_pos_symbol();
1077 Handle<Object> start_pos = JSObject::GetDataProperty(
1078 Handle<JSObject>::cast(exception), start_pos_symbol);
1079 if (!start_pos->IsSmi()) return false;
1080 int start_pos_value = Handle<Smi>::cast(start_pos)->value();
1081
1082 Handle<Name> end_pos_symbol = factory()->error_end_pos_symbol();
1083 Handle<Object> end_pos = JSObject::GetDataProperty(
1084 Handle<JSObject>::cast(exception), end_pos_symbol);
1085 if (!end_pos->IsSmi()) return false;
1086 int end_pos_value = Handle<Smi>::cast(end_pos)->value();
1087
1088 Handle<Name> script_symbol = factory()->error_script_symbol();
1089 Handle<Object> script = JSObject::GetDataProperty(
1090 Handle<JSObject>::cast(exception), script_symbol);
1091 if (!script->IsScript()) return false;
1092
1093 Handle<Script> cast_script(Script::cast(*script));
1094 *target = MessageLocation(cast_script, start_pos_value, end_pos_value);
1095 return true;
1096 }
1097
1098
1072 bool Isolate::ComputeLocationFromStackTrace(MessageLocation* target, 1099 bool Isolate::ComputeLocationFromStackTrace(MessageLocation* target,
1073 Handle<Object> exception) { 1100 Handle<Object> exception) {
1074 *target = MessageLocation(Handle<Script>(heap_.empty_script()), -1, -1); 1101 *target = MessageLocation(Handle<Script>(heap_.empty_script()), -1, -1);
1075 1102
1076 if (!exception->IsJSObject()) return false; 1103 if (!exception->IsJSObject()) return false;
1077 Handle<Name> key = factory()->stack_trace_symbol(); 1104 Handle<Name> key = factory()->stack_trace_symbol();
1078 Handle<Object> property = 1105 Handle<Object> property =
1079 JSObject::GetDataProperty(Handle<JSObject>::cast(exception), key); 1106 JSObject::GetDataProperty(Handle<JSObject>::cast(exception), key);
1080 if (!property->IsJSArray()) return false; 1107 if (!property->IsJSArray()) return false;
1081 Handle<JSArray> simple_stack_trace = Handle<JSArray>::cast(property); 1108 Handle<JSArray> simple_stack_trace = Handle<JSArray>::cast(property);
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
1174 GetDetailedStackTrace(Handle<JSObject>::cast(exception)); 1201 GetDetailedStackTrace(Handle<JSObject>::cast(exception));
1175 } 1202 }
1176 if (stack_trace_object.is_null()) { 1203 if (stack_trace_object.is_null()) {
1177 // Not an error object, we capture stack and location at throw site. 1204 // Not an error object, we capture stack and location at throw site.
1178 stack_trace_object = CaptureCurrentStackTrace( 1205 stack_trace_object = CaptureCurrentStackTrace(
1179 stack_trace_for_uncaught_exceptions_frame_limit_, 1206 stack_trace_for_uncaught_exceptions_frame_limit_,
1180 stack_trace_for_uncaught_exceptions_options_); 1207 stack_trace_for_uncaught_exceptions_options_);
1181 } 1208 }
1182 } 1209 }
1183 if (!location) { 1210 if (!location) {
1184 if (!ComputeLocationFromStackTrace(&potential_computed_location, 1211 if (!ComputeLocationFromException(&potential_computed_location,
1185 exception)) { 1212 exception)) {
1186 ComputeLocation(&potential_computed_location); 1213 if (!ComputeLocationFromStackTrace(&potential_computed_location,
1214 exception)) {
1215 ComputeLocation(&potential_computed_location);
1216 }
1187 } 1217 }
1188 location = &potential_computed_location; 1218 location = &potential_computed_location;
1189 } 1219 }
1190 1220
1191 // If the exception argument is a custom object, turn it into a string 1221 // If the exception argument is a custom object, turn it into a string
1192 // before throwing as uncaught exception. Note that the pending 1222 // before throwing as uncaught exception. Note that the pending
1193 // exception object to be set later must not be turned into a string. 1223 // exception object to be set later must not be turned into a string.
1194 if (exception->IsJSObject() && !IsErrorObject(exception)) { 1224 if (exception->IsJSObject() && !IsErrorObject(exception)) {
1195 MaybeHandle<Object> maybe_exception = 1225 MaybeHandle<Object> maybe_exception =
1196 Execution::ToDetailString(this, exception); 1226 Execution::ToDetailString(this, exception);
(...skipping 1358 matching lines...) Expand 10 before | Expand all | Expand 10 after
2555 if (prev_ && prev_->Intercept(flag)) return true; 2585 if (prev_ && prev_->Intercept(flag)) return true;
2556 // Then check whether this scope intercepts. 2586 // Then check whether this scope intercepts.
2557 if ((flag & intercept_mask_)) { 2587 if ((flag & intercept_mask_)) {
2558 intercepted_flags_ |= flag; 2588 intercepted_flags_ |= flag;
2559 return true; 2589 return true;
2560 } 2590 }
2561 return false; 2591 return false;
2562 } 2592 }
2563 2593
2564 } } // namespace v8::internal 2594 } } // namespace v8::internal
OLDNEW
« 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