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 constructor_is_generator: ["Class constructor may not be a generator"], | 9 constructor_is_generator: ["Class constructor may not be a generator"], |
10 constructor_is_accessor: ["Class constructor may not be an accessor"], | 10 constructor_is_accessor: ["Class constructor may not be an accessor"], |
(...skipping 24 matching lines...) Expand all Loading... |
35 undefined_method: ["Object ", "%1", " has no method '", "%0", "'"
], | 35 undefined_method: ["Object ", "%1", " has no method '", "%0", "'"
], |
36 not_defined: ["%0", " is not defined"], | 36 not_defined: ["%0", " is not defined"], |
37 non_method: ["'super' is referenced from non-method"], | 37 non_method: ["'super' is referenced from non-method"], |
38 unsupported_super: ["Unsupported reference to 'super'"], | 38 unsupported_super: ["Unsupported reference to 'super'"], |
39 non_object_property_load: ["Cannot read property '", "%0", "' of ", "%1"]
, | 39 non_object_property_load: ["Cannot read property '", "%0", "' of ", "%1"]
, |
40 non_object_property_store: ["Cannot set property '", "%0", "' of ", "%1"], | 40 non_object_property_store: ["Cannot set property '", "%0", "' of ", "%1"], |
41 illegal_invocation: ["Illegal invocation"], | 41 illegal_invocation: ["Illegal invocation"], |
42 no_setter_in_callback: ["Cannot set property ", "%0", " of ", "%1", "
which has only a getter"], | 42 no_setter_in_callback: ["Cannot set property ", "%0", " of ", "%1", "
which has only a getter"], |
43 flags_getter_non_object: ["RegExp.prototype.flags getter called on non-o
bject ", "%0"], | 43 flags_getter_non_object: ["RegExp.prototype.flags getter called on non-o
bject ", "%0"], |
44 reduce_no_initial: ["Reduce of empty array with no initial value"]
, | 44 reduce_no_initial: ["Reduce of empty array with no initial value"]
, |
45 getter_must_be_callable: ["Getter must be a function: ", "%0"], | |
46 setter_must_be_callable: ["Setter must be a function: ", "%0"], | |
47 value_and_accessor: ["Invalid property. A property cannot both hav
e accessors and be writable or have a value, ", "%0"], | 45 value_and_accessor: ["Invalid property. A property cannot both hav
e accessors and be writable or have a value, ", "%0"], |
48 proto_object_or_null: ["Object prototype may only be an Object or nul
l: ", "%0"], | 46 proto_object_or_null: ["Object prototype may only be an Object or nul
l: ", "%0"], |
49 property_desc_object: ["Property description must be an object: ", "%
0"], | |
50 redefine_disallowed: ["Cannot redefine property: ", "%0"], | |
51 define_disallowed: ["Cannot define property:", "%0", ", object is
not extensible."], | |
52 non_extensible_proto: ["%0", " is not extensible"], | 47 non_extensible_proto: ["%0", " is not extensible"], |
53 handler_non_object: ["Proxy.", "%0", " called with non-object as ha
ndler"], | 48 handler_non_object: ["Proxy.", "%0", " called with non-object as ha
ndler"], |
54 proto_non_object: ["Proxy.", "%0", " called with non-object as pr
ototype"], | 49 proto_non_object: ["Proxy.", "%0", " called with non-object as pr
ototype"], |
55 trap_function_expected: ["Proxy.", "%0", " called with non-function for
'", "%1", "' trap"], | 50 trap_function_expected: ["Proxy.", "%0", " called with non-function for
'", "%1", "' trap"], |
56 handler_trap_missing: ["Proxy handler ", "%0", " has no '", "%1", "'
trap"], | |
57 handler_trap_must_be_callable: ["Proxy handler ", "%0", " has non-callable '",
"%1", "' trap"], | |
58 handler_returned_false: ["Proxy handler ", "%0", " returned false from
'", "%1", "' trap"], | |
59 handler_returned_undefined: ["Proxy handler ", "%0", " returned undefined f
rom '", "%1", "' trap"], | |
60 proxy_prop_not_configurable: ["Proxy handler ", "%0", " returned non-configu
rable descriptor for property '", "%2", "' from '", "%1", "' trap"], | |
61 proxy_non_object_prop_names: ["Trap '", "%1", "' returned non-object ", "%0"
], | |
62 proxy_repeated_prop_name: ["Trap '", "%1", "' returned repeated property
name '", "%2", "'"], | 51 proxy_repeated_prop_name: ["Trap '", "%1", "' returned repeated property
name '", "%2", "'"], |
63 invalid_weakmap_key: ["Invalid value used as weak map key"], | 52 invalid_weakmap_key: ["Invalid value used as weak map key"], |
64 invalid_weakset_value: ["Invalid value used in weak set"], | 53 invalid_weakset_value: ["Invalid value used in weak set"], |
65 not_date_object: ["this is not a Date object."], | 54 not_date_object: ["this is not a Date object."], |
66 observe_non_object: ["Object.", "%0", " cannot ", "%0", " non-objec
t"], | 55 observe_non_object: ["Object.", "%0", " cannot ", "%0", " non-objec
t"], |
67 observe_non_function: ["Object.", "%0", " cannot deliver to non-funct
ion"], | 56 observe_non_function: ["Object.", "%0", " cannot deliver to non-funct
ion"], |
68 observe_callback_frozen: ["Object.observe cannot deliver to a frozen fun
ction object"], | 57 observe_callback_frozen: ["Object.observe cannot deliver to a frozen fun
ction object"], |
69 observe_invalid_accept: ["Third argument to Object.observe must be an a
rray of strings."], | 58 observe_invalid_accept: ["Third argument to Object.observe must be an a
rray of strings."], |
70 observe_type_non_string: ["Invalid changeRecord with non-string 'type' p
roperty"], | 59 observe_type_non_string: ["Invalid changeRecord with non-string 'type' p
roperty"], |
71 observe_perform_non_string: ["Invalid non-string changeType"], | 60 observe_perform_non_string: ["Invalid non-string changeType"], |
72 observe_perform_non_function: ["Cannot perform non-function"], | 61 observe_perform_non_function: ["Cannot perform non-function"], |
73 observe_notify_non_notifier: ["notify called on non-notifier object"], | 62 observe_notify_non_notifier: ["notify called on non-notifier object"], |
74 observe_global_proxy: ["%0", " cannot be called on the global proxy o
bject"], | 63 observe_global_proxy: ["%0", " cannot be called on the global proxy o
bject"], |
75 not_typed_array: ["this is not a typed array."], | 64 not_typed_array: ["this is not a typed array."], |
76 invalid_argument: ["invalid_argument"], | 65 invalid_argument: ["invalid_argument"], |
77 data_view_not_array_buffer: ["First argument to DataView constructor must b
e an ArrayBuffer"], | 66 data_view_not_array_buffer: ["First argument to DataView constructor must b
e an ArrayBuffer"], |
78 constructor_not_function: ["Constructor ", "%0", " requires 'new'"], | 67 constructor_not_function: ["Constructor ", "%0", " requires 'new'"], |
79 not_a_symbol: ["%0", " is not a symbol"], | 68 not_a_symbol: ["%0", " is not a symbol"], |
80 not_a_promise: ["%0", " is not a promise"], | 69 not_a_promise: ["%0", " is not a promise"], |
81 resolver_not_a_function: ["Promise resolver ", "%0", " is not a function
"], | 70 resolver_not_a_function: ["Promise resolver ", "%0", " is not a function
"], |
82 promise_cyclic: ["Chaining cycle detected for promise ", "%0"], | 71 promise_cyclic: ["Chaining cycle detected for promise ", "%0"], |
83 array_functions_on_frozen: ["Cannot modify frozen array elements"], | 72 array_functions_on_frozen: ["Cannot modify frozen array elements"], |
84 array_functions_change_sealed: ["Cannot add/remove sealed array elements"], | 73 array_functions_change_sealed: ["Cannot add/remove sealed array elements"], |
85 first_argument_not_regexp: ["First argument to ", "%0", " must not be a re
gular expression"], | 74 first_argument_not_regexp: ["First argument to ", "%0", " must not be a re
gular expression"], |
86 not_iterable: ["%0", " is not iterable"], | |
87 not_an_iterator: ["%0", " is not an iterator"], | |
88 iterator_result_not_an_object: ["Iterator result ", "%0", " is not an object"]
, | 75 iterator_result_not_an_object: ["Iterator result ", "%0", " is not an object"]
, |
89 iterator_value_not_an_object: ["Iterator value ", "%0", " is not an entry obj
ect"], | 76 iterator_value_not_an_object: ["Iterator value ", "%0", " is not an entry obj
ect"], |
90 // RangeError | 77 // RangeError |
91 invalid_array_length: ["Invalid array length"], | 78 invalid_array_length: ["Invalid array length"], |
92 invalid_array_buffer_length: ["Invalid array buffer length"], | 79 invalid_array_buffer_length: ["Invalid array buffer length"], |
93 invalid_string_length: ["Invalid string length"], | 80 invalid_string_length: ["Invalid string length"], |
94 invalid_typed_array_offset: ["Start offset is too large:"], | 81 invalid_typed_array_offset: ["Start offset is too large:"], |
95 invalid_typed_array_length: ["Invalid typed array length"], | 82 invalid_typed_array_length: ["Invalid typed array length"], |
96 invalid_typed_array_alignment: ["%0", " of ", "%1", " should be a multiple of
", "%2"], | 83 invalid_typed_array_alignment: ["%0", " of ", "%1", " should be a multiple of
", "%2"], |
97 typed_array_set_source_too_large: | 84 typed_array_set_source_too_large: |
98 ["Source is too large"], | 85 ["Source is too large"], |
99 typed_array_set_negative_offset: | 86 typed_array_set_negative_offset: |
100 ["Start offset is negative"], | 87 ["Start offset is negative"], |
101 invalid_data_view_offset: ["Start offset is outside the bounds of the buf
fer"], | 88 invalid_data_view_offset: ["Start offset is outside the bounds of the buf
fer"], |
102 invalid_data_view_length: ["Invalid data view length"], | 89 invalid_data_view_length: ["Invalid data view length"], |
103 invalid_data_view_accessor_offset: | 90 invalid_data_view_accessor_offset: |
104 ["Offset is outside the bounds of the DataView"
], | 91 ["Offset is outside the bounds of the DataView"
], |
105 | 92 |
106 invalid_time_value: ["Invalid time value"], | 93 invalid_time_value: ["Invalid time value"], |
107 invalid_count_value: ["Invalid count value"], | 94 invalid_count_value: ["Invalid count value"], |
108 invalid_code_point: ["Invalid code point ", "%0"], | 95 invalid_code_point: ["Invalid code point ", "%0"], |
109 // ReferenceError | 96 // ReferenceError |
110 invalid_lhs_in_assignment: ["Invalid left-hand side in assignment"], | 97 invalid_lhs_in_assignment: ["Invalid left-hand side in assignment"], |
111 invalid_lhs_in_for: ["Invalid left-hand side in for-loop"], | 98 invalid_lhs_in_for: ["Invalid left-hand side in for-loop"], |
112 invalid_lhs_in_postfix_op: ["Invalid left-hand side expression in postfix
operation"], | 99 invalid_lhs_in_postfix_op: ["Invalid left-hand side expression in postfix
operation"], |
113 invalid_lhs_in_prefix_op: ["Invalid left-hand side expression in prefix o
peration"], | 100 invalid_lhs_in_prefix_op: ["Invalid left-hand side expression in prefix o
peration"], |
114 // SyntaxError | 101 // SyntaxError |
115 paren_in_arg_string: ["Function arg string contains parenthesis"], | |
116 not_isvar: ["builtin %IS_VAR: not a variable"], | 102 not_isvar: ["builtin %IS_VAR: not a variable"], |
117 single_function_literal: ["Single function literal required"], | 103 single_function_literal: ["Single function literal required"], |
118 invalid_regexp_flags: ["Invalid flags supplied to RegExp constructor
'", "%0", "'"], | 104 invalid_regexp_flags: ["Invalid flags supplied to RegExp constructor
'", "%0", "'"], |
119 invalid_regexp: ["Invalid RegExp pattern /", "%0", "/"], | 105 invalid_regexp: ["Invalid RegExp pattern /", "%0", "/"], |
120 illegal_break: ["Illegal break statement"], | 106 illegal_break: ["Illegal break statement"], |
121 illegal_continue: ["Illegal continue statement"], | 107 illegal_continue: ["Illegal continue statement"], |
122 illegal_return: ["Illegal return statement"], | 108 illegal_return: ["Illegal return statement"], |
123 error_loading_debugger: ["Error loading debugger"], | 109 error_loading_debugger: ["Error loading debugger"], |
124 no_input_to_regexp: ["No input to ", "%0"], | |
125 invalid_json: ["String '", "%0", "' is not valid JSON"], | |
126 circular_structure: ["Converting circular structure to JSON"], | 110 circular_structure: ["Converting circular structure to JSON"], |
127 called_on_non_object: ["%0", " called on non-object"], | |
128 called_on_null_or_undefined: ["%0", " called on null or undefined"], | 111 called_on_null_or_undefined: ["%0", " called on null or undefined"], |
129 array_indexof_not_defined: ["Array.getIndexOf: Argument undefined"], | 112 array_indexof_not_defined: ["Array.getIndexOf: Argument undefined"], |
130 object_not_extensible: ["Can't add property ", "%0", ", object is not
extensible"], | 113 object_not_extensible: ["Can't add property ", "%0", ", object is not
extensible"], |
131 illegal_access: ["Illegal access"], | 114 illegal_access: ["Illegal access"], |
132 static_prototype: ["Classes may not have static property named pr
ototype"], | 115 static_prototype: ["Classes may not have static property named pr
ototype"], |
133 strict_mode_with: ["Strict mode code may not include a with state
ment"], | 116 strict_mode_with: ["Strict mode code may not include a with state
ment"], |
134 strict_eval_arguments: ["Unexpected eval or arguments in strict mode"]
, | 117 strict_eval_arguments: ["Unexpected eval or arguments in strict mode"]
, |
135 too_many_arguments: ["Too many arguments in function call (only 655
35 allowed)"], | 118 too_many_arguments: ["Too many arguments in function call (only 655
35 allowed)"], |
136 too_many_parameters: ["Too many parameters in function definition (o
nly 65535 allowed)"], | 119 too_many_parameters: ["Too many parameters in function definition (o
nly 65535 allowed)"], |
137 too_many_variables: ["Too many variables declared (only 4194303 all
owed)"], | 120 too_many_variables: ["Too many variables declared (only 4194303 all
owed)"], |
(...skipping 1107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1245 if (name === "") return message; | 1228 if (name === "") return message; |
1246 if (message === "") return name; | 1229 if (message === "") return name; |
1247 return name + ": " + message; | 1230 return name + ": " + message; |
1248 } finally { | 1231 } finally { |
1249 visited_errors.length = visited_errors.length - 1; | 1232 visited_errors.length = visited_errors.length - 1; |
1250 } | 1233 } |
1251 } | 1234 } |
1252 | 1235 |
1253 function ErrorToString() { | 1236 function ErrorToString() { |
1254 if (!IS_SPEC_OBJECT(this)) { | 1237 if (!IS_SPEC_OBJECT(this)) { |
1255 throw MakeTypeError("called_on_non_object", ["Error.prototype.toString"]); | 1238 throw MakeTypeError(kCalledOnNonObject, "Error.prototype.toString"); |
1256 } | 1239 } |
1257 | 1240 |
1258 try { | 1241 try { |
1259 return ErrorToStringDetectCycle(this); | 1242 return ErrorToStringDetectCycle(this); |
1260 } catch(e) { | 1243 } catch(e) { |
1261 // If this error message was encountered already return the empty | 1244 // If this error message was encountered already return the empty |
1262 // string for it instead of recursively formatting it. | 1245 // string for it instead of recursively formatting it. |
1263 if (e === cyclic_error_marker) { | 1246 if (e === cyclic_error_marker) { |
1264 return ''; | 1247 return ''; |
1265 } | 1248 } |
1266 throw e; | 1249 throw e; |
1267 } | 1250 } |
1268 } | 1251 } |
1269 | 1252 |
1270 | 1253 |
1271 InstallFunctions($Error.prototype, DONT_ENUM, ['toString', ErrorToString]); | 1254 InstallFunctions($Error.prototype, DONT_ENUM, ['toString', ErrorToString]); |
1272 | 1255 |
1273 // Boilerplate for exceptions for stack overflows. Used from | 1256 // Boilerplate for exceptions for stack overflows. Used from |
1274 // Isolate::StackOverflow(). | 1257 // Isolate::StackOverflow(). |
1275 function SetUpStackOverflowBoilerplate() { | 1258 function SetUpStackOverflowBoilerplate() { |
1276 var boilerplate = MakeRangeError(kStackOverflow); | 1259 var boilerplate = MakeRangeError(kStackOverflow); |
1277 | 1260 |
1278 %DefineAccessorPropertyUnchecked( | 1261 %DefineAccessorPropertyUnchecked( |
1279 boilerplate, 'stack', StackTraceGetter, StackTraceSetter, DONT_ENUM); | 1262 boilerplate, 'stack', StackTraceGetter, StackTraceSetter, DONT_ENUM); |
1280 | 1263 |
1281 return boilerplate; | 1264 return boilerplate; |
1282 } | 1265 } |
1283 | 1266 |
1284 var kStackOverflowBoilerplate = SetUpStackOverflowBoilerplate(); | 1267 var kStackOverflowBoilerplate = SetUpStackOverflowBoilerplate(); |
OLD | NEW |