Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 1 | // Copyright 2006-2008 the V8 project authors. All rights reserved. |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 4 | |
| 5 | // The infrastructure used for (localized) message reporting in V8. |
| 6 | // |
| 7 | // Note: there's a big unresolved issue about ownership of the data |
| 8 | // structures used by this framework. |
| 9 | |
| 10 | #ifndef V8_MESSAGES_H_ |
| 11 | #define V8_MESSAGES_H_ |
| 12 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 13 | #include "src/base/smart-pointers.h" |
| 14 | #include "src/handles.h" |
| 15 | #include "src/list.h" |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 16 | |
| 17 | namespace v8 { |
| 18 | namespace internal { |
| 19 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 20 | // Forward declarations. |
| 21 | class JSMessageObject; |
| 22 | class LookupIterator; |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 23 | class SourceInfo; |
| 24 | |
| 25 | class MessageLocation { |
| 26 | public: |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 27 | MessageLocation(Handle<Script> script, int start_pos, int end_pos, |
| 28 | Handle<JSFunction> function = Handle<JSFunction>()) |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 29 | : script_(script), |
| 30 | start_pos_(start_pos), |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 31 | end_pos_(end_pos), |
| 32 | function_(function) {} |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 33 | MessageLocation() : start_pos_(-1), end_pos_(-1) { } |
| 34 | |
| 35 | Handle<Script> script() const { return script_; } |
| 36 | int start_pos() const { return start_pos_; } |
| 37 | int end_pos() const { return end_pos_; } |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 38 | Handle<JSFunction> function() const { return function_; } |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 39 | |
| 40 | private: |
| 41 | Handle<Script> script_; |
| 42 | int start_pos_; |
| 43 | int end_pos_; |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 44 | Handle<JSFunction> function_; |
| 45 | }; |
| 46 | |
| 47 | |
| 48 | class CallSite { |
| 49 | public: |
| 50 | CallSite(Isolate* isolate, Handle<JSObject> call_site_obj); |
| 51 | |
| 52 | Handle<Object> GetFileName(); |
| 53 | Handle<Object> GetFunctionName(); |
| 54 | Handle<Object> GetScriptNameOrSourceUrl(); |
| 55 | Handle<Object> GetMethodName(); |
| 56 | // Return 1-based line number, including line offset. |
| 57 | int GetLineNumber(); |
| 58 | // Return 1-based column number, including column offset if first line. |
| 59 | int GetColumnNumber(); |
| 60 | bool IsNative(); |
| 61 | bool IsToplevel(); |
| 62 | bool IsEval(); |
| 63 | bool IsConstructor(); |
| 64 | |
| 65 | bool IsValid() { return !fun_.is_null(); } |
| 66 | |
| 67 | private: |
| 68 | Isolate* isolate_; |
| 69 | Handle<Object> receiver_; |
| 70 | Handle<JSFunction> fun_; |
| 71 | int32_t pos_; |
| 72 | }; |
| 73 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 74 | #define MESSAGE_TEMPLATES(T) \ |
| 75 | /* Error */ \ |
| 76 | T(None, "") \ |
| 77 | T(CyclicProto, "Cyclic __proto__ value") \ |
| 78 | T(Debugger, "Debugger: %") \ |
| 79 | T(DebuggerLoading, "Error loading debugger") \ |
| 80 | T(DefaultOptionsMissing, "Internal % error. Default options are missing.") \ |
| 81 | T(UncaughtException, "Uncaught %") \ |
| 82 | T(Unsupported, "Not supported") \ |
| 83 | T(WrongServiceType, "Internal error, wrong service type: %") \ |
| 84 | T(WrongValueType, "Internal error. Wrong value type.") \ |
| 85 | /* TypeError */ \ |
| 86 | T(ApplyNonFunction, \ |
| 87 | "Function.prototype.apply was called on %, which is a % and not a " \ |
| 88 | "function") \ |
| 89 | T(ArrayBufferTooShort, \ |
| 90 | "Derived ArrayBuffer constructor created a buffer which was too small") \ |
| 91 | T(ArrayBufferSpeciesThis, \ |
| 92 | "ArrayBuffer subclass returned this from species constructor") \ |
| 93 | T(ArrayFunctionsOnFrozen, "Cannot modify frozen array elements") \ |
| 94 | T(ArrayFunctionsOnSealed, "Cannot add/remove sealed array elements") \ |
| 95 | T(ArrayNotSubclassable, "Subclassing Arrays is not currently supported.") \ |
| 96 | T(CalledNonCallable, "% is not a function") \ |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 97 | T(CalledNonCallableInstanceOf, \ |
| 98 | "Right-hand side of 'instanceof' is not callable") \ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 99 | T(CalledOnNonObject, "% called on non-object") \ |
| 100 | T(CalledOnNullOrUndefined, "% called on null or undefined") \ |
| 101 | T(CallSiteExpectsFunction, \ |
| 102 | "CallSite expects function as second argument, got %") \ |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 103 | T(CallSiteMethod, "CallSite method % expects CallSite as receiver") \ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 104 | T(CannotConvertToPrimitive, "Cannot convert object to primitive value") \ |
| 105 | T(CannotPreventExt, "Cannot prevent extensions") \ |
| 106 | T(CannotFreezeArrayBufferView, \ |
| 107 | "Cannot freeze array buffer views with elements") \ |
| 108 | T(CircularStructure, "Converting circular structure to JSON") \ |
| 109 | T(ConstructAbstractClass, "Abstract class % not directly constructable") \ |
| 110 | T(ConstAssign, "Assignment to constant variable.") \ |
| 111 | T(ConstructorNonCallable, \ |
| 112 | "Class constructor % cannot be invoked without 'new'") \ |
| 113 | T(ConstructorNotFunction, "Constructor % requires 'new'") \ |
| 114 | T(ConstructorNotReceiver, "The .constructor property is not an object") \ |
| 115 | T(CurrencyCode, "Currency code is required with currency style.") \ |
| 116 | T(DataViewNotArrayBuffer, \ |
| 117 | "First argument to DataView constructor must be an ArrayBuffer") \ |
| 118 | T(DateType, "this is not a Date object.") \ |
| 119 | T(DebuggerFrame, "Debugger: Invalid frame index.") \ |
| 120 | T(DebuggerType, "Debugger: Parameters have wrong types.") \ |
| 121 | T(DeclarationMissingInitializer, "Missing initializer in % declaration") \ |
| 122 | T(DefineDisallowed, "Cannot define property:%, object is not extensible.") \ |
| 123 | T(DuplicateTemplateProperty, "Object template has duplicate property '%'") \ |
| 124 | T(ExtendsValueGenerator, \ |
| 125 | "Class extends value % may not be a generator function") \ |
| 126 | T(ExtendsValueNotFunction, \ |
| 127 | "Class extends value % is not a function or null") \ |
| 128 | T(FirstArgumentNotRegExp, \ |
| 129 | "First argument to % must not be a regular expression") \ |
| 130 | T(FunctionBind, "Bind must be called on a function") \ |
| 131 | T(GeneratorRunning, "Generator is already running") \ |
| 132 | T(IllegalInvocation, "Illegal invocation") \ |
| 133 | T(IncompatibleMethodReceiver, "Method % called on incompatible receiver %") \ |
| 134 | T(InstanceofFunctionExpected, \ |
| 135 | "Expecting a function in instanceof check, but got %") \ |
| 136 | T(InstanceofNonobjectProto, \ |
| 137 | "Function has non-object prototype '%' in instanceof check") \ |
| 138 | T(InvalidArgument, "invalid_argument") \ |
| 139 | T(InvalidInOperatorUse, "Cannot use 'in' operator to search for '%' in %") \ |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 140 | T(InvalidRegExpExecResult, \ |
| 141 | "RegExp exec method returned something other than an Object or null") \ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 142 | T(InvalidSimdOperation, "% is not a valid type for this SIMD operation.") \ |
| 143 | T(IteratorResultNotAnObject, "Iterator result % is not an object") \ |
| 144 | T(IteratorValueNotAnObject, "Iterator value % is not an entry object") \ |
| 145 | T(LanguageID, "Language ID should be string or object.") \ |
| 146 | T(MethodCalledOnWrongObject, \ |
| 147 | "Method % called on a non-object or on a wrong type of object.") \ |
| 148 | T(MethodInvokedOnNullOrUndefined, \ |
| 149 | "Method invoked on undefined or null value.") \ |
| 150 | T(MethodInvokedOnWrongType, "Method invoked on an object that is not %.") \ |
| 151 | T(NoAccess, "no access") \ |
| 152 | T(NonCoercible, "Cannot match against 'undefined' or 'null'.") \ |
| 153 | T(NonExtensibleProto, "% is not extensible") \ |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 154 | T(NonObjectInInstanceOfCheck, \ |
| 155 | "Right-hand side of 'instanceof' is not an object") \ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 156 | T(NonObjectPropertyLoad, "Cannot read property '%' of %") \ |
| 157 | T(NonObjectPropertyStore, "Cannot set property '%' of %") \ |
| 158 | T(NoSetterInCallback, "Cannot set property % of % which has only a getter") \ |
| 159 | T(NotAnIterator, "% is not an iterator") \ |
| 160 | T(NotAPromise, "% is not a promise") \ |
| 161 | T(NotConstructor, "% is not a constructor") \ |
| 162 | T(NotDateObject, "this is not a Date object.") \ |
| 163 | T(NotIntlObject, "% is not an i18n object.") \ |
| 164 | T(NotGeneric, "% is not generic") \ |
| 165 | T(NotIterable, "% is not iterable") \ |
| 166 | T(NotPropertyName, "% is not a valid property name") \ |
| 167 | T(NotTypedArray, "this is not a typed array.") \ |
| 168 | T(NotSharedTypedArray, "% is not a shared typed array.") \ |
| 169 | T(NotIntegerSharedTypedArray, "% is not an integer shared typed array.") \ |
| 170 | T(NotInt32SharedTypedArray, "% is not an int32 shared typed array.") \ |
| 171 | T(ObjectGetterExpectingFunction, \ |
| 172 | "Object.prototype.__defineGetter__: Expecting function") \ |
| 173 | T(ObjectGetterCallable, "Getter must be a function: %") \ |
| 174 | T(ObjectNotExtensible, "Can't add property %, object is not extensible") \ |
| 175 | T(ObjectSetterExpectingFunction, \ |
| 176 | "Object.prototype.__defineSetter__: Expecting function") \ |
| 177 | T(ObjectSetterCallable, "Setter must be a function: %") \ |
| 178 | T(ObserveCallbackFrozen, \ |
| 179 | "Object.observe cannot deliver to a frozen function object") \ |
| 180 | T(ObserveGlobalProxy, "% cannot be called on the global proxy object") \ |
| 181 | T(ObserveAccessChecked, "% cannot be called on access-checked objects") \ |
| 182 | T(ObserveInvalidAccept, \ |
| 183 | "Third argument to Object.observe must be an array of strings.") \ |
| 184 | T(ObserveNonFunction, "Object.% cannot deliver to non-function") \ |
| 185 | T(ObserveNonObject, "Object.% cannot % non-object") \ |
| 186 | T(ObserveNotifyNonNotifier, "notify called on non-notifier object") \ |
| 187 | T(ObservePerformNonFunction, "Cannot perform non-function") \ |
| 188 | T(ObservePerformNonString, "Invalid non-string changeType") \ |
| 189 | T(ObserveTypeNonString, \ |
| 190 | "Invalid changeRecord with non-string 'type' property") \ |
| 191 | T(OrdinaryFunctionCalledAsConstructor, \ |
| 192 | "Function object that's not a constructor was created with new") \ |
| 193 | T(PromiseCyclic, "Chaining cycle detected for promise %") \ |
| 194 | T(PromiseExecutorAlreadyInvoked, \ |
| 195 | "Promise executor has already been invoked with non-undefined arguments") \ |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 196 | T(PromiseNonCallable, "Promise resolve or reject function is not callable") \ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 197 | T(PropertyDescObject, "Property description must be an object: %") \ |
| 198 | T(PropertyNotFunction, \ |
| 199 | "'%' returned for property '%' of object '%' is not a function") \ |
| 200 | T(ProtoObjectOrNull, "Object prototype may only be an Object or null: %") \ |
| 201 | T(PrototypeParentNotAnObject, \ |
| 202 | "Class extends value does not have valid prototype property %") \ |
| 203 | T(ProxyConstructNonObject, \ |
| 204 | "'construct' on proxy: trap returned non-object ('%')") \ |
| 205 | T(ProxyDefinePropertyNonConfigurable, \ |
| 206 | "'defineProperty' on proxy: trap returned truish for defining " \ |
| 207 | "non-configurable property '%' which is either non-existant or " \ |
| 208 | "configurable in the proxy target") \ |
| 209 | T(ProxyDefinePropertyNonExtensible, \ |
| 210 | "'defineProperty' on proxy: trap returned truish for adding property '%' " \ |
| 211 | " to the non-extensible proxy target") \ |
| 212 | T(ProxyDefinePropertyIncompatible, \ |
| 213 | "'defineProperty' on proxy: trap returned truish for adding property '%' " \ |
| 214 | " that is incompatible with the existing property in the proxy target") \ |
| 215 | T(ProxyDeletePropertyNonConfigurable, \ |
| 216 | "'deleteProperty' on proxy: trap returned truish for property '%' which " \ |
| 217 | "is non-configurable in the proxy target") \ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 218 | T(ProxyGetNonConfigurableData, \ |
| 219 | "'get' on proxy: property '%' is a read-only and " \ |
| 220 | "non-configurable data property on the proxy target but the proxy " \ |
| 221 | "did not return its actual value (expected '%' but got '%')") \ |
| 222 | T(ProxyGetNonConfigurableAccessor, \ |
| 223 | "'get' on proxy: property '%' is a non-configurable accessor " \ |
| 224 | "property on the proxy target and does not have a getter function, but " \ |
| 225 | "the trap did not return 'undefined' (got '%')") \ |
| 226 | T(ProxyGetOwnPropertyDescriptorIncompatible, \ |
| 227 | "'getOwnPropertyDescriptor' on proxy: trap returned descriptor for " \ |
| 228 | "property '%' that is incompatible with the existing property in the " \ |
| 229 | "proxy target") \ |
| 230 | T(ProxyGetOwnPropertyDescriptorInvalid, \ |
| 231 | "'getOwnPropertyDescriptor' on proxy: trap returned neither object nor " \ |
| 232 | "undefined for property '%'") \ |
| 233 | T(ProxyGetOwnPropertyDescriptorNonConfigurable, \ |
| 234 | "'getOwnPropertyDescriptor' on proxy: trap reported non-configurability " \ |
| 235 | "for property '%' which is either non-existant or configurable in the " \ |
| 236 | "proxy target") \ |
| 237 | T(ProxyGetOwnPropertyDescriptorNonExtensible, \ |
| 238 | "'getOwnPropertyDescriptor' on proxy: trap returned undefined for " \ |
| 239 | "property '%' which exists in the non-extensible proxy target") \ |
| 240 | T(ProxyGetOwnPropertyDescriptorUndefined, \ |
| 241 | "'getOwnPropertyDescriptor' on proxy: trap returned undefined for " \ |
| 242 | "property '%' which is non-configurable in the proxy target") \ |
| 243 | T(ProxyGetPrototypeOfInvalid, \ |
| 244 | "'getPrototypeOf' on proxy: trap returned neither object nor null") \ |
| 245 | T(ProxyGetPrototypeOfNonExtensible, \ |
| 246 | "'getPrototypeOf' on proxy: proxy target is non-extensible but the " \ |
| 247 | "trap did not return its actual prototype") \ |
| 248 | T(ProxyHandlerOrTargetRevoked, \ |
| 249 | "Cannot create proxy with a revoked proxy as target or handler") \ |
| 250 | T(ProxyHasNonConfigurable, \ |
| 251 | "'has' on proxy: trap returned falsish for property '%' which exists in " \ |
| 252 | "the proxy target as non-configurable") \ |
| 253 | T(ProxyHasNonExtensible, \ |
| 254 | "'has' on proxy: trap returned falsish for property '%' but the proxy " \ |
| 255 | "target is not extensible") \ |
| 256 | T(ProxyIsExtensibleInconsistent, \ |
| 257 | "'isExtensible' on proxy: trap result does not reflect extensibility of " \ |
| 258 | "proxy target (which is '%')") \ |
| 259 | T(ProxyNonObject, \ |
| 260 | "Cannot create proxy with a non-object as target or handler") \ |
| 261 | T(ProxyOwnKeysMissing, \ |
| 262 | "'ownKeys' on proxy: trap result did not include '%'") \ |
| 263 | T(ProxyOwnKeysNonExtensible, \ |
| 264 | "'ownKeys' on proxy: trap returned extra keys but proxy target is " \ |
| 265 | "non-extensible") \ |
| 266 | T(ProxyPreventExtensionsExtensible, \ |
| 267 | "'preventExtensions' on proxy: trap returned truish but the proxy target " \ |
| 268 | "is extensible") \ |
| 269 | T(ProxyPrivate, "Cannot pass private property name to proxy trap") \ |
| 270 | T(ProxyRevoked, "Cannot perform '%' on a proxy that has been revoked") \ |
| 271 | T(ProxySetFrozenData, \ |
| 272 | "'set' on proxy: trap returned truish for property '%' which exists in " \ |
| 273 | "the proxy target as a non-configurable and non-writable data property " \ |
| 274 | "with a different value") \ |
| 275 | T(ProxySetFrozenAccessor, \ |
| 276 | "'set' on proxy: trap returned truish for property '%' which exists in " \ |
| 277 | "the proxy target as a non-configurable and non-writable accessor " \ |
| 278 | "property without a setter") \ |
| 279 | T(ProxySetPrototypeOfNonExtensible, \ |
| 280 | "'setPrototypeOf' on proxy: trap returned truish for setting a new " \ |
| 281 | "prototype on the non-extensible proxy target") \ |
| 282 | T(ProxyTrapReturnedFalsish, "'%' on proxy: trap returned falsish") \ |
| 283 | T(ProxyTrapReturnedFalsishFor, \ |
| 284 | "'%' on proxy: trap returned falsish for property '%'") \ |
| 285 | T(ReadGlobalReferenceThroughProxy, "Trying to access '%' through proxy") \ |
| 286 | T(RedefineDisallowed, "Cannot redefine property: %") \ |
| 287 | T(RedefineExternalArray, \ |
| 288 | "Cannot redefine a property of an object with external array elements") \ |
| 289 | T(ReduceNoInitial, "Reduce of empty array with no initial value") \ |
| 290 | T(RegExpFlags, \ |
| 291 | "Cannot supply flags when constructing one RegExp from another") \ |
| 292 | T(RegExpNonObject, "% getter called on non-object %") \ |
| 293 | T(RegExpNonRegExp, "% getter called on non-RegExp object") \ |
| 294 | T(ReinitializeIntl, "Trying to re-initialize % object.") \ |
| 295 | T(ResolvedOptionsCalledOnNonObject, \ |
| 296 | "resolvedOptions method called on a non-object or on a object that is " \ |
| 297 | "not Intl.%.") \ |
| 298 | T(ResolverNotAFunction, "Promise resolver % is not a function") \ |
| 299 | T(RestrictedFunctionProperties, \ |
| 300 | "'caller' and 'arguments' are restricted function properties and cannot " \ |
| 301 | "be accessed in this context.") \ |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 302 | T(ReturnMethodNotCallable, "The iterator's 'return' method is not callable") \ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 303 | T(StaticPrototype, "Classes may not have static property named prototype") \ |
| 304 | T(StrictCannotAssign, "Cannot assign to read only '%' in strict mode") \ |
| 305 | T(StrictDeleteProperty, "Cannot delete property '%' of %") \ |
| 306 | T(StrictPoisonPill, \ |
| 307 | "'caller', 'callee', and 'arguments' properties may not be accessed on " \ |
| 308 | "strict mode functions or the arguments objects for calls to them") \ |
| 309 | T(StrictReadOnlyProperty, \ |
| 310 | "Cannot assign to read only property '%' of % '%'") \ |
| 311 | T(StrictCannotCreateProperty, "Cannot create property '%' on % '%'") \ |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 312 | T(SymbolIteratorInvalid, \ |
| 313 | "Result of the Symbol.iterator method is not an object") \ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 314 | T(SymbolKeyFor, "% is not a symbol") \ |
| 315 | T(SymbolToNumber, "Cannot convert a Symbol value to a number") \ |
| 316 | T(SymbolToString, "Cannot convert a Symbol value to a string") \ |
| 317 | T(SimdToNumber, "Cannot convert a SIMD value to a number") \ |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 318 | T(ThrowMethodMissing, "The iterator does not provide a 'throw' method.") \ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 319 | T(UndefinedOrNullToObject, "Cannot convert undefined or null to object") \ |
| 320 | T(ValueAndAccessor, \ |
| 321 | "Invalid property descriptor. Cannot both specify accessors and a value " \ |
| 322 | "or writable attribute, %") \ |
| 323 | T(VarRedeclaration, "Identifier '%' has already been declared") \ |
| 324 | T(WrongArgs, "%: Arguments list has wrong type") \ |
| 325 | /* ReferenceError */ \ |
| 326 | T(NonMethod, "'super' is referenced from non-method") \ |
| 327 | T(NotDefined, "% is not defined") \ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 328 | T(UnsupportedSuper, "Unsupported reference to 'super'") \ |
| 329 | /* RangeError */ \ |
| 330 | T(DateRange, "Provided date is not in valid range.") \ |
| 331 | T(ExpectedTimezoneID, \ |
| 332 | "Expected Area/Location(/Location)* for time zone, got %") \ |
| 333 | T(ExpectedLocation, \ |
| 334 | "Expected letters optionally connected with underscores or hyphens for " \ |
| 335 | "a location, got %") \ |
| 336 | T(InvalidArrayBufferLength, "Invalid array buffer length") \ |
| 337 | T(ArrayBufferAllocationFailed, "Array buffer allocation failed") \ |
| 338 | T(InvalidArrayLength, "Invalid array length") \ |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 339 | T(InvalidAtomicAccessIndex, "Invalid atomic access index") \ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 340 | T(InvalidCodePoint, "Invalid code point %") \ |
| 341 | T(InvalidCountValue, "Invalid count value") \ |
| 342 | T(InvalidCurrencyCode, "Invalid currency code: %") \ |
| 343 | T(InvalidDataViewAccessorOffset, \ |
| 344 | "Offset is outside the bounds of the DataView") \ |
| 345 | T(InvalidDataViewLength, "Invalid data view length") \ |
| 346 | T(InvalidDataViewOffset, "Start offset is outside the bounds of the buffer") \ |
| 347 | T(InvalidHint, "Invalid hint: %") \ |
| 348 | T(InvalidLanguageTag, "Invalid language tag: %") \ |
| 349 | T(InvalidWeakMapKey, "Invalid value used as weak map key") \ |
| 350 | T(InvalidWeakSetValue, "Invalid value used in weak set") \ |
| 351 | T(InvalidStringLength, "Invalid string length") \ |
| 352 | T(InvalidTimeValue, "Invalid time value") \ |
| 353 | T(InvalidTypedArrayAlignment, "% of % should be a multiple of %") \ |
| 354 | T(InvalidTypedArrayLength, "Invalid typed array length") \ |
| 355 | T(InvalidTypedArrayOffset, "Start offset is too large:") \ |
| 356 | T(LetInLexicalBinding, "let is disallowed as a lexically bound name") \ |
| 357 | T(LocaleMatcher, "Illegal value for localeMatcher:%") \ |
| 358 | T(NormalizationForm, "The normalization form should be one of %.") \ |
| 359 | T(NumberFormatRange, "% argument must be between 0 and 20") \ |
| 360 | T(PropertyValueOutOfRange, "% value is out of range.") \ |
| 361 | T(StackOverflow, "Maximum call stack size exceeded") \ |
| 362 | T(ToPrecisionFormatRange, "toPrecision() argument must be between 1 and 21") \ |
| 363 | T(ToRadixFormatRange, "toString() radix argument must be between 2 and 36") \ |
| 364 | T(TypedArraySetNegativeOffset, "Start offset is negative") \ |
| 365 | T(TypedArraySetSourceTooLarge, "Source is too large") \ |
| 366 | T(UnsupportedTimeZone, "Unsupported time zone specified %") \ |
| 367 | T(ValueOutOfRange, "Value % out of range for % options property %") \ |
| 368 | /* SyntaxError */ \ |
| 369 | T(BadGetterArity, "Getter must not have any formal parameters.") \ |
| 370 | T(BadSetterArity, "Setter must have exactly one formal parameter.") \ |
| 371 | T(ConstructorIsAccessor, "Class constructor may not be an accessor") \ |
| 372 | T(ConstructorIsGenerator, "Class constructor may not be a generator") \ |
| 373 | T(DerivedConstructorReturn, \ |
| 374 | "Derived constructors may only return object or undefined") \ |
| 375 | T(DuplicateConstructor, "A class may only have one constructor") \ |
| 376 | T(DuplicateExport, "Duplicate export of '%'") \ |
| 377 | T(DuplicateProto, \ |
| 378 | "Duplicate __proto__ fields are not allowed in object literals") \ |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 379 | T(ForInOfLoopInitializer, \ |
| 380 | "% loop variable declaration may not have an initializer.") \ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 381 | T(ForInOfLoopMultiBindings, \ |
| 382 | "Invalid left-hand side in % loop: Must have a single binding.") \ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 383 | T(IllegalBreak, "Illegal break statement") \ |
| 384 | T(IllegalContinue, "Illegal continue statement") \ |
| 385 | T(IllegalLanguageModeDirective, \ |
| 386 | "Illegal '%' directive in function with non-simple parameter list") \ |
| 387 | T(IllegalReturn, "Illegal return statement") \ |
| 388 | T(InvalidEscapedReservedWord, "Keyword must not contain escaped characters") \ |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 389 | T(InvalidEscapedMetaProperty, "'%' must not contain escaped characters") \ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 390 | T(InvalidLhsInAssignment, "Invalid left-hand side in assignment") \ |
| 391 | T(InvalidCoverInitializedName, "Invalid shorthand property initializer") \ |
| 392 | T(InvalidDestructuringTarget, "Invalid destructuring assignment target") \ |
| 393 | T(InvalidLhsInFor, "Invalid left-hand side in for-loop") \ |
| 394 | T(InvalidLhsInPostfixOp, \ |
| 395 | "Invalid left-hand side expression in postfix operation") \ |
| 396 | T(InvalidLhsInPrefixOp, \ |
| 397 | "Invalid left-hand side expression in prefix operation") \ |
| 398 | T(InvalidRegExpFlags, "Invalid flags supplied to RegExp constructor '%'") \ |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 399 | T(InvalidOrUnexpectedToken, "Invalid or unexpected token") \ |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 400 | T(JsonParseUnexpectedEOS, "Unexpected end of JSON input") \ |
| 401 | T(JsonParseUnexpectedToken, "Unexpected token % in JSON at position %") \ |
| 402 | T(JsonParseUnexpectedTokenNumber, "Unexpected number in JSON at position %") \ |
| 403 | T(JsonParseUnexpectedTokenString, "Unexpected string in JSON at position %") \ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 404 | T(LabelRedeclaration, "Label '%' has already been declared") \ |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 405 | T(LabelledFunctionDeclaration, \ |
| 406 | "Labelled function declaration not allowed as the body of a control flow " \ |
| 407 | "structure") \ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 408 | T(MalformedArrowFunParamList, "Malformed arrow function parameter list") \ |
| 409 | T(MalformedRegExp, "Invalid regular expression: /%/: %") \ |
| 410 | T(MalformedRegExpFlags, "Invalid regular expression flags") \ |
| 411 | T(ModuleExportUndefined, "Export '%' is not defined in module") \ |
| 412 | T(MultipleDefaultsInSwitch, \ |
| 413 | "More than one default clause in switch statement") \ |
| 414 | T(NewlineAfterThrow, "Illegal newline after throw") \ |
| 415 | T(NoCatchOrFinally, "Missing catch or finally after try") \ |
| 416 | T(NotIsvar, "builtin %%IS_VAR: not a variable") \ |
| 417 | T(ParamAfterRest, "Rest parameter must be last formal parameter") \ |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 418 | T(InvalidRestParameter, \ |
| 419 | "Rest parameter must be an identifier or destructuring pattern") \ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 420 | T(PushPastSafeLength, \ |
| 421 | "Pushing % elements on an array-like of length % " \ |
| 422 | "is disallowed, as the total surpasses 2**53-1") \ |
| 423 | T(ElementAfterRest, "Rest element must be last element in array") \ |
| 424 | T(BadSetterRestParameter, \ |
| 425 | "Setter function argument must not be a rest parameter") \ |
| 426 | T(ParamDupe, "Duplicate parameter name not allowed in this context") \ |
| 427 | T(ParenthesisInArgString, "Function arg string contains parenthesis") \ |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 428 | T(RuntimeWrongNumArgs, "Runtime function given wrong number of arguments") \ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 429 | T(SingleFunctionLiteral, "Single function literal required") \ |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 430 | T(SloppyFunction, \ |
| 431 | "In non-strict mode code, functions can only be declared at top level, " \ |
| 432 | "inside a block, or as the body of an if statement.") \ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 433 | T(SloppyLexical, \ |
| 434 | "Block-scoped declarations (let, const, function, class) not yet " \ |
| 435 | "supported outside strict mode") \ |
| 436 | T(SpeciesNotConstructor, \ |
| 437 | "object.constructor[Symbol.species] is not a constructor") \ |
| 438 | T(StrictDelete, "Delete of an unqualified identifier in strict mode.") \ |
| 439 | T(StrictEvalArguments, "Unexpected eval or arguments in strict mode") \ |
| 440 | T(StrictFunction, \ |
| 441 | "In strict mode code, functions can only be declared at top level or " \ |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 442 | "inside a block.") \ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 443 | T(StrictOctalLiteral, "Octal literals are not allowed in strict mode.") \ |
| 444 | T(StrictWith, "Strict mode code may not include a with statement") \ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 445 | T(TemplateOctalLiteral, \ |
| 446 | "Octal literals are not allowed in template strings.") \ |
| 447 | T(ThisFormalParameter, "'this' is not a valid formal parameter name") \ |
| 448 | T(TooManyArguments, \ |
| 449 | "Too many arguments in function call (only 65535 allowed)") \ |
| 450 | T(TooManyParameters, \ |
| 451 | "Too many parameters in function definition (only 65535 allowed)") \ |
| 452 | T(TooManyVariables, "Too many variables declared (only 4194303 allowed)") \ |
| 453 | T(TypedArrayTooShort, \ |
| 454 | "Derived TypedArray constructor created an array which was too small") \ |
| 455 | T(UnexpectedEOS, "Unexpected end of input") \ |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 456 | T(UnexpectedFunctionSent, \ |
| 457 | "function.sent expression is not allowed outside a generator") \ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 458 | T(UnexpectedReserved, "Unexpected reserved word") \ |
| 459 | T(UnexpectedStrictReserved, "Unexpected strict mode reserved word") \ |
| 460 | T(UnexpectedSuper, "'super' keyword unexpected here") \ |
| 461 | T(UnexpectedNewTarget, "new.target expression is not allowed here") \ |
| 462 | T(UnexpectedTemplateString, "Unexpected template string") \ |
| 463 | T(UnexpectedToken, "Unexpected token %") \ |
| 464 | T(UnexpectedTokenIdentifier, "Unexpected identifier") \ |
| 465 | T(UnexpectedTokenNumber, "Unexpected number") \ |
| 466 | T(UnexpectedTokenString, "Unexpected string") \ |
| 467 | T(UnexpectedTokenRegExp, "Unexpected regular expression") \ |
| 468 | T(UnknownLabel, "Undefined label '%'") \ |
| 469 | T(UnterminatedArgList, "missing ) after argument list") \ |
| 470 | T(UnterminatedRegExp, "Invalid regular expression: missing /") \ |
| 471 | T(UnterminatedTemplate, "Unterminated template literal") \ |
| 472 | T(UnterminatedTemplateExpr, "Missing } in template expression") \ |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 473 | T(FoundNonCallableHasInstance, "Found non-callable @@hasInstance") \ |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame^] | 474 | T(InvalidHexEscapeSequence, "Invalid hexadecimal escape sequence") \ |
| 475 | T(InvalidUnicodeEscapeSequence, "Invalid Unicode escape sequence") \ |
| 476 | T(UndefinedUnicodeCodePoint, "Undefined Unicode code-point") \ |
| 477 | T(YieldInParameter, "Yield expression not allowed in formal parameter") \ |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 478 | /* EvalError */ \ |
| 479 | T(CodeGenFromStrings, "%") \ |
| 480 | /* URIError */ \ |
| 481 | T(URIMalformed, "URI malformed") |
| 482 | |
| 483 | class MessageTemplate { |
| 484 | public: |
| 485 | enum Template { |
| 486 | #define TEMPLATE(NAME, STRING) k##NAME, |
| 487 | MESSAGE_TEMPLATES(TEMPLATE) |
| 488 | #undef TEMPLATE |
| 489 | kLastMessage |
| 490 | }; |
| 491 | |
| 492 | static const char* TemplateString(int template_index); |
| 493 | |
| 494 | static MaybeHandle<String> FormatMessage(int template_index, |
| 495 | Handle<String> arg0, |
| 496 | Handle<String> arg1, |
| 497 | Handle<String> arg2); |
| 498 | |
| 499 | static Handle<String> FormatMessage(Isolate* isolate, int template_index, |
| 500 | Handle<Object> arg); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 501 | }; |
| 502 | |
| 503 | |
| 504 | // A message handler is a convenience interface for accessing the list |
| 505 | // of message listeners registered in an environment |
| 506 | class MessageHandler { |
| 507 | public: |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 508 | // Returns a message object for the API to use. |
Steve Block | 1e0659c | 2011-05-24 12:43:12 +0100 | [diff] [blame] | 509 | static Handle<JSMessageObject> MakeMessageObject( |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 510 | Isolate* isolate, MessageTemplate::Template type, |
| 511 | MessageLocation* location, Handle<Object> argument, |
Steve Block | 1e0659c | 2011-05-24 12:43:12 +0100 | [diff] [blame] | 512 | Handle<JSArray> stack_frames); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 513 | |
| 514 | // Report a formatted message (needs JS allocation). |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 515 | static void ReportMessage(Isolate* isolate, MessageLocation* loc, |
| 516 | Handle<JSMessageObject> message); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 517 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 518 | static void DefaultMessageReport(Isolate* isolate, const MessageLocation* loc, |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 519 | Handle<Object> message_obj); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 520 | static Handle<String> GetMessage(Isolate* isolate, Handle<Object> data); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 521 | static base::SmartArrayPointer<char> GetLocalizedMessage(Isolate* isolate, |
| 522 | Handle<Object> data); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 523 | }; |
| 524 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 525 | |
| 526 | } // namespace internal |
| 527 | } // namespace v8 |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 528 | |
| 529 | #endif // V8_MESSAGES_H_ |