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 // 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 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 248 } | 248 } |
| 249 } | 249 } |
| 250 return ToStringCheckErrorObject(obj); | 250 return ToStringCheckErrorObject(obj); |
| 251 } | 251 } |
| 252 | 252 |
| 253 | 253 |
| 254 function MakeGenericError(constructor, type, args) { | 254 function MakeGenericError(constructor, type, args) { |
| 255 if (IS_UNDEFINED(args)) { | 255 if (IS_UNDEFINED(args)) { |
| 256 args = []; | 256 args = []; |
| 257 } | 257 } |
| 258 var e = new constructor(FormatMessage(type, args)); | 258 var e = new constructor(FormatMessage(type, args)); |
|
Sven Panne
2012/11/14 08:40:35
Just drop the "var e =", it's cleaner... ;-)
| |
| 259 e.type = type; | |
| 260 e.arguments = args; | |
| 261 return e; | 259 return e; |
| 262 } | 260 } |
| 263 | 261 |
| 264 | 262 |
| 265 /** | 263 /** |
| 266 * Set up the Script function and constructor. | 264 * Set up the Script function and constructor. |
| 267 */ | 265 */ |
| 268 %FunctionSetInstanceClassName(Script, 'Script'); | 266 %FunctionSetInstanceClassName(Script, 'Script'); |
| 269 %SetProperty(Script.prototype, 'constructor', Script, | 267 %SetProperty(Script.prototype, 'constructor', Script, |
| 270 DONT_ENUM | DONT_DELETE | READ_ONLY); | 268 DONT_ENUM | DONT_DELETE | READ_ONLY); |
| (...skipping 865 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1136 } | 1134 } |
| 1137 %FunctionSetInstanceClassName(f, 'Error'); | 1135 %FunctionSetInstanceClassName(f, 'Error'); |
| 1138 %SetProperty(f.prototype, 'constructor', f, DONT_ENUM); | 1136 %SetProperty(f.prototype, 'constructor', f, DONT_ENUM); |
| 1139 %SetProperty(f.prototype, "name", name, DONT_ENUM); | 1137 %SetProperty(f.prototype, "name", name, DONT_ENUM); |
| 1140 %SetCode(f, function(m) { | 1138 %SetCode(f, function(m) { |
| 1141 if (%_IsConstructCall()) { | 1139 if (%_IsConstructCall()) { |
| 1142 // Define all the expected properties directly on the error | 1140 // Define all the expected properties directly on the error |
| 1143 // object. This avoids going through getters and setters defined | 1141 // object. This avoids going through getters and setters defined |
| 1144 // on prototype objects. | 1142 // on prototype objects. |
| 1145 %IgnoreAttributesAndSetProperty(this, 'stack', void 0, DONT_ENUM); | 1143 %IgnoreAttributesAndSetProperty(this, 'stack', void 0, DONT_ENUM); |
| 1146 %IgnoreAttributesAndSetProperty(this, 'arguments', void 0, DONT_ENUM); | |
| 1147 %IgnoreAttributesAndSetProperty(this, 'type', void 0, DONT_ENUM); | |
| 1148 if (!IS_UNDEFINED(m)) { | 1144 if (!IS_UNDEFINED(m)) { |
| 1149 %IgnoreAttributesAndSetProperty( | 1145 %IgnoreAttributesAndSetProperty( |
| 1150 this, 'message', ToString(m), DONT_ENUM); | 1146 this, 'message', ToString(m), DONT_ENUM); |
| 1151 } | 1147 } |
| 1152 captureStackTrace(this, f); | 1148 captureStackTrace(this, f); |
| 1153 } else { | 1149 } else { |
| 1154 return new f(m); | 1150 return new f(m); |
| 1155 } | 1151 } |
| 1156 }); | 1152 }); |
| 1157 %SetNativeFlag(f); | 1153 %SetNativeFlag(f); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1197 if (error === $TypeError.prototype) | 1193 if (error === $TypeError.prototype) |
| 1198 return isName ? "TypeError" : void 0; | 1194 return isName ? "TypeError" : void 0; |
| 1199 } | 1195 } |
| 1200 // Otherwise, read normally. | 1196 // Otherwise, read normally. |
| 1201 return error[name]; | 1197 return error[name]; |
| 1202 } | 1198 } |
| 1203 | 1199 |
| 1204 function ErrorToStringDetectCycle(error) { | 1200 function ErrorToStringDetectCycle(error) { |
| 1205 if (!%PushIfAbsent(visited_errors, error)) throw cyclic_error_marker; | 1201 if (!%PushIfAbsent(visited_errors, error)) throw cyclic_error_marker; |
| 1206 try { | 1202 try { |
| 1207 var type = GetPropertyWithoutInvokingMonkeyGetters(error, "type"); | |
| 1208 var name = GetPropertyWithoutInvokingMonkeyGetters(error, "name"); | 1203 var name = GetPropertyWithoutInvokingMonkeyGetters(error, "name"); |
| 1209 name = IS_UNDEFINED(name) ? "Error" : TO_STRING_INLINE(name); | 1204 name = IS_UNDEFINED(name) ? "Error" : TO_STRING_INLINE(name); |
| 1210 var message = GetPropertyWithoutInvokingMonkeyGetters(error, "message"); | 1205 var message = GetPropertyWithoutInvokingMonkeyGetters(error, "message"); |
| 1211 message = IS_UNDEFINED(message) ? "" : TO_STRING_INLINE(message); | 1206 message = IS_UNDEFINED(message) ? "" : TO_STRING_INLINE(message); |
| 1212 if (name === "") return message; | 1207 if (name === "") return message; |
| 1213 if (message === "") return name; | 1208 if (message === "") return name; |
| 1214 return name + ": " + message; | 1209 return name + ": " + message; |
| 1215 } finally { | 1210 } finally { |
| 1216 visited_errors.length = visited_errors.length - 1; | 1211 visited_errors.length = visited_errors.length - 1; |
| 1217 } | 1212 } |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1266 %DefineOrRedefineDataProperty(this, 'stack', v, NONE); | 1261 %DefineOrRedefineDataProperty(this, 'stack', v, NONE); |
| 1267 } | 1262 } |
| 1268 | 1263 |
| 1269 %DefineOrRedefineAccessorProperty( | 1264 %DefineOrRedefineAccessorProperty( |
| 1270 boilerplate, 'stack', getter, setter, DONT_ENUM); | 1265 boilerplate, 'stack', getter, setter, DONT_ENUM); |
| 1271 | 1266 |
| 1272 return boilerplate; | 1267 return boilerplate; |
| 1273 } | 1268 } |
| 1274 | 1269 |
| 1275 var kStackOverflowBoilerplate = SetUpStackOverflowBoilerplate(); | 1270 var kStackOverflowBoilerplate = SetUpStackOverflowBoilerplate(); |
| OLD | NEW |