| OLD | NEW |
| 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 // ------------------------------------------------------------------- | 5 // ------------------------------------------------------------------- |
| 6 | 6 |
| 7 var $errorToString; | 7 var $errorToString; |
| 8 var $formatMessage; | 8 var $formatMessage; |
| 9 var $getStackTraceLine; | 9 var $getStackTraceLine; |
| 10 var $messageGetPositionInLine; | 10 var $messageGetPositionInLine; |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 | 262 |
| 263 | 263 |
| 264 // When formatting internally created error messages, do not | 264 // When formatting internally created error messages, do not |
| 265 // invoke overwritten error toString methods but explicitly use | 265 // invoke overwritten error toString methods but explicitly use |
| 266 // the error to string method. This is to avoid leaking error | 266 // the error to string method. This is to avoid leaking error |
| 267 // objects between script tags in a browser setting. | 267 // objects between script tags in a browser setting. |
| 268 function ToStringCheckErrorObject(obj) { | 268 function ToStringCheckErrorObject(obj) { |
| 269 if (CanBeSafelyTreatedAsAnErrorObject(obj)) { | 269 if (CanBeSafelyTreatedAsAnErrorObject(obj)) { |
| 270 return %_CallFunction(obj, ErrorToString); | 270 return %_CallFunction(obj, ErrorToString); |
| 271 } else { | 271 } else { |
| 272 return ToString(obj); | 272 return $toString(obj); |
| 273 } | 273 } |
| 274 } | 274 } |
| 275 | 275 |
| 276 | 276 |
| 277 function ToDetailString(obj) { | 277 function ToDetailString(obj) { |
| 278 if (obj != null && IS_OBJECT(obj) && obj.toString === $objectToString) { | 278 if (obj != null && IS_OBJECT(obj) && obj.toString === $objectToString) { |
| 279 var constructor = obj.constructor; | 279 var constructor = obj.constructor; |
| 280 if (typeof constructor == "function") { | 280 if (typeof constructor == "function") { |
| 281 var constructorName = constructor.name; | 281 var constructorName = constructor.name; |
| 282 if (IS_STRING(constructorName) && constructorName !== "") { | 282 if (IS_STRING(constructorName) && constructorName !== "") { |
| (...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1082 %FunctionSetInstanceClassName(f, 'Error'); | 1082 %FunctionSetInstanceClassName(f, 'Error'); |
| 1083 %AddNamedProperty(f.prototype, 'constructor', f, DONT_ENUM); | 1083 %AddNamedProperty(f.prototype, 'constructor', f, DONT_ENUM); |
| 1084 %AddNamedProperty(f.prototype, 'name', name, DONT_ENUM); | 1084 %AddNamedProperty(f.prototype, 'name', name, DONT_ENUM); |
| 1085 %SetCode(f, function(m) { | 1085 %SetCode(f, function(m) { |
| 1086 if (%_IsConstructCall()) { | 1086 if (%_IsConstructCall()) { |
| 1087 try { captureStackTrace(this, f); } catch (e) { } | 1087 try { captureStackTrace(this, f); } catch (e) { } |
| 1088 // Define all the expected properties directly on the error | 1088 // Define all the expected properties directly on the error |
| 1089 // object. This avoids going through getters and setters defined | 1089 // object. This avoids going through getters and setters defined |
| 1090 // on prototype objects. | 1090 // on prototype objects. |
| 1091 if (!IS_UNDEFINED(m)) { | 1091 if (!IS_UNDEFINED(m)) { |
| 1092 %AddNamedProperty(this, 'message', ToString(m), DONT_ENUM); | 1092 %AddNamedProperty(this, 'message', $toString(m), DONT_ENUM); |
| 1093 } | 1093 } |
| 1094 } else { | 1094 } else { |
| 1095 return new f(m); | 1095 return new f(m); |
| 1096 } | 1096 } |
| 1097 }); | 1097 }); |
| 1098 %SetNativeFlag(f); | 1098 %SetNativeFlag(f); |
| 1099 return f; | 1099 return f; |
| 1100 }; | 1100 }; |
| 1101 | 1101 |
| 1102 GlobalError = DefineError(function Error() { }); | 1102 GlobalError = DefineError(function Error() { }); |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1235 return MakeGenericError(GlobalTypeError, type, [arg]); | 1235 return MakeGenericError(GlobalTypeError, type, [arg]); |
| 1236 } | 1236 } |
| 1237 | 1237 |
| 1238 //Boilerplate for exceptions for stack overflows. Used from | 1238 //Boilerplate for exceptions for stack overflows. Used from |
| 1239 //Isolate::StackOverflow(). | 1239 //Isolate::StackOverflow(). |
| 1240 $stackOverflowBoilerplate = MakeRangeError(kStackOverflow); | 1240 $stackOverflowBoilerplate = MakeRangeError(kStackOverflow); |
| 1241 %DefineAccessorPropertyUnchecked($stackOverflowBoilerplate, 'stack', | 1241 %DefineAccessorPropertyUnchecked($stackOverflowBoilerplate, 'stack', |
| 1242 StackTraceGetter, StackTraceSetter, DONT_ENUM); | 1242 StackTraceGetter, StackTraceSetter, DONT_ENUM); |
| 1243 | 1243 |
| 1244 })(); | 1244 })(); |
| OLD | NEW |