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 13 matching lines...) Expand all Loading... |
24 var MakeEvalError; | 24 var MakeEvalError; |
25 var MakeRangeError; | 25 var MakeRangeError; |
26 var MakeReferenceError; | 26 var MakeReferenceError; |
27 var MakeSyntaxError; | 27 var MakeSyntaxError; |
28 var MakeTypeError; | 28 var MakeTypeError; |
29 var MakeURIError; | 29 var MakeURIError; |
30 var MakeReferenceErrorEmbedded; | 30 var MakeReferenceErrorEmbedded; |
31 var MakeSyntaxErrorEmbedded; | 31 var MakeSyntaxErrorEmbedded; |
32 var MakeTypeErrorEmbedded; | 32 var MakeTypeErrorEmbedded; |
33 | 33 |
34 (function() { | 34 (function(global, shared, exports) { |
35 | 35 |
36 %CheckIsBootstrapping(); | 36 %CheckIsBootstrapping(); |
37 | 37 |
38 var GlobalObject = global.Object; | 38 var GlobalObject = global.Object; |
39 var GlobalError; | 39 var GlobalError; |
40 var GlobalTypeError; | 40 var GlobalTypeError; |
41 var GlobalRangeError; | 41 var GlobalRangeError; |
42 var GlobalURIError; | 42 var GlobalURIError; |
43 var GlobalSyntaxError; | 43 var GlobalSyntaxError; |
44 var GlobalReferenceError; | 44 var GlobalReferenceError; |
(...skipping 999 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1044 var captureStackTrace = function captureStackTrace(obj, cons_opt) { | 1044 var captureStackTrace = function captureStackTrace(obj, cons_opt) { |
1045 // Define accessors first, as this may fail and throw. | 1045 // Define accessors first, as this may fail and throw. |
1046 $objectDefineProperty(obj, 'stack', { get: StackTraceGetter, | 1046 $objectDefineProperty(obj, 'stack', { get: StackTraceGetter, |
1047 set: StackTraceSetter, | 1047 set: StackTraceSetter, |
1048 configurable: true }); | 1048 configurable: true }); |
1049 %CollectStackTrace(obj, cons_opt ? cons_opt : captureStackTrace); | 1049 %CollectStackTrace(obj, cons_opt ? cons_opt : captureStackTrace); |
1050 } | 1050 } |
1051 | 1051 |
1052 | 1052 |
1053 // Define special error type constructors. | 1053 // Define special error type constructors. |
1054 function DefineError(f) { | 1054 function DefineError(global, f) { |
1055 // Store the error function in both the global object | 1055 // Store the error function in both the global object |
1056 // and the runtime object. The function is fetched | 1056 // and the runtime object. The function is fetched |
1057 // from the runtime object when throwing errors from | 1057 // from the runtime object when throwing errors from |
1058 // within the runtime system to avoid strange side | 1058 // within the runtime system to avoid strange side |
1059 // effects when overwriting the error functions from | 1059 // effects when overwriting the error functions from |
1060 // user code. | 1060 // user code. |
1061 var name = f.name; | 1061 var name = f.name; |
1062 %AddNamedProperty(global, name, f, DONT_ENUM); | 1062 %AddNamedProperty(global, name, f, DONT_ENUM); |
1063 // Configure the error function. | 1063 // Configure the error function. |
1064 if (name == 'Error') { | 1064 if (name == 'Error') { |
(...skipping 22 matching lines...) Expand all Loading... |
1087 %AddNamedProperty(this, 'message', $toString(m), DONT_ENUM); | 1087 %AddNamedProperty(this, 'message', $toString(m), DONT_ENUM); |
1088 } | 1088 } |
1089 } else { | 1089 } else { |
1090 return new f(m); | 1090 return new f(m); |
1091 } | 1091 } |
1092 }); | 1092 }); |
1093 %SetNativeFlag(f); | 1093 %SetNativeFlag(f); |
1094 return f; | 1094 return f; |
1095 }; | 1095 }; |
1096 | 1096 |
1097 GlobalError = DefineError(function Error() { }); | 1097 GlobalError = DefineError(global, function Error() { }); |
1098 GlobalEvalError = DefineError(function EvalError() { }); | 1098 GlobalEvalError = DefineError(global, function EvalError() { }); |
1099 GlobalRangeError = DefineError(function RangeError() { }); | 1099 GlobalRangeError = DefineError(global, function RangeError() { }); |
1100 GlobalReferenceError = DefineError(function ReferenceError() { }); | 1100 GlobalReferenceError = DefineError(global, function ReferenceError() { }); |
1101 GlobalSyntaxError = DefineError(function SyntaxError() { }); | 1101 GlobalSyntaxError = DefineError(global, function SyntaxError() { }); |
1102 GlobalTypeError = DefineError(function TypeError() { }); | 1102 GlobalTypeError = DefineError(global, function TypeError() { }); |
1103 GlobalURIError = DefineError(function URIError() { }); | 1103 GlobalURIError = DefineError(global, function URIError() { }); |
1104 | 1104 |
1105 | 1105 |
1106 GlobalError.captureStackTrace = captureStackTrace; | 1106 GlobalError.captureStackTrace = captureStackTrace; |
1107 | 1107 |
1108 %AddNamedProperty(GlobalError.prototype, 'message', '', DONT_ENUM); | 1108 %AddNamedProperty(GlobalError.prototype, 'message', '', DONT_ENUM); |
1109 | 1109 |
1110 // Global list of error objects visited during ErrorToString. This is | 1110 // Global list of error objects visited during ErrorToString. This is |
1111 // used to detect cycles in error toString formatting. | 1111 // used to detect cycles in error toString formatting. |
1112 var visited_errors = new InternalArray(); | 1112 var visited_errors = new InternalArray(); |
1113 var cyclic_error_marker = new GlobalObject(); | 1113 var cyclic_error_marker = new GlobalObject(); |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1229 MakeTypeErrorEmbedded = function(type, arg) { | 1229 MakeTypeErrorEmbedded = function(type, arg) { |
1230 return MakeGenericError(GlobalTypeError, type, [arg]); | 1230 return MakeGenericError(GlobalTypeError, type, [arg]); |
1231 } | 1231 } |
1232 | 1232 |
1233 //Boilerplate for exceptions for stack overflows. Used from | 1233 //Boilerplate for exceptions for stack overflows. Used from |
1234 //Isolate::StackOverflow(). | 1234 //Isolate::StackOverflow(). |
1235 $stackOverflowBoilerplate = MakeRangeError(kStackOverflow); | 1235 $stackOverflowBoilerplate = MakeRangeError(kStackOverflow); |
1236 %DefineAccessorPropertyUnchecked($stackOverflowBoilerplate, 'stack', | 1236 %DefineAccessorPropertyUnchecked($stackOverflowBoilerplate, 'stack', |
1237 StackTraceGetter, StackTraceSetter, DONT_ENUM); | 1237 StackTraceGetter, StackTraceSetter, DONT_ENUM); |
1238 | 1238 |
1239 })(); | 1239 }) |
OLD | NEW |