| 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 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 var constructorName = constructor.name; | 305 var constructorName = constructor.name; |
| 312 if (IS_STRING(constructorName) && constructorName !== "") { | 306 if (IS_STRING(constructorName) && constructorName !== "") { |
| 313 return "#<" + constructorName + ">"; | 307 return "#<" + constructorName + ">"; |
| 314 } | 308 } |
| 315 } | 309 } |
| 316 } | 310 } |
| 317 return ToStringCheckErrorObject(obj); | 311 return ToStringCheckErrorObject(obj); |
| 318 } | 312 } |
| 319 | 313 |
| 320 | 314 |
| 321 function MakeGenericError(constructor, type, args) { | 315 function MakeGenericError(constructor, type, arg0, arg1, arg2) { |
| 322 if (IS_UNDEFINED(args)) args = []; | 316 if (IS_UNDEFINED(arg0) && IS_STRING(type)) arg0 = []; |
| 323 return new constructor(FormatMessage(type, args)); | |
| 324 } | |
| 325 | |
| 326 | |
| 327 function MakeGenericError2(constructor, type, arg0, arg1, arg2) { | |
| 328 return new constructor(FormatMessage(type, arg0, arg1, arg2)); | 317 return new constructor(FormatMessage(type, arg0, arg1, arg2)); |
| 329 } | 318 } |
| 330 | 319 |
| 331 | 320 |
| 332 /** | 321 /** |
| 333 * Set up the Script function and constructor. | 322 * Set up the Script function and constructor. |
| 334 */ | 323 */ |
| 335 %FunctionSetInstanceClassName(Script, 'Script'); | 324 %FunctionSetInstanceClassName(Script, 'Script'); |
| 336 %AddNamedProperty(Script.prototype, 'constructor', Script, | 325 %AddNamedProperty(Script.prototype, 'constructor', Script, |
| 337 DONT_ENUM | DONT_DELETE | READ_ONLY); | 326 DONT_ENUM | DONT_DELETE | READ_ONLY); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 // position, or the empty string if the position is invalid. | 363 // position, or the empty string if the position is invalid. |
| 375 function GetSourceLine(message) { | 364 function GetSourceLine(message) { |
| 376 var script = %MessageGetScript(message); | 365 var script = %MessageGetScript(message); |
| 377 var start_position = %MessageGetStartPosition(message); | 366 var start_position = %MessageGetStartPosition(message); |
| 378 var location = script.locationFromPosition(start_position, true); | 367 var location = script.locationFromPosition(start_position, true); |
| 379 if (location == null) return ""; | 368 if (location == null) return ""; |
| 380 return location.sourceText(); | 369 return location.sourceText(); |
| 381 } | 370 } |
| 382 | 371 |
| 383 | 372 |
| 384 function MakeTypeError(type, args) { | 373 function MakeError(type, arg0, arg1, arg2) { |
| 385 return MakeGenericError($TypeError, type, args); | 374 return MakeGenericError($Error, type, arg0, arg1, arg2); |
| 386 } | 375 } |
| 387 | 376 |
| 388 | 377 |
| 389 // TODO(yangguo): rename this once we migrated all messages. | 378 function MakeTypeError(type, arg0, arg1, arg2) { |
| 390 function MakeTypeError2(type, arg0, arg1, arg2) { | 379 return MakeGenericError($TypeError, type, arg0, arg1, arg2); |
| 391 return MakeGenericError2($TypeError, type, arg0, arg1, arg2); | |
| 392 } | 380 } |
| 393 | 381 |
| 394 | 382 |
| 395 function MakeRangeError(type, args) { | 383 function MakeRangeError(type, arg0, arg1, arg2) { |
| 396 return MakeGenericError($RangeError, type, args); | 384 return MakeGenericError($RangeError, type, arg0, arg1, arg2); |
| 397 } | 385 } |
| 398 | 386 |
| 399 | 387 |
| 400 function MakeSyntaxError(type, args) { | 388 function MakeSyntaxError(type, arg0, arg1, arg2) { |
| 401 return MakeGenericError($SyntaxError, type, args); | 389 return MakeGenericError($SyntaxError, type, arg0, arg1, arg2); |
| 402 } | 390 } |
| 403 | 391 |
| 404 | 392 |
| 405 function MakeReferenceError(type, args) { | 393 function MakeReferenceError(type, arg0, arg1, arg2) { |
| 406 return MakeGenericError($ReferenceError, type, args); | 394 return MakeGenericError($ReferenceError, type, arg0, arg1, arg2); |
| 407 } | 395 } |
| 408 | 396 |
| 409 | 397 |
| 410 function MakeEvalError(type, args) { | 398 function MakeEvalError(type, arg0, arg1, arg2) { |
| 411 return MakeGenericError($EvalError, type, args); | 399 return MakeGenericError($EvalError, type, arg0, arg1, arg2); |
| 412 } | 400 } |
| 413 | 401 |
| 414 | |
| 415 function MakeError(type, args) { | |
| 416 return MakeGenericError($Error, type, args); | |
| 417 } | |
| 418 | |
| 419 | |
| 420 // The embedded versions are called from unoptimized code, with embedded | 402 // The embedded versions are called from unoptimized code, with embedded |
| 421 // arguments. Those arguments cannot be arrays, which are context-dependent. | 403 // arguments. Those arguments cannot be arrays, which are context-dependent. |
| 422 function MakeTypeErrorEmbedded(type, arg) { | 404 function MakeTypeErrorEmbedded(type, arg) { |
| 423 return MakeGenericError($TypeError, type, [arg]); | 405 return MakeGenericError($TypeError, type, [arg]); |
| 424 } | 406 } |
| 425 | 407 |
| 426 | 408 |
| 427 function MakeSyntaxErrorEmbedded(type, arg) { | 409 function MakeSyntaxErrorEmbedded(type, arg) { |
| 428 return MakeGenericError($SyntaxError, type, [arg]); | 410 return MakeGenericError($SyntaxError, type, [arg]); |
| 429 } | 411 } |
| (...skipping 881 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1311 function SetUpStackOverflowBoilerplate() { | 1293 function SetUpStackOverflowBoilerplate() { |
| 1312 var boilerplate = MakeRangeError('stack_overflow', []); | 1294 var boilerplate = MakeRangeError('stack_overflow', []); |
| 1313 | 1295 |
| 1314 %DefineAccessorPropertyUnchecked( | 1296 %DefineAccessorPropertyUnchecked( |
| 1315 boilerplate, 'stack', StackTraceGetter, StackTraceSetter, DONT_ENUM); | 1297 boilerplate, 'stack', StackTraceGetter, StackTraceSetter, DONT_ENUM); |
| 1316 | 1298 |
| 1317 return boilerplate; | 1299 return boilerplate; |
| 1318 } | 1300 } |
| 1319 | 1301 |
| 1320 var kStackOverflowBoilerplate = SetUpStackOverflowBoilerplate(); | 1302 var kStackOverflowBoilerplate = SetUpStackOverflowBoilerplate(); |
| OLD | NEW |