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 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 "strict_read_only_property", ["Cannot assign to read only property '",
"%0", "' of ", "%1"], | 240 "strict_read_only_property", ["Cannot assign to read only property '",
"%0", "' of ", "%1"], |
241 "strict_cannot_assign", ["Cannot assign to read only '", "%0", "'
in strict mode"], | 241 "strict_cannot_assign", ["Cannot assign to read only '", "%0", "'
in strict mode"], |
242 "strict_poison_pill", ["'caller', 'callee', and 'arguments' prop
erties may not be accessed on strict mode functions or the arguments objects for
calls to them"], | 242 "strict_poison_pill", ["'caller', 'callee', and 'arguments' prop
erties may not be accessed on strict mode functions or the arguments objects for
calls to them"], |
243 "strict_caller", ["Illegal access to a strict mode caller f
unction."], | 243 "strict_caller", ["Illegal access to a strict mode caller f
unction."], |
244 "unprotected_let", ["Illegal let declaration in unprotected s
tatement context."], | 244 "unprotected_let", ["Illegal let declaration in unprotected s
tatement context."], |
245 "unprotected_const", ["Illegal const declaration in unprotected
statement context."], | 245 "unprotected_const", ["Illegal const declaration in unprotected
statement context."], |
246 "cant_prevent_ext_external_array_elements", ["Cannot prevent extension of
an object with external array elements"], | 246 "cant_prevent_ext_external_array_elements", ["Cannot prevent extension of
an object with external array elements"], |
247 "redef_external_array_element", ["Cannot redefine a property of an object
with external array elements"], | 247 "redef_external_array_element", ["Cannot redefine a property of an object
with external array elements"], |
248 ]; | 248 ]; |
249 var messages = { __proto__ : null }; | 249 var messages = { __proto__ : null }; |
250 var desc = new PropertyDescriptor(); | |
251 desc.setConfigurable(false); | |
252 desc.setEnumerable(false); | |
253 desc.setWritable(false); | |
254 for (var i = 0; i < messagesDictionary.length; i += 2) { | 250 for (var i = 0; i < messagesDictionary.length; i += 2) { |
255 var key = messagesDictionary[i]; | 251 var key = messagesDictionary[i]; |
256 var format = messagesDictionary[i + 1]; | 252 var format = messagesDictionary[i + 1]; |
257 ObjectFreeze(format); | 253 |
258 desc.setValue(format); | 254 for (var j = 0; j < format.length; j++) { |
259 DefineOwnProperty(messages, key, desc); | 255 %IgnoreAttributesAndSetProperty(format, %_NumberToString(j), format[j], |
| 256 DONT_DELETE | READ_ONLY | DONT_ENUM); |
| 257 } |
| 258 %IgnoreAttributesAndSetProperty(format, 'length', format.length, |
| 259 DONT_DELETE | READ_ONLY | DONT_ENUM); |
| 260 %PreventExtensions(format); |
| 261 %IgnoreAttributesAndSetProperty(messages, |
| 262 key, |
| 263 format, |
| 264 DONT_DELETE | DONT_ENUM | READ_ONLY); |
260 } | 265 } |
261 %PreventExtensions(messages); | 266 %PreventExtensions(messages); |
262 %IgnoreAttributesAndSetProperty(builtins, "kMessages", | 267 %IgnoreAttributesAndSetProperty(builtins, "kMessages", |
263 messages, | 268 messages, |
264 DONT_DELETE | DONT_ENUM | READ_ONLY); | 269 DONT_DELETE | DONT_ENUM | READ_ONLY); |
265 } | 270 } |
266 var message_type = %MessageGetType(message); | 271 var message_type = %MessageGetType(message); |
267 var format = kMessages[message_type]; | 272 var format = kMessages[message_type]; |
268 if (!format) return "<unknown message " + message_type + ">"; | 273 if (!format) return "<unknown message " + message_type + ">"; |
269 return FormatString(format, message); | 274 return FormatString(format, message); |
(...skipping 915 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1185 throw e; | 1190 throw e; |
1186 } | 1191 } |
1187 } | 1192 } |
1188 | 1193 |
1189 | 1194 |
1190 InstallFunctions($Error.prototype, DONT_ENUM, ['toString', ErrorToString]); | 1195 InstallFunctions($Error.prototype, DONT_ENUM, ['toString', ErrorToString]); |
1191 | 1196 |
1192 // Boilerplate for exceptions for stack overflows. Used from | 1197 // Boilerplate for exceptions for stack overflows. Used from |
1193 // Isolate::StackOverflow(). | 1198 // Isolate::StackOverflow(). |
1194 const kStackOverflowBoilerplate = MakeRangeError('stack_overflow', []); | 1199 const kStackOverflowBoilerplate = MakeRangeError('stack_overflow', []); |
OLD | NEW |