OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 10 matching lines...) Expand all Loading... |
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 | 28 |
29 // ------------------------------------------------------------------- | 29 // ------------------------------------------------------------------- |
30 // | 30 // |
31 // Matches Script::Type from objects.h | |
32 var TYPE_NATIVE = 0; | |
33 var TYPE_EXTENSION = 1; | |
34 var TYPE_NORMAL = 2; | |
35 | |
36 // Matches Script::CompilationType from objects.h | |
37 var COMPILATION_TYPE_HOST = 0; | |
38 var COMPILATION_TYPE_EVAL = 1; | |
39 var COMPILATION_TYPE_JSON = 2; | |
40 | |
41 // Matches Messages::kNoLineNumberInfo from v8.h | |
42 var kNoLineNumberInfo = 0; | |
43 | |
44 // If this object gets passed to an error constructor the error will | 31 // If this object gets passed to an error constructor the error will |
45 // get an accessor for .message that constructs a descriptive error | 32 // get an accessor for .message that constructs a descriptive error |
46 // message on access. | 33 // message on access. |
47 const kAddMessageAccessorsMarker = { }; | 34 const kAddMessageAccessorsMarker = { }; |
48 | 35 |
49 // This will be lazily initialized when first needed (and forcibly | 36 // This will be lazily initialized when first needed (and forcibly |
50 // overwritten even though it's const). | 37 // overwritten even though it's const). |
51 const kMessages = 0; | 38 const kMessages = 0; |
52 | 39 |
53 function FormatString(format, message) { | 40 function FormatString(format, message) { |
(...skipping 980 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1034 | 1021 |
1035 function DefineError(f) { | 1022 function DefineError(f) { |
1036 // Store the error function in both the global object | 1023 // Store the error function in both the global object |
1037 // and the runtime object. The function is fetched | 1024 // and the runtime object. The function is fetched |
1038 // from the runtime object when throwing errors from | 1025 // from the runtime object when throwing errors from |
1039 // within the runtime system to avoid strange side | 1026 // within the runtime system to avoid strange side |
1040 // effects when overwriting the error functions from | 1027 // effects when overwriting the error functions from |
1041 // user code. | 1028 // user code. |
1042 var name = f.name; | 1029 var name = f.name; |
1043 %SetProperty(global, name, f, DONT_ENUM); | 1030 %SetProperty(global, name, f, DONT_ENUM); |
1044 builtins['$' + name] = f; | 1031 %SetProperty(builtins, '$' + name, f, DONT_ENUM | DONT_DELETE | READ_ONLY); |
1045 // Configure the error function. | 1032 // Configure the error function. |
1046 if (name == 'Error') { | 1033 if (name == 'Error') { |
1047 // The prototype of the Error object must itself be an error. | 1034 // The prototype of the Error object must itself be an error. |
1048 // However, it can't be an instance of the Error object because | 1035 // However, it can't be an instance of the Error object because |
1049 // it hasn't been properly configured yet. Instead we create a | 1036 // it hasn't been properly configured yet. Instead we create a |
1050 // special not-a-true-error-but-close-enough object. | 1037 // special not-a-true-error-but-close-enough object. |
1051 function ErrorPrototype() {} | 1038 function ErrorPrototype() {} |
1052 %FunctionSetPrototype(ErrorPrototype, $Object.prototype); | 1039 %FunctionSetPrototype(ErrorPrototype, $Object.prototype); |
1053 %FunctionSetInstanceClassName(ErrorPrototype, 'Error'); | 1040 %FunctionSetInstanceClassName(ErrorPrototype, 'Error'); |
1054 %FunctionSetPrototype(f, new ErrorPrototype()); | 1041 %FunctionSetPrototype(f, new ErrorPrototype()); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1145 throw e; | 1132 throw e; |
1146 } | 1133 } |
1147 } | 1134 } |
1148 | 1135 |
1149 | 1136 |
1150 InstallFunctions($Error.prototype, DONT_ENUM, ['toString', errorToString]); | 1137 InstallFunctions($Error.prototype, DONT_ENUM, ['toString', errorToString]); |
1151 | 1138 |
1152 // Boilerplate for exceptions for stack overflows. Used from | 1139 // Boilerplate for exceptions for stack overflows. Used from |
1153 // Isolate::StackOverflow(). | 1140 // Isolate::StackOverflow(). |
1154 const kStackOverflowBoilerplate = MakeRangeError('stack_overflow', []); | 1141 const kStackOverflowBoilerplate = MakeRangeError('stack_overflow', []); |
OLD | NEW |