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 11 matching lines...) Expand all Loading... | |
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 | 31 // Matches Script::Type from objects.h |
32 var TYPE_NATIVE = 0; | 32 const TYPE_NATIVE = 0; |
Kevin Millikin (Chromium)
2011/09/01 07:58:24
Is this change necessary?
If it is, can you inste
Lasse Reichstein
2011/09/01 09:26:58
Nothing here is *necessary*, but it's an attempt t
Kevin Millikin (Chromium)
2011/09/01 09:53:14
I think something like that, even if you have to i
| |
33 var TYPE_EXTENSION = 1; | 33 const TYPE_EXTENSION = 1; |
34 var TYPE_NORMAL = 2; | 34 const TYPE_NORMAL = 2; |
35 | 35 |
36 // Matches Script::CompilationType from objects.h | 36 // Matches Script::CompilationType from objects.h |
37 var COMPILATION_TYPE_HOST = 0; | 37 const COMPILATION_TYPE_HOST = 0; |
38 var COMPILATION_TYPE_EVAL = 1; | 38 const COMPILATION_TYPE_EVAL = 1; |
39 var COMPILATION_TYPE_JSON = 2; | 39 const COMPILATION_TYPE_JSON = 2; |
40 | 40 |
41 // Matches Messages::kNoLineNumberInfo from v8.h | 41 // Matches Messages::kNoLineNumberInfo from v8.h |
42 var kNoLineNumberInfo = 0; | 42 const kNoLineNumberInfo = 0; |
43 | 43 |
44 // If this object gets passed to an error constructor the error will | 44 // If this object gets passed to an error constructor the error will |
45 // get an accessor for .message that constructs a descriptive error | 45 // get an accessor for .message that constructs a descriptive error |
46 // message on access. | 46 // message on access. |
47 var kAddMessageAccessorsMarker = { }; | 47 var kAddMessageAccessorsMarker = { }; |
48 | 48 |
49 var kMessages = 0; | 49 var kMessages = 0; |
50 | 50 |
51 var kReplacementMarkers = [ "%0", "%1", "%2", "%3" ]; | 51 var kReplacementMarkers = [ "%0", "%1", "%2", "%3" ]; |
52 | 52 |
(...skipping 947 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1000 | 1000 |
1001 function DefineError(f) { | 1001 function DefineError(f) { |
1002 // Store the error function in both the global object | 1002 // Store the error function in both the global object |
1003 // and the runtime object. The function is fetched | 1003 // and the runtime object. The function is fetched |
1004 // from the runtime object when throwing errors from | 1004 // from the runtime object when throwing errors from |
1005 // within the runtime system to avoid strange side | 1005 // within the runtime system to avoid strange side |
1006 // effects when overwriting the error functions from | 1006 // effects when overwriting the error functions from |
1007 // user code. | 1007 // user code. |
1008 var name = f.name; | 1008 var name = f.name; |
1009 %SetProperty(global, name, f, DONT_ENUM); | 1009 %SetProperty(global, name, f, DONT_ENUM); |
1010 this['$' + name] = f; | 1010 %SetProperty(this, '$' + name, f, DONT_ENUM | DONT_DELETE | READ_ONLY); |
1011 // Configure the error function. | 1011 // Configure the error function. |
1012 if (name == 'Error') { | 1012 if (name == 'Error') { |
1013 // The prototype of the Error object must itself be an error. | 1013 // The prototype of the Error object must itself be an error. |
1014 // However, it can't be an instance of the Error object because | 1014 // However, it can't be an instance of the Error object because |
1015 // it hasn't been properly configured yet. Instead we create a | 1015 // it hasn't been properly configured yet. Instead we create a |
1016 // special not-a-true-error-but-close-enough object. | 1016 // special not-a-true-error-but-close-enough object. |
1017 function ErrorPrototype() {} | 1017 function ErrorPrototype() {} |
1018 %FunctionSetPrototype(ErrorPrototype, $Object.prototype); | 1018 %FunctionSetPrototype(ErrorPrototype, $Object.prototype); |
1019 %FunctionSetInstanceClassName(ErrorPrototype, 'Error'); | 1019 %FunctionSetInstanceClassName(ErrorPrototype, 'Error'); |
1020 %FunctionSetPrototype(f, new ErrorPrototype()); | 1020 %FunctionSetPrototype(f, new ErrorPrototype()); |
1021 } else { | 1021 } else { |
1022 %FunctionSetPrototype(f, new $Error()); | 1022 %FunctionSetPrototype(f, new $Error()); |
1023 } | 1023 } |
1024 %FunctionSetInstanceClassName(f, 'Error'); | 1024 %FunctionSetInstanceClassName(f, 'Error'); |
1025 %SetProperty(f.prototype, 'constructor', f, DONT_ENUM); | 1025 %SetProperty(f.prototype, 'constructor', f, DONT_ENUM); |
1026 // The name property on the prototype of error objects is not | 1026 // The name property on the prototype of error objects is not |
1027 // specified as being read-one and dont-delete. However, allowing | 1027 // specified as being read-only and dont-delete. However, allowing |
1028 // overwriting allows leaks of error objects between script blocks | 1028 // overwriting allows leaks of error objects between script blocks |
1029 // in the same context in a browser setting. Therefore we fix the | 1029 // in the same context in a browser setting. Therefore we fix the |
1030 // name. | 1030 // name. |
1031 %SetProperty(f.prototype, "name", name, DONT_ENUM | DONT_DELETE | READ_ONLY); | 1031 %SetProperty(f.prototype, "name", name, DONT_ENUM | DONT_DELETE | READ_ONLY); |
1032 %SetCode(f, function(m) { | 1032 %SetCode(f, function(m) { |
1033 if (%_IsConstructCall()) { | 1033 if (%_IsConstructCall()) { |
1034 // Define all the expected properties directly on the error | 1034 // Define all the expected properties directly on the error |
1035 // object. This avoids going through getters and setters defined | 1035 // object. This avoids going through getters and setters defined |
1036 // on prototype objects. | 1036 // on prototype objects. |
1037 %IgnoreAttributesAndSetProperty(this, 'stack', void 0, DONT_ENUM); | 1037 %IgnoreAttributesAndSetProperty(this, 'stack', void 0, DONT_ENUM); |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1141 throw e; | 1141 throw e; |
1142 } | 1142 } |
1143 } | 1143 } |
1144 | 1144 |
1145 | 1145 |
1146 InstallFunctions($Error.prototype, DONT_ENUM, ['toString', errorToString]); | 1146 InstallFunctions($Error.prototype, DONT_ENUM, ['toString', errorToString]); |
1147 | 1147 |
1148 // Boilerplate for exceptions for stack overflows. Used from | 1148 // Boilerplate for exceptions for stack overflows. Used from |
1149 // Isolate::StackOverflow(). | 1149 // Isolate::StackOverflow(). |
1150 const kStackOverflowBoilerplate = MakeRangeError('stack_overflow', []); | 1150 const kStackOverflowBoilerplate = MakeRangeError('stack_overflow', []); |
OLD | NEW |