Chromium Code Reviews| 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 kMessages = { | 7 var kMessages = { |
| 8 // Error | 8 // Error |
| 9 cyclic_proto: ["Cyclic __proto__ value"], | 9 cyclic_proto: ["Cyclic __proto__ value"], |
| 10 code_gen_from_strings: ["%0"], | 10 code_gen_from_strings: ["%0"], |
| (...skipping 1146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1157 // The prototype of the Error object must itself be an error. | 1157 // The prototype of the Error object must itself be an error. |
| 1158 // However, it can't be an instance of the Error object because | 1158 // However, it can't be an instance of the Error object because |
| 1159 // it hasn't been properly configured yet. Instead we create a | 1159 // it hasn't been properly configured yet. Instead we create a |
| 1160 // special not-a-true-error-but-close-enough object. | 1160 // special not-a-true-error-but-close-enough object. |
| 1161 var ErrorPrototype = function() {}; | 1161 var ErrorPrototype = function() {}; |
| 1162 %FunctionSetPrototype(ErrorPrototype, $Object.prototype); | 1162 %FunctionSetPrototype(ErrorPrototype, $Object.prototype); |
| 1163 %FunctionSetInstanceClassName(ErrorPrototype, 'Error'); | 1163 %FunctionSetInstanceClassName(ErrorPrototype, 'Error'); |
| 1164 %FunctionSetPrototype(f, new ErrorPrototype()); | 1164 %FunctionSetPrototype(f, new ErrorPrototype()); |
| 1165 } else { | 1165 } else { |
| 1166 %FunctionSetPrototype(f, new $Error()); | 1166 %FunctionSetPrototype(f, new $Error()); |
| 1167 %SetPrototype(f, $Error); | |
|
adamk
2015/03/31 22:45:12
Any reason not to use %InternalSetPrototype here?
arv (Not doing code reviews)
2015/03/31 22:48:27
Yes, the reason is that I'm stupid. Fixing.
| |
| 1167 } | 1168 } |
| 1168 %FunctionSetInstanceClassName(f, 'Error'); | 1169 %FunctionSetInstanceClassName(f, 'Error'); |
| 1169 %AddNamedProperty(f.prototype, 'constructor', f, DONT_ENUM); | 1170 %AddNamedProperty(f.prototype, 'constructor', f, DONT_ENUM); |
| 1170 %AddNamedProperty(f.prototype, "name", name, DONT_ENUM); | 1171 %AddNamedProperty(f.prototype, 'name', name, DONT_ENUM); |
| 1171 %SetCode(f, function(m) { | 1172 %SetCode(f, function(m) { |
| 1172 if (%_IsConstructCall()) { | 1173 if (%_IsConstructCall()) { |
| 1173 try { captureStackTrace(this, f); } catch (e) { } | 1174 try { captureStackTrace(this, f); } catch (e) { } |
| 1174 // Define all the expected properties directly on the error | 1175 // Define all the expected properties directly on the error |
| 1175 // object. This avoids going through getters and setters defined | 1176 // object. This avoids going through getters and setters defined |
| 1176 // on prototype objects. | 1177 // on prototype objects. |
| 1177 if (!IS_UNDEFINED(m)) { | 1178 if (!IS_UNDEFINED(m)) { |
| 1178 %AddNamedProperty(this, 'message', ToString(m), DONT_ENUM); | 1179 %AddNamedProperty(this, 'message', ToString(m), DONT_ENUM); |
| 1179 } | 1180 } |
| 1180 } else { | 1181 } else { |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1269 function SetUpStackOverflowBoilerplate() { | 1270 function SetUpStackOverflowBoilerplate() { |
| 1270 var boilerplate = MakeRangeError('stack_overflow', []); | 1271 var boilerplate = MakeRangeError('stack_overflow', []); |
| 1271 | 1272 |
| 1272 %DefineAccessorPropertyUnchecked( | 1273 %DefineAccessorPropertyUnchecked( |
| 1273 boilerplate, 'stack', StackTraceGetter, StackTraceSetter, DONT_ENUM); | 1274 boilerplate, 'stack', StackTraceGetter, StackTraceSetter, DONT_ENUM); |
| 1274 | 1275 |
| 1275 return boilerplate; | 1276 return boilerplate; |
| 1276 } | 1277 } |
| 1277 | 1278 |
| 1278 var kStackOverflowBoilerplate = SetUpStackOverflowBoilerplate(); | 1279 var kStackOverflowBoilerplate = SetUpStackOverflowBoilerplate(); |
| OLD | NEW |