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 1004 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1049 var captureStackTrace = function captureStackTrace(obj, cons_opt) { | 1049 var captureStackTrace = function captureStackTrace(obj, cons_opt) { |
1050 // Define accessors first, as this may fail and throw. | 1050 // Define accessors first, as this may fail and throw. |
1051 $objectDefineProperty(obj, 'stack', { get: StackTraceGetter, | 1051 $objectDefineProperty(obj, 'stack', { get: StackTraceGetter, |
1052 set: StackTraceSetter, | 1052 set: StackTraceSetter, |
1053 configurable: true }); | 1053 configurable: true }); |
1054 %CollectStackTrace(obj, cons_opt ? cons_opt : captureStackTrace); | 1054 %CollectStackTrace(obj, cons_opt ? cons_opt : captureStackTrace); |
1055 } | 1055 } |
1056 | 1056 |
1057 | 1057 |
1058 // Define special error type constructors. | 1058 // Define special error type constructors. |
1059 function DefineError(f) { | 1059 function DefineError(global, f) { |
1060 // Store the error function in both the global object | 1060 // Store the error function in both the global object |
1061 // and the runtime object. The function is fetched | 1061 // and the runtime object. The function is fetched |
1062 // from the runtime object when throwing errors from | 1062 // from the runtime object when throwing errors from |
1063 // within the runtime system to avoid strange side | 1063 // within the runtime system to avoid strange side |
1064 // effects when overwriting the error functions from | 1064 // effects when overwriting the error functions from |
1065 // user code. | 1065 // user code. |
1066 var name = f.name; | 1066 var name = f.name; |
1067 %AddNamedProperty(global, name, f, DONT_ENUM); | 1067 %AddNamedProperty(global, name, f, DONT_ENUM); |
1068 // Configure the error function. | 1068 // Configure the error function. |
1069 if (name == 'Error') { | 1069 if (name == 'Error') { |
(...skipping 22 matching lines...) Expand all Loading... |
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(global, function Error() { }); |
1103 GlobalEvalError = DefineError(function EvalError() { }); | 1103 GlobalEvalError = DefineError(global, function EvalError() { }); |
1104 GlobalRangeError = DefineError(function RangeError() { }); | 1104 GlobalRangeError = DefineError(global, function RangeError() { }); |
1105 GlobalReferenceError = DefineError(function ReferenceError() { }); | 1105 GlobalReferenceError = DefineError(global, function ReferenceError() { }); |
1106 GlobalSyntaxError = DefineError(function SyntaxError() { }); | 1106 GlobalSyntaxError = DefineError(global, function SyntaxError() { }); |
1107 GlobalTypeError = DefineError(function TypeError() { }); | 1107 GlobalTypeError = DefineError(global, function TypeError() { }); |
1108 GlobalURIError = DefineError(function URIError() { }); | 1108 GlobalURIError = DefineError(global, function URIError() { }); |
1109 | 1109 |
1110 | 1110 |
1111 GlobalError.captureStackTrace = captureStackTrace; | 1111 GlobalError.captureStackTrace = captureStackTrace; |
1112 | 1112 |
1113 %AddNamedProperty(GlobalError.prototype, 'message', '', DONT_ENUM); | 1113 %AddNamedProperty(GlobalError.prototype, 'message', '', DONT_ENUM); |
1114 | 1114 |
1115 // Global list of error objects visited during ErrorToString. This is | 1115 // Global list of error objects visited during ErrorToString. This is |
1116 // used to detect cycles in error toString formatting. | 1116 // used to detect cycles in error toString formatting. |
1117 var visited_errors = new InternalArray(); | 1117 var visited_errors = new InternalArray(); |
1118 var cyclic_error_marker = new GlobalObject(); | 1118 var cyclic_error_marker = new GlobalObject(); |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1234 MakeTypeErrorEmbedded = function(type, arg) { | 1234 MakeTypeErrorEmbedded = function(type, arg) { |
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 |