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 MakeError; | |
8 var MakeEvalError; | |
9 var MakeRangeError; | |
10 var MakeReferenceError; | |
11 var MakeSyntaxError; | |
12 var MakeTypeError; | |
13 var MakeURIError; | |
14 | |
15 (function(global, utils) { | 7 (function(global, utils) { |
16 | 8 |
17 %CheckIsBootstrapping(); | 9 %CheckIsBootstrapping(); |
18 | 10 |
19 // ------------------------------------------------------------------- | 11 // ------------------------------------------------------------------- |
20 // Imports | 12 // Imports |
21 | 13 |
22 var ArrayJoin; | 14 var ArrayJoin; |
23 var Bool16x8ToString; | 15 var Bool16x8ToString; |
24 var Bool32x4ToString; | 16 var Bool32x4ToString; |
(...skipping 940 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
965 GlobalError = DefineError(global, function Error() { }); | 957 GlobalError = DefineError(global, function Error() { }); |
966 GlobalEvalError = DefineError(global, function EvalError() { }); | 958 GlobalEvalError = DefineError(global, function EvalError() { }); |
967 GlobalRangeError = DefineError(global, function RangeError() { }); | 959 GlobalRangeError = DefineError(global, function RangeError() { }); |
968 GlobalReferenceError = DefineError(global, function ReferenceError() { }); | 960 GlobalReferenceError = DefineError(global, function ReferenceError() { }); |
969 GlobalSyntaxError = DefineError(global, function SyntaxError() { }); | 961 GlobalSyntaxError = DefineError(global, function SyntaxError() { }); |
970 GlobalTypeError = DefineError(global, function TypeError() { }); | 962 GlobalTypeError = DefineError(global, function TypeError() { }); |
971 GlobalURIError = DefineError(global, function URIError() { }); | 963 GlobalURIError = DefineError(global, function URIError() { }); |
972 | 964 |
973 %AddNamedProperty(GlobalError.prototype, 'message', '', DONT_ENUM); | 965 %AddNamedProperty(GlobalError.prototype, 'message', '', DONT_ENUM); |
974 | 966 |
| 967 utils.InstallFunctions(GlobalError.prototype, DONT_ENUM, |
| 968 ['toString', ErrorToString]); |
| 969 |
975 function ErrorToString() { | 970 function ErrorToString() { |
976 if (!IS_SPEC_OBJECT(this)) { | 971 if (!IS_SPEC_OBJECT(this)) { |
977 throw MakeTypeError(kCalledOnNonObject, "Error.prototype.toString"); | 972 throw MakeTypeError(kCalledOnNonObject, "Error.prototype.toString"); |
978 } | 973 } |
979 | 974 |
980 return %ErrorToStringRT(this); | 975 return %ErrorToStringRT(this); |
981 } | 976 } |
982 | 977 |
983 utils.InstallFunctions(GlobalError.prototype, DONT_ENUM, | 978 function MakeError(type, arg0, arg1, arg2) { |
984 ['toString', ErrorToString]); | |
985 | |
986 MakeError = function(type, arg0, arg1, arg2) { | |
987 return MakeGenericError(GlobalError, type, arg0, arg1, arg2); | 979 return MakeGenericError(GlobalError, type, arg0, arg1, arg2); |
988 } | 980 } |
989 | 981 |
990 MakeRangeError = function(type, arg0, arg1, arg2) { | 982 function MakeRangeError(type, arg0, arg1, arg2) { |
991 return MakeGenericError(GlobalRangeError, type, arg0, arg1, arg2); | 983 return MakeGenericError(GlobalRangeError, type, arg0, arg1, arg2); |
992 } | 984 } |
993 | 985 |
994 MakeSyntaxError = function(type, arg0, arg1, arg2) { | 986 function MakeSyntaxError(type, arg0, arg1, arg2) { |
995 return MakeGenericError(GlobalSyntaxError, type, arg0, arg1, arg2); | 987 return MakeGenericError(GlobalSyntaxError, type, arg0, arg1, arg2); |
996 } | 988 } |
997 | 989 |
998 MakeTypeError = function(type, arg0, arg1, arg2) { | 990 function MakeTypeError(type, arg0, arg1, arg2) { |
999 return MakeGenericError(GlobalTypeError, type, arg0, arg1, arg2); | 991 return MakeGenericError(GlobalTypeError, type, arg0, arg1, arg2); |
1000 } | 992 } |
1001 | 993 |
1002 MakeURIError = function() { | 994 function MakeURIError() { |
1003 return MakeGenericError(GlobalURIError, kURIMalformed); | 995 return MakeGenericError(GlobalURIError, kURIMalformed); |
1004 } | 996 } |
1005 | 997 |
1006 // Boilerplate for exceptions for stack overflows. Used from | 998 // Boilerplate for exceptions for stack overflows. Used from |
1007 // Isolate::StackOverflow(). | 999 // Isolate::StackOverflow(). |
1008 var StackOverflowBoilerplate = MakeRangeError(kStackOverflow); | 1000 var StackOverflowBoilerplate = MakeRangeError(kStackOverflow); |
1009 %DefineAccessorPropertyUnchecked(StackOverflowBoilerplate, 'stack', | 1001 %DefineAccessorPropertyUnchecked(StackOverflowBoilerplate, 'stack', |
1010 StackTraceGetter, StackTraceSetter, | 1002 StackTraceGetter, StackTraceSetter, |
1011 DONT_ENUM); | 1003 DONT_ENUM); |
1012 | 1004 |
(...skipping 23 matching lines...) Expand all Loading... |
1036 "reference_error_function", GlobalReferenceError, | 1028 "reference_error_function", GlobalReferenceError, |
1037 "stack_overflow_boilerplate", StackOverflowBoilerplate, | 1029 "stack_overflow_boilerplate", StackOverflowBoilerplate, |
1038 "syntax_error_function", GlobalSyntaxError, | 1030 "syntax_error_function", GlobalSyntaxError, |
1039 "to_detail_string_fun", ToDetailString, | 1031 "to_detail_string_fun", ToDetailString, |
1040 "type_error_function", GlobalTypeError, | 1032 "type_error_function", GlobalTypeError, |
1041 "uri_error_function", GlobalURIError, | 1033 "uri_error_function", GlobalURIError, |
1042 ]); | 1034 ]); |
1043 | 1035 |
1044 utils.Export(function(to) { | 1036 utils.Export(function(to) { |
1045 to.ErrorToString = ErrorToString; | 1037 to.ErrorToString = ErrorToString; |
| 1038 to.MakeError = MakeError; |
| 1039 to.MakeRangeError = MakeRangeError; |
| 1040 to.MakeSyntaxError = MakeSyntaxError; |
| 1041 to.MakeTypeError = MakeTypeError; |
| 1042 to.MakeURIError = MakeURIError; |
1046 }); | 1043 }); |
1047 | 1044 |
1048 }); | 1045 }); |
OLD | NEW |