OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 // The infrastructure used for (localized) message reporting in V8. | 5 // The infrastructure used for (localized) message reporting in V8. |
6 // | 6 // |
7 // Note: there's a big unresolved issue about ownership of the data | 7 // Note: there's a big unresolved issue about ownership of the data |
8 // structures used by this framework. | 8 // structures used by this framework. |
9 | 9 |
10 #ifndef V8_MESSAGES_H_ | 10 #ifndef V8_MESSAGES_H_ |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 "Function.prototype.apply was called on %, which is a % and not a " \ | 123 "Function.prototype.apply was called on %, which is a % and not a " \ |
124 "function") \ | 124 "function") \ |
125 T(ArrayFunctionsOnFrozen, "Cannot modify frozen array elements") \ | 125 T(ArrayFunctionsOnFrozen, "Cannot modify frozen array elements") \ |
126 T(ArrayFunctionsOnSealed, "Cannot add/remove sealed array elements") \ | 126 T(ArrayFunctionsOnSealed, "Cannot add/remove sealed array elements") \ |
127 T(CalledNonCallable, "% is not a function") \ | 127 T(CalledNonCallable, "% is not a function") \ |
128 T(CalledOnNonObject, "% called on non-object") \ | 128 T(CalledOnNonObject, "% called on non-object") \ |
129 T(CalledOnNullOrUndefined, "% called on null or undefined") \ | 129 T(CalledOnNullOrUndefined, "% called on null or undefined") \ |
130 T(CannotConvertToPrimitive, "Cannot convert object to primitive value") \ | 130 T(CannotConvertToPrimitive, "Cannot convert object to primitive value") \ |
131 T(ConstructorNotFunction, "Constructor % requires 'new'") \ | 131 T(ConstructorNotFunction, "Constructor % requires 'new'") \ |
132 T(CurrencyCode, "Currency code is required with currency style.") \ | 132 T(CurrencyCode, "Currency code is required with currency style.") \ |
| 133 T(DataViewNotArrayBuffer, \ |
| 134 "First argument to DataView constructor must be an ArrayBuffer") \ |
133 T(DateType, "this is not a Date object.") \ | 135 T(DateType, "this is not a Date object.") \ |
134 T(DefineDisallowed, "Cannot define property:%, object is not extensible.") \ | 136 T(DefineDisallowed, "Cannot define property:%, object is not extensible.") \ |
135 T(FirstArgumentNotRegExp, \ | 137 T(FirstArgumentNotRegExp, \ |
136 "First argument to % must not be a regular expression") \ | 138 "First argument to % must not be a regular expression") \ |
137 T(FlagsGetterNonObject, \ | 139 T(FlagsGetterNonObject, \ |
138 "RegExp.prototype.flags getter called on non-object %") \ | 140 "RegExp.prototype.flags getter called on non-object %") \ |
139 T(FunctionBind, "Bind must be called on a function") \ | 141 T(FunctionBind, "Bind must be called on a function") \ |
140 T(GeneratorRunning, "Generator is already running") \ | 142 T(GeneratorRunning, "Generator is already running") \ |
141 T(IncompatibleMethodReceiver, "Method % called on incompatible receiver %") \ | 143 T(IncompatibleMethodReceiver, "Method % called on incompatible receiver %") \ |
142 T(InstanceofFunctionExpected, \ | 144 T(InstanceofFunctionExpected, \ |
143 "Expecting a function in instanceof check, but got %") \ | 145 "Expecting a function in instanceof check, but got %") \ |
144 T(InstanceofNonobjectProto, \ | 146 T(InstanceofNonobjectProto, \ |
145 "Function has non-object prototype '%' in instanceof check") \ | 147 "Function has non-object prototype '%' in instanceof check") \ |
| 148 T(InvalidArgument, "invalid_argument") \ |
146 T(InvalidInOperatorUse, "Cannot use 'in' operator to search for '%' in %") \ | 149 T(InvalidInOperatorUse, "Cannot use 'in' operator to search for '%' in %") \ |
147 T(IteratorResultNotAnObject, "Iterator result % is not an object") \ | 150 T(IteratorResultNotAnObject, "Iterator result % is not an object") \ |
148 T(IteratorValueNotAnObject, "Iterator value % is not an entry object") \ | 151 T(IteratorValueNotAnObject, "Iterator value % is not an entry object") \ |
149 T(LanguageID, "Language ID should be string or object.") \ | 152 T(LanguageID, "Language ID should be string or object.") \ |
150 T(MethodCalledOnWrongObject, \ | 153 T(MethodCalledOnWrongObject, \ |
151 "Method % called on a non-object or on a wrong type of object.") \ | 154 "Method % called on a non-object or on a wrong type of object.") \ |
152 T(MethodInvokedOnNullOrUndefined, \ | 155 T(MethodInvokedOnNullOrUndefined, \ |
153 "Method invoked on undefined or null value.") \ | 156 "Method invoked on undefined or null value.") \ |
154 T(MethodInvokedOnWrongType, "Method invoked on an object that is not %.") \ | 157 T(MethodInvokedOnWrongType, "Method invoked on an object that is not %.") \ |
155 T(NotAnIterator, "% is not an iterator") \ | 158 T(NotAnIterator, "% is not an iterator") \ |
| 159 T(NotAPromise, "% is not a promise") \ |
156 T(NotConstructor, "% is not a constructor") \ | 160 T(NotConstructor, "% is not a constructor") \ |
157 T(NotGeneric, "% is not generic") \ | 161 T(NotGeneric, "% is not generic") \ |
158 T(NotIterable, "% is not iterable") \ | 162 T(NotIterable, "% is not iterable") \ |
159 T(NotTypedArray, "this is not a typed array.") \ | 163 T(NotTypedArray, "this is not a typed array.") \ |
160 T(ObjectGetterExpectingFunction, \ | 164 T(ObjectGetterExpectingFunction, \ |
161 "Object.prototype.__defineGetter__: Expecting function") \ | 165 "Object.prototype.__defineGetter__: Expecting function") \ |
162 T(ObjectGetterCallable, "Getter must be a function: %") \ | 166 T(ObjectGetterCallable, "Getter must be a function: %") \ |
163 T(ObjectSetterExpectingFunction, \ | 167 T(ObjectSetterExpectingFunction, \ |
164 "Object.prototype.__defineSetter__: Expecting function") \ | 168 "Object.prototype.__defineSetter__: Expecting function") \ |
165 T(ObjectSetterCallable, "Setter must be a function: %") \ | 169 T(ObjectSetterCallable, "Setter must be a function: %") \ |
166 T(ObserveCallbackFrozen, \ | 170 T(ObserveCallbackFrozen, \ |
167 "Object.observe cannot deliver to a frozen function object") \ | 171 "Object.observe cannot deliver to a frozen function object") \ |
168 T(ObserveGlobalProxy, "% cannot be called on the global proxy object") \ | 172 T(ObserveGlobalProxy, "% cannot be called on the global proxy object") \ |
169 T(ObserveInvalidAccept, \ | 173 T(ObserveInvalidAccept, \ |
170 "Third argument to Object.observe must be an array of strings.") \ | 174 "Third argument to Object.observe must be an array of strings.") \ |
171 T(ObserveNonFunction, "Object.% cannot deliver to non-function") \ | 175 T(ObserveNonFunction, "Object.% cannot deliver to non-function") \ |
172 T(ObserveNonObject, "Object.% cannot % non-object") \ | 176 T(ObserveNonObject, "Object.% cannot % non-object") \ |
173 T(ObserveNotifyNonNotifier, "notify called on non-notifier object") \ | 177 T(ObserveNotifyNonNotifier, "notify called on non-notifier object") \ |
174 T(ObservePerformNonFunction, "Cannot perform non-function") \ | 178 T(ObservePerformNonFunction, "Cannot perform non-function") \ |
175 T(ObservePerformNonString, "Invalid non-string changeType") \ | 179 T(ObservePerformNonString, "Invalid non-string changeType") \ |
176 T(ObserveTypeNonString, \ | 180 T(ObserveTypeNonString, \ |
177 "Invalid changeRecord with non-string 'type' property") \ | 181 "Invalid changeRecord with non-string 'type' property") \ |
178 T(OrdinaryFunctionCalledAsConstructor, \ | 182 T(OrdinaryFunctionCalledAsConstructor, \ |
179 "Function object that's not a constructor was created with new") \ | 183 "Function object that's not a constructor was created with new") \ |
| 184 T(PromiseCyclic, "Chaining cycle detected for promise %") \ |
180 T(PropertyDescObject, "Property description must be an object: %") \ | 185 T(PropertyDescObject, "Property description must be an object: %") \ |
181 T(PropertyNotFunction, "Property '%' of object % is not a function") \ | 186 T(PropertyNotFunction, "Property '%' of object % is not a function") \ |
182 T(ProtoObjectOrNull, "Object prototype may only be an Object or null: %") \ | 187 T(ProtoObjectOrNull, "Object prototype may only be an Object or null: %") \ |
| 188 T(ProxyHandlerNonObject, "Proxy.% called with non-object as handler") \ |
183 T(ProxyHandlerReturned, "Proxy handler % returned % from '%' trap") \ | 189 T(ProxyHandlerReturned, "Proxy handler % returned % from '%' trap") \ |
184 T(ProxyHandlerTrapMissing, "Proxy handler % has no '%' trap") \ | 190 T(ProxyHandlerTrapMissing, "Proxy handler % has no '%' trap") \ |
185 T(ProxyHandlerTrapMustBeCallable, \ | 191 T(ProxyHandlerTrapMustBeCallable, \ |
186 "Proxy handler %0 has non-callable '%' trap") \ | 192 "Proxy handler %0 has non-callable '%' trap") \ |
187 T(ProxyNonObjectPropNames, "Trap '%' returned non-object %") \ | 193 T(ProxyNonObjectPropNames, "Trap '%' returned non-object %") \ |
188 T(ProxyRepeatedPropName, "Trap '%' returned repeated property name '%'") \ | 194 T(ProxyProtoNonObject, "Proxy.create called with no-object as prototype") \ |
189 T(ProxyPropNotConfigurable, \ | 195 T(ProxyPropNotConfigurable, \ |
190 "Proxy handler % returned non-configurable descriptor for property '%' " \ | 196 "Proxy handler % returned non-configurable descriptor for property '%' " \ |
191 "from '%' trap") \ | 197 "from '%' trap") \ |
| 198 T(ProxyRepeatedPropName, "Trap '%' returned repeated property name '%'") \ |
| 199 T(ProxyTrapFunctionExpected, \ |
| 200 "Proxy.createFunction called with non-function for '%' trap") \ |
192 T(RedefineDisallowed, "Cannot redefine property: %") \ | 201 T(RedefineDisallowed, "Cannot redefine property: %") \ |
193 T(ReduceNoInitial, "Reduce of empty array with no initial value") \ | 202 T(ReduceNoInitial, "Reduce of empty array with no initial value") \ |
194 T(ReinitializeIntl, "Trying to re-initialize % object.") \ | 203 T(ReinitializeIntl, "Trying to re-initialize % object.") \ |
195 T(ResolvedOptionsCalledOnNonObject, \ | 204 T(ResolvedOptionsCalledOnNonObject, \ |
196 "resolvedOptions method called on a non-object or on a object that is " \ | 205 "resolvedOptions method called on a non-object or on a object that is " \ |
197 "not Intl.%.") \ | 206 "not Intl.%.") \ |
| 207 T(ResolverNotAFunction, "Promise resolver % is not a function") \ |
198 T(SymbolToPrimitive, \ | 208 T(SymbolToPrimitive, \ |
199 "Cannot convert a Symbol wrapper object to a primitive value") \ | 209 "Cannot convert a Symbol wrapper object to a primitive value") \ |
200 T(SymbolToNumber, "Cannot convert a Symbol value to a number") \ | 210 T(SymbolToNumber, "Cannot convert a Symbol value to a number") \ |
201 T(SymbolToString, "Cannot convert a Symbol value to a string") \ | 211 T(SymbolToString, "Cannot convert a Symbol value to a string") \ |
202 T(UndefinedOrNullToObject, "Cannot convert undefined or null to object") \ | 212 T(UndefinedOrNullToObject, "Cannot convert undefined or null to object") \ |
203 T(ValueAndAccessor, \ | 213 T(ValueAndAccessor, \ |
204 "Invalid property. A property cannot both have accessors and be " \ | 214 "Invalid property. A property cannot both have accessors and be " \ |
205 "writable or have a value, %") \ | 215 "writable or have a value, %") \ |
206 T(WithExpression, "% has no properties") \ | 216 T(WithExpression, "% has no properties") \ |
207 T(WrongArgs, "%: Arguments list has wrong type") \ | 217 T(WrongArgs, "%: Arguments list has wrong type") \ |
208 /* RangeError */ \ | 218 /* RangeError */ \ |
209 T(ArrayLengthOutOfRange, "defineProperty() array length out of range") \ | 219 T(ArrayLengthOutOfRange, "defineProperty() array length out of range") \ |
210 T(DateRange, "Provided date is not in valid range.") \ | 220 T(DateRange, "Provided date is not in valid range.") \ |
211 T(ExpectedLocation, "Expected Area/Location for time zone, got %") \ | 221 T(ExpectedLocation, "Expected Area/Location for time zone, got %") \ |
| 222 T(InvalidArrayBufferLength, "Invalid array buffer length") \ |
| 223 T(InvalidArrayLength, "Invalid array length") \ |
212 T(InvalidCodePoint, "Invalid code point %") \ | 224 T(InvalidCodePoint, "Invalid code point %") \ |
213 T(InvalidCountValue, "Invalid count value") \ | 225 T(InvalidCountValue, "Invalid count value") \ |
214 T(InvalidCurrencyCode, "Invalid currency code: %") \ | 226 T(InvalidCurrencyCode, "Invalid currency code: %") \ |
| 227 T(InvalidDataViewAccessorOffset, \ |
| 228 "Offset is outside the bounds of the DataView") \ |
| 229 T(InvalidDataViewLength, "Invalid data view length") \ |
| 230 T(InvalidDataViewOffset, "Start offset is outside the bounds of the buffer") \ |
215 T(InvalidLanguageTag, "Invalid language tag: %") \ | 231 T(InvalidLanguageTag, "Invalid language tag: %") \ |
| 232 T(InvalidStringLength, "Invalid string length") \ |
216 T(InvalidTimeValue, "Invalid time value") \ | 233 T(InvalidTimeValue, "Invalid time value") \ |
| 234 T(InvalidTypedArrayAlignment, "% of % should be a multiple of %") \ |
| 235 T(InvalidTypedArrayLength, "Invalid typed array length") \ |
| 236 T(InvalidTypedArrayOffset, "Start offset is too large:") \ |
217 T(LocaleMatcher, "Illegal value for localeMatcher:%") \ | 237 T(LocaleMatcher, "Illegal value for localeMatcher:%") \ |
218 T(NormalizationForm, "The normalization form should be one of %.") \ | 238 T(NormalizationForm, "The normalization form should be one of %.") \ |
219 T(NumberFormatRange, "% argument must be between 0 and 20") \ | 239 T(NumberFormatRange, "% argument must be between 0 and 20") \ |
220 T(PropertyValueOutOfRange, "% value is out of range.") \ | 240 T(PropertyValueOutOfRange, "% value is out of range.") \ |
221 T(StackOverflow, "Maximum call stack size exceeded") \ | 241 T(StackOverflow, "Maximum call stack size exceeded") \ |
222 T(ToPrecisionFormatRange, "toPrecision() argument must be between 1 and 21") \ | 242 T(ToPrecisionFormatRange, "toPrecision() argument must be between 1 and 21") \ |
223 T(ToRadixFormatRange, "toString() radix argument must be between 2 and 36") \ | 243 T(ToRadixFormatRange, "toString() radix argument must be between 2 and 36") \ |
| 244 T(TypedArraySetNegativeOffset, "Start offset is negative") \ |
| 245 T(TypedArraySetSourceTooLarge, "Source is too large") \ |
224 T(UnsupportedTimeZone, "Unsupported time zone specified %") \ | 246 T(UnsupportedTimeZone, "Unsupported time zone specified %") \ |
225 T(ValueOutOfRange, "Value % out of range for % options property %") \ | 247 T(ValueOutOfRange, "Value % out of range for % options property %") \ |
226 /* SyntaxError */ \ | 248 /* SyntaxError */ \ |
227 T(ParenthesisInArgString, "Function arg string contains parenthesis") \ | 249 T(ParenthesisInArgString, "Function arg string contains parenthesis") \ |
228 /* EvalError */ \ | 250 /* EvalError */ \ |
229 T(CodeGenFromStrings, "%") \ | 251 T(CodeGenFromStrings, "%") \ |
230 /* URIError */ \ | 252 /* URIError */ \ |
231 T(URIMalformed, "URI malformed") | 253 T(URIMalformed, "URI malformed") |
232 | 254 |
233 class MessageTemplate { | 255 class MessageTemplate { |
234 public: | 256 public: |
235 enum Template { | 257 enum Template { |
236 #define TEMPLATE(NAME, STRING) k##NAME, | 258 #define TEMPLATE(NAME, STRING) k##NAME, |
237 MESSAGE_TEMPLATES(TEMPLATE) | 259 MESSAGE_TEMPLATES(TEMPLATE) |
238 #undef TEMPLATE | 260 #undef TEMPLATE |
239 kLastMessage | 261 kLastMessage |
240 }; | 262 }; |
241 | 263 |
242 static MaybeHandle<String> FormatMessage(int template_index, | 264 static MaybeHandle<String> FormatMessage(int template_index, |
243 Handle<String> arg0, | 265 Handle<String> arg0, |
244 Handle<String> arg1, | 266 Handle<String> arg1, |
245 Handle<String> arg2); | 267 Handle<String> arg2); |
246 }; | 268 }; |
247 } } // namespace v8::internal | 269 } } // namespace v8::internal |
248 | 270 |
249 #endif // V8_MESSAGES_H_ | 271 #endif // V8_MESSAGES_H_ |
OLD | NEW |