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"], | |
10 code_gen_from_strings: ["%0"], | |
11 constructor_is_generator: ["Class constructor may not be a generator"], | 9 constructor_is_generator: ["Class constructor may not be a generator"], |
12 constructor_is_accessor: ["Class constructor may not be an accessor"], | 10 constructor_is_accessor: ["Class constructor may not be an accessor"], |
13 // TypeError | 11 // TypeError |
14 generator_running: ["Generator is already running"], | |
15 unexpected_token: ["Unexpected token ", "%0"], | 12 unexpected_token: ["Unexpected token ", "%0"], |
16 unexpected_token_number: ["Unexpected number"], | 13 unexpected_token_number: ["Unexpected number"], |
17 unexpected_token_string: ["Unexpected string"], | 14 unexpected_token_string: ["Unexpected string"], |
18 unexpected_token_identifier: ["Unexpected identifier"], | 15 unexpected_token_identifier: ["Unexpected identifier"], |
19 unexpected_reserved: ["Unexpected reserved word"], | 16 unexpected_reserved: ["Unexpected reserved word"], |
20 unexpected_strict_reserved: ["Unexpected strict mode reserved word"], | 17 unexpected_strict_reserved: ["Unexpected strict mode reserved word"], |
21 unexpected_eos: ["Unexpected end of input"], | 18 unexpected_eos: ["Unexpected end of input"], |
22 unexpected_template_string: ["Unexpected template string"], | 19 unexpected_template_string: ["Unexpected template string"], |
23 malformed_regexp: ["Invalid regular expression: /", "%0", "/: ",
"%1"], | 20 malformed_regexp: ["Invalid regular expression: /", "%0", "/: ",
"%1"], |
24 malformed_regexp_flags: ["Invalid regular expression flags"], | 21 malformed_regexp_flags: ["Invalid regular expression flags"], |
25 unterminated_regexp: ["Invalid regular expression: missing /"], | 22 unterminated_regexp: ["Invalid regular expression: missing /"], |
26 unterminated_template: ["Unterminated template literal"], | 23 unterminated_template: ["Unterminated template literal"], |
27 unterminated_template_expr: ["Missing } in template expression"], | 24 unterminated_template_expr: ["Missing } in template expression"], |
28 unterminated_arg_list: ["missing ) after argument list"], | 25 unterminated_arg_list: ["missing ) after argument list"], |
29 regexp_flags: ["Cannot supply flags when constructing one Reg
Exp from another"], | 26 regexp_flags: ["Cannot supply flags when constructing one Reg
Exp from another"], |
30 incompatible_method_receiver: ["Method ", "%0", " called on incompatible rece
iver ", "%1"], | |
31 multiple_defaults_in_switch: ["More than one default clause in switch statem
ent"], | 27 multiple_defaults_in_switch: ["More than one default clause in switch statem
ent"], |
32 newline_after_throw: ["Illegal newline after throw"], | 28 newline_after_throw: ["Illegal newline after throw"], |
33 label_redeclaration: ["Label '", "%0", "' has already been declared"
], | 29 label_redeclaration: ["Label '", "%0", "' has already been declared"
], |
34 var_redeclaration: ["Identifier '", "%0", "' has already been decl
ared"], | 30 var_redeclaration: ["Identifier '", "%0", "' has already been decl
ared"], |
35 duplicate_template_property: ["Object template has duplicate property '", "%
0", "'"], | 31 duplicate_template_property: ["Object template has duplicate property '", "%
0", "'"], |
36 no_catch_or_finally: ["Missing catch or finally after try"], | 32 no_catch_or_finally: ["Missing catch or finally after try"], |
37 unknown_label: ["Undefined label '", "%0", "'"], | 33 unknown_label: ["Undefined label '", "%0", "'"], |
38 uncaught_exception: ["Uncaught ", "%0"], | 34 uncaught_exception: ["Uncaught ", "%0"], |
39 stack_trace: ["Stack Trace:\n", "%0"], | |
40 called_non_callable: ["%0", " is not a function"], | |
41 undefined_method: ["Object ", "%1", " has no method '", "%0", "'"
], | 35 undefined_method: ["Object ", "%1", " has no method '", "%0", "'"
], |
42 cannot_convert_to_primitive: ["Cannot convert object to primitive value"], | 36 cannot_convert_to_primitive: ["Cannot convert object to primitive value"], |
43 not_constructor: ["%0", " is not a constructor"], | 37 not_constructor: ["%0", " is not a constructor"], |
44 not_defined: ["%0", " is not defined"], | 38 not_defined: ["%0", " is not defined"], |
45 non_method: ["'super' is referenced from non-method"], | 39 non_method: ["'super' is referenced from non-method"], |
46 unsupported_super: ["Unsupported reference to 'super'"], | 40 unsupported_super: ["Unsupported reference to 'super'"], |
47 non_object_property_load: ["Cannot read property '", "%0", "' of ", "%1"]
, | 41 non_object_property_load: ["Cannot read property '", "%0", "' of ", "%1"]
, |
48 non_object_property_store: ["Cannot set property '", "%0", "' of ", "%1"], | 42 non_object_property_store: ["Cannot set property '", "%0", "' of ", "%1"], |
49 illegal_invocation: ["Illegal invocation"], | 43 illegal_invocation: ["Illegal invocation"], |
50 no_setter_in_callback: ["Cannot set property ", "%0", " of ", "%1", "
which has only a getter"], | 44 no_setter_in_callback: ["Cannot set property ", "%0", " of ", "%1", "
which has only a getter"], |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 var constructorName = constructor.name; | 304 var constructorName = constructor.name; |
311 if (IS_STRING(constructorName) && constructorName !== "") { | 305 if (IS_STRING(constructorName) && constructorName !== "") { |
312 return "#<" + constructorName + ">"; | 306 return "#<" + constructorName + ">"; |
313 } | 307 } |
314 } | 308 } |
315 } | 309 } |
316 return ToStringCheckErrorObject(obj); | 310 return ToStringCheckErrorObject(obj); |
317 } | 311 } |
318 | 312 |
319 | 313 |
320 function MakeGenericError(constructor, type, args) { | 314 function MakeGenericError(constructor, type, arg0, arg1, arg2) { |
321 if (IS_UNDEFINED(args)) args = []; | 315 if (IS_UNDEFINED(arg0) && IS_STRING(type)) arg0 = []; |
322 return new constructor(FormatMessage(type, args)); | |
323 } | |
324 | |
325 | |
326 function MakeGenericError2(constructor, type, arg0, arg1, arg2) { | |
327 return new constructor(FormatMessage(type, arg0, arg1, arg2)); | 316 return new constructor(FormatMessage(type, arg0, arg1, arg2)); |
328 } | 317 } |
329 | 318 |
330 | 319 |
331 /** | 320 /** |
332 * Set up the Script function and constructor. | 321 * Set up the Script function and constructor. |
333 */ | 322 */ |
334 %FunctionSetInstanceClassName(Script, 'Script'); | 323 %FunctionSetInstanceClassName(Script, 'Script'); |
335 %AddNamedProperty(Script.prototype, 'constructor', Script, | 324 %AddNamedProperty(Script.prototype, 'constructor', Script, |
336 DONT_ENUM | DONT_DELETE | READ_ONLY); | 325 DONT_ENUM | DONT_DELETE | READ_ONLY); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 // position, or the empty string if the position is invalid. | 362 // position, or the empty string if the position is invalid. |
374 function GetSourceLine(message) { | 363 function GetSourceLine(message) { |
375 var script = %MessageGetScript(message); | 364 var script = %MessageGetScript(message); |
376 var start_position = %MessageGetStartPosition(message); | 365 var start_position = %MessageGetStartPosition(message); |
377 var location = script.locationFromPosition(start_position, true); | 366 var location = script.locationFromPosition(start_position, true); |
378 if (location == null) return ""; | 367 if (location == null) return ""; |
379 return location.sourceText(); | 368 return location.sourceText(); |
380 } | 369 } |
381 | 370 |
382 | 371 |
383 function MakeTypeError(type, args) { | 372 function MakeError(type, arg0, arg1, arg2) { |
384 return MakeGenericError($TypeError, type, args); | 373 return MakeGenericError($Error, type, arg0, arg1, arg2); |
385 } | 374 } |
386 | 375 |
387 | 376 |
388 // TODO(yangguo): rename this once we migrated all messages. | 377 function MakeTypeError(type, arg0, arg1, arg2) { |
389 function MakeTypeError2(type, arg0, arg1, arg2) { | 378 return MakeGenericError($TypeError, type, arg0, arg1, arg2); |
390 return MakeGenericError2($TypeError, type, arg0, arg1, arg2); | |
391 } | 379 } |
392 | 380 |
393 | 381 |
394 function MakeRangeError(type, args) { | 382 function MakeRangeError(type, arg0, arg1, arg2) { |
395 return MakeGenericError($RangeError, type, args); | 383 return MakeGenericError($RangeError, type, arg0, arg1, arg2); |
396 } | 384 } |
397 | 385 |
398 | 386 |
399 function MakeSyntaxError(type, args) { | 387 function MakeSyntaxError(type, arg0, arg1, arg2) { |
400 return MakeGenericError($SyntaxError, type, args); | 388 return MakeGenericError($SyntaxError, type, arg0, arg1, arg2); |
401 } | 389 } |
402 | 390 |
403 | 391 |
404 function MakeReferenceError(type, args) { | 392 function MakeReferenceError(type, arg0, arg1, arg2) { |
405 return MakeGenericError($ReferenceError, type, args); | 393 return MakeGenericError($ReferenceError, type, arg0, arg1, arg2); |
406 } | 394 } |
407 | 395 |
408 | 396 |
409 function MakeEvalError(type, args) { | 397 function MakeEvalError(type, arg0, arg1, arg2) { |
410 return MakeGenericError($EvalError, type, args); | 398 return MakeGenericError($EvalError, type, arg0, arg1, arg2); |
411 } | 399 } |
412 | 400 |
413 | |
414 function MakeError(type, args) { | |
415 return MakeGenericError($Error, type, args); | |
416 } | |
417 | |
418 | |
419 // The embedded versions are called from unoptimized code, with embedded | 401 // The embedded versions are called from unoptimized code, with embedded |
420 // arguments. Those arguments cannot be arrays, which are context-dependent. | 402 // arguments. Those arguments cannot be arrays, which are context-dependent. |
421 function MakeTypeErrorEmbedded(type, arg) { | 403 function MakeTypeErrorEmbedded(type, arg) { |
422 return MakeGenericError($TypeError, type, [arg]); | 404 return MakeGenericError($TypeError, type, [arg]); |
423 } | 405 } |
424 | 406 |
425 | 407 |
426 function MakeSyntaxErrorEmbedded(type, arg) { | 408 function MakeSyntaxErrorEmbedded(type, arg) { |
427 return MakeGenericError($SyntaxError, type, [arg]); | 409 return MakeGenericError($SyntaxError, type, [arg]); |
428 } | 410 } |
(...skipping 881 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1310 function SetUpStackOverflowBoilerplate() { | 1292 function SetUpStackOverflowBoilerplate() { |
1311 var boilerplate = MakeRangeError('stack_overflow', []); | 1293 var boilerplate = MakeRangeError('stack_overflow', []); |
1312 | 1294 |
1313 %DefineAccessorPropertyUnchecked( | 1295 %DefineAccessorPropertyUnchecked( |
1314 boilerplate, 'stack', StackTraceGetter, StackTraceSetter, DONT_ENUM); | 1296 boilerplate, 'stack', StackTraceGetter, StackTraceSetter, DONT_ENUM); |
1315 | 1297 |
1316 return boilerplate; | 1298 return boilerplate; |
1317 } | 1299 } |
1318 | 1300 |
1319 var kStackOverflowBoilerplate = SetUpStackOverflowBoilerplate(); | 1301 var kStackOverflowBoilerplate = SetUpStackOverflowBoilerplate(); |
OLD | NEW |