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 | |
| 74 | |
| 75 | #define MESSAGE_TEMPLATES(T) \ |
| 76 | /* Error */ \ |
| 77 | T(None, "") \ |
| 78 | T(CyclicProto, "Cyclic __proto__ value") \ |
| 79 | T(Debugger, "Debugger: %") \ |
| 80 | T(DebuggerLoading, "Error loading debugger") \ |
| 81 | T(DefaultOptionsMissing, "Internal % error. Default options are missing.") \ |
| 82 | T(UncaughtException, "Uncaught %") \ |
| 83 | T(Unsupported, "Not supported") \ |
| 84 | T(WrongServiceType, "Internal error, wrong service type: %") \ |
| 85 | T(WrongValueType, "Internal error. Wrong value type.") \ |
| 86 | /* TypeError */ \ |
| 87 | T(ApplyNonFunction, \ |
| 88 | "Function.prototype.apply was called on %, which is a % and not a " \ |
| 89 | "function") \ |
| 90 | T(ArrayBufferTooShort, \ |
| 91 | "Derived ArrayBuffer constructor created a buffer which was too small") \ |
| 92 | T(ArrayBufferSpeciesThis, \ |
| 93 | "ArrayBuffer subclass returned this from species constructor") \ |
| 94 | T(ArrayFunctionsOnFrozen, "Cannot modify frozen array elements") \ |
| 95 | T(ArrayFunctionsOnSealed, "Cannot add/remove sealed array elements") \ |
| 96 | T(ArrayNotSubclassable, "Subclassing Arrays is not currently supported.") \ |
| 97 | T(CalledNonCallable, "% is not a function") \ |
| 98 | T(CalledOnNonObject, "% called on non-object") \ |
| 99 | T(CalledOnNullOrUndefined, "% called on null or undefined") \ |
| 100 | T(CallSiteExpectsFunction, \ |
| 101 | "CallSite expects function as second argument, got %") \ |
| 102 | T(CannotConvertToPrimitive, "Cannot convert object to primitive value") \ |
| 103 | T(CannotPreventExt, "Cannot prevent extensions") \ |
| 104 | T(CannotFreezeArrayBufferView, \ |
| 105 | "Cannot freeze array buffer views with elements") \ |
| 106 | T(CircularStructure, "Converting circular structure to JSON") \ |
| 107 | T(ConstructAbstractClass, "Abstract class % not directly constructable") \ |
| 108 | T(ConstAssign, "Assignment to constant variable.") \ |
| 109 | T(ConstructorNonCallable, \ |
| 110 | "Class constructor % cannot be invoked without 'new'") \ |
| 111 | T(ConstructorNotFunction, "Constructor % requires 'new'") \ |
| 112 | T(ConstructorNotReceiver, "The .constructor property is not an object") \ |
| 113 | T(CurrencyCode, "Currency code is required with currency style.") \ |
| 114 | T(DataViewNotArrayBuffer, \ |
| 115 | "First argument to DataView constructor must be an ArrayBuffer") \ |
| 116 | T(DateType, "this is not a Date object.") \ |
| 117 | T(DebuggerFrame, "Debugger: Invalid frame index.") \ |
| 118 | T(DebuggerType, "Debugger: Parameters have wrong types.") \ |
| 119 | T(DeclarationMissingInitializer, "Missing initializer in % declaration") \ |
| 120 | T(DefineDisallowed, "Cannot define property:%, object is not extensible.") \ |
| 121 | T(DuplicateTemplateProperty, "Object template has duplicate property '%'") \ |
| 122 | T(ExtendsValueGenerator, \ |
| 123 | "Class extends value % may not be a generator function") \ |
| 124 | T(ExtendsValueNotFunction, \ |
| 125 | "Class extends value % is not a function or null") \ |
| 126 | T(FirstArgumentNotRegExp, \ |
| 127 | "First argument to % must not be a regular expression") \ |
| 128 | T(FunctionBind, "Bind must be called on a function") \ |
| 129 | T(GeneratorRunning, "Generator is already running") \ |
| 130 | T(IllegalInvocation, "Illegal invocation") \ |
| 131 | T(IncompatibleMethodReceiver, "Method % called on incompatible receiver %") \ |
| 132 | T(InstanceofFunctionExpected, \ |
| 133 | "Expecting a function in instanceof check, but got %") \ |
| 134 | T(InstanceofNonobjectProto, \ |
| 135 | "Function has non-object prototype '%' in instanceof check") \ |
| 136 | T(InvalidArgument, "invalid_argument") \ |
| 137 | T(InvalidInOperatorUse, "Cannot use 'in' operator to search for '%' in %") \ |
| 138 | T(InvalidSimdOperation, "% is not a valid type for this SIMD operation.") \ |
| 139 | T(IteratorResultNotAnObject, "Iterator result % is not an object") \ |
| 140 | T(IteratorValueNotAnObject, "Iterator value % is not an entry object") \ |
| 141 | T(LanguageID, "Language ID should be string or object.") \ |
| 142 | T(MethodCalledOnWrongObject, \ |
| 143 | "Method % called on a non-object or on a wrong type of object.") \ |
| 144 | T(MethodInvokedOnNullOrUndefined, \ |
| 145 | "Method invoked on undefined or null value.") \ |
| 146 | T(MethodInvokedOnWrongType, "Method invoked on an object that is not %.") \ |
| 147 | T(NoAccess, "no access") \ |
| 148 | T(NonCoercible, "Cannot match against 'undefined' or 'null'.") \ |
| 149 | T(NonExtensibleProto, "% is not extensible") \ |
| 150 | T(NonObjectPropertyLoad, "Cannot read property '%' of %") \ |
| 151 | T(NonObjectPropertyStore, "Cannot set property '%' of %") \ |
| 152 | T(NoSetterInCallback, "Cannot set property % of % which has only a getter") \ |
| 153 | T(NotAnIterator, "% is not an iterator") \ |
| 154 | T(NotAPromise, "% is not a promise") \ |
| 155 | T(NotConstructor, "% is not a constructor") \ |
| 156 | T(NotDateObject, "this is not a Date object.") \ |
| 157 | T(NotIntlObject, "% is not an i18n object.") \ |
| 158 | T(NotGeneric, "% is not generic") \ |
| 159 | T(NotIterable, "% is not iterable") \ |
| 160 | T(NotPropertyName, "% is not a valid property name") \ |
| 161 | T(NotTypedArray, "this is not a typed array.") \ |
| 162 | T(NotSharedTypedArray, "% is not a shared typed array.") \ |
| 163 | T(NotIntegerSharedTypedArray, "% is not an integer shared typed array.") \ |
| 164 | T(NotInt32SharedTypedArray, "% is not an int32 shared typed array.") \ |
| 165 | T(ObjectGetterExpectingFunction, \ |
| 166 | "Object.prototype.__defineGetter__: Expecting function") \ |
| 167 | T(ObjectGetterCallable, "Getter must be a function: %") \ |
| 168 | T(ObjectNotExtensible, "Can't add property %, object is not extensible") \ |
| 169 | T(ObjectSetterExpectingFunction, \ |
| 170 | "Object.prototype.__defineSetter__: Expecting function") \ |
| 171 | T(ObjectSetterCallable, "Setter must be a function: %") \ |
| 172 | T(ObserveCallbackFrozen, \ |
| 173 | "Object.observe cannot deliver to a frozen function object") \ |
| 174 | T(ObserveGlobalProxy, "% cannot be called on the global proxy object") \ |
| 175 | T(ObserveAccessChecked, "% cannot be called on access-checked objects") \ |
| 176 | T(ObserveInvalidAccept, \ |
| 177 | "Third argument to Object.observe must be an array of strings.") \ |
| 178 | T(ObserveNonFunction, "Object.% cannot deliver to non-function") \ |
| 179 | T(ObserveNonObject, "Object.% cannot % non-object") \ |
| 180 | T(ObserveNotifyNonNotifier, "notify called on non-notifier object") \ |
| 181 | T(ObservePerformNonFunction, "Cannot perform non-function") \ |
| 182 | T(ObservePerformNonString, "Invalid non-string changeType") \ |
| 183 | T(ObserveTypeNonString, \ |
| 184 | "Invalid changeRecord with non-string 'type' property") \ |
| 185 | T(OrdinaryFunctionCalledAsConstructor, \ |
| 186 | "Function object that's not a constructor was created with new") \ |
| 187 | T(PromiseCyclic, "Chaining cycle detected for promise %") \ |
| 188 | T(PromiseExecutorAlreadyInvoked, \ |
| 189 | "Promise executor has already been invoked with non-undefined arguments") \ |
| 190 | T(PropertyDescObject, "Property description must be an object: %") \ |
| 191 | T(PropertyNotFunction, \ |
| 192 | "'%' returned for property '%' of object '%' is not a function") \ |
| 193 | T(ProtoObjectOrNull, "Object prototype may only be an Object or null: %") \ |
| 194 | T(PrototypeParentNotAnObject, \ |
| 195 | "Class extends value does not have valid prototype property %") \ |
| 196 | T(ProxyConstructNonObject, \ |
| 197 | "'construct' on proxy: trap returned non-object ('%')") \ |
| 198 | T(ProxyDefinePropertyNonConfigurable, \ |
| 199 | "'defineProperty' on proxy: trap returned truish for defining " \ |
| 200 | "non-configurable property '%' which is either non-existant or " \ |
| 201 | "configurable in the proxy target") \ |
| 202 | T(ProxyDefinePropertyNonExtensible, \ |
| 203 | "'defineProperty' on proxy: trap returned truish for adding property '%' " \ |
| 204 | " to the non-extensible proxy target") \ |
| 205 | T(ProxyDefinePropertyIncompatible, \ |
| 206 | "'defineProperty' on proxy: trap returned truish for adding property '%' " \ |
| 207 | " that is incompatible with the existing property in the proxy target") \ |
| 208 | T(ProxyDeletePropertyNonConfigurable, \ |
| 209 | "'deleteProperty' on proxy: trap returned truish for property '%' which " \ |
| 210 | "is non-configurable in the proxy target") \ |
| 211 | T(ProxyEnumerateNonObject, "'enumerate' on proxy: trap returned non-object") \ |
| 212 | T(ProxyEnumerateNonString, \ |
| 213 | "'enumerate' on proxy: trap result includes non-string") \ |
| 214 | T(ProxyGetNonConfigurableData, \ |
| 215 | "'get' on proxy: property '%' is a read-only and " \ |
| 216 | "non-configurable data property on the proxy target but the proxy " \ |
| 217 | "did not return its actual value (expected '%' but got '%')") \ |
| 218 | T(ProxyGetNonConfigurableAccessor, \ |
| 219 | "'get' on proxy: property '%' is a non-configurable accessor " \ |
| 220 | "property on the proxy target and does not have a getter function, but " \ |
| 221 | "the trap did not return 'undefined' (got '%')") \ |
| 222 | T(ProxyGetOwnPropertyDescriptorIncompatible, \ |
| 223 | "'getOwnPropertyDescriptor' on proxy: trap returned descriptor for " \ |
| 224 | "property '%' that is incompatible with the existing property in the " \ |
| 225 | "proxy target") \ |
| 226 | T(ProxyGetOwnPropertyDescriptorInvalid, \ |
| 227 | "'getOwnPropertyDescriptor' on proxy: trap returned neither object nor " \ |
| 228 | "undefined for property '%'") \ |
| 229 | T(ProxyGetOwnPropertyDescriptorNonConfigurable, \ |
| 230 | "'getOwnPropertyDescriptor' on proxy: trap reported non-configurability " \ |
| 231 | "for property '%' which is either non-existant or configurable in the " \ |
| 232 | "proxy target") \ |
| 233 | T(ProxyGetOwnPropertyDescriptorNonExtensible, \ |
| 234 | "'getOwnPropertyDescriptor' on proxy: trap returned undefined for " \ |
| 235 | "property '%' which exists in the non-extensible proxy target") \ |
| 236 | T(ProxyGetOwnPropertyDescriptorUndefined, \ |
| 237 | "'getOwnPropertyDescriptor' on proxy: trap returned undefined for " \ |
| 238 | "property '%' which is non-configurable in the proxy target") \ |
| 239 | T(ProxyGetPrototypeOfInvalid, \ |
| 240 | "'getPrototypeOf' on proxy: trap returned neither object nor null") \ |
| 241 | T(ProxyGetPrototypeOfNonExtensible, \ |
| 242 | "'getPrototypeOf' on proxy: proxy target is non-extensible but the " \ |
| 243 | "trap did not return its actual prototype") \ |
| 244 | T(ProxyHandlerOrTargetRevoked, \ |
| 245 | "Cannot create proxy with a revoked proxy as target or handler") \ |
| 246 | T(ProxyHasNonConfigurable, \ |
| 247 | "'has' on proxy: trap returned falsish for property '%' which exists in " \ |
| 248 | "the proxy target as non-configurable") \ |
| 249 | T(ProxyHasNonExtensible, \ |
| 250 | "'has' on proxy: trap returned falsish for property '%' but the proxy " \ |
| 251 | "target is not extensible") \ |
| 252 | T(ProxyIsExtensibleInconsistent, \ |
| 253 | "'isExtensible' on proxy: trap result does not reflect extensibility of " \ |
| 254 | "proxy target (which is '%')") \ |
| 255 | T(ProxyNonObject, \ |
| 256 | "Cannot create proxy with a non-object as target or handler") \ |
| 257 | T(ProxyOwnKeysMissing, \ |
| 258 | "'ownKeys' on proxy: trap result did not include '%'") \ |
| 259 | T(ProxyOwnKeysNonExtensible, \ |
| 260 | "'ownKeys' on proxy: trap returned extra keys but proxy target is " \ |
| 261 | "non-extensible") \ |
| 262 | T(ProxyPreventExtensionsExtensible, \ |
| 263 | "'preventExtensions' on proxy: trap returned truish but the proxy target " \ |
| 264 | "is extensible") \ |
| 265 | T(ProxyPrivate, "Cannot pass private property name to proxy trap") \ |
| 266 | T(ProxyRevoked, "Cannot perform '%' on a proxy that has been revoked") \ |
| 267 | T(ProxySetFrozenData, \ |
| 268 | "'set' on proxy: trap returned truish for property '%' which exists in " \ |
| 269 | "the proxy target as a non-configurable and non-writable data property " \ |
| 270 | "with a different value") \ |
| 271 | T(ProxySetFrozenAccessor, \ |
| 272 | "'set' on proxy: trap returned truish for property '%' which exists in " \ |
| 273 | "the proxy target as a non-configurable and non-writable accessor " \ |
| 274 | "property without a setter") \ |
| 275 | T(ProxySetPrototypeOfNonExtensible, \ |
| 276 | "'setPrototypeOf' on proxy: trap returned truish for setting a new " \ |
| 277 | "prototype on the non-extensible proxy target") \ |
| 278 | T(ProxyTrapReturnedFalsish, "'%' on proxy: trap returned falsish") \ |
| 279 | T(ProxyTrapReturnedFalsishFor, \ |
| 280 | "'%' on proxy: trap returned falsish for property '%'") \ |
| 281 | T(ReadGlobalReferenceThroughProxy, "Trying to access '%' through proxy") \ |
| 282 | T(RedefineDisallowed, "Cannot redefine property: %") \ |
| 283 | T(RedefineExternalArray, \ |
| 284 | "Cannot redefine a property of an object with external array elements") \ |
| 285 | T(ReduceNoInitial, "Reduce of empty array with no initial value") \ |
| 286 | T(RegExpFlags, \ |
| 287 | "Cannot supply flags when constructing one RegExp from another") \ |
| 288 | T(RegExpNonObject, "% getter called on non-object %") \ |
| 289 | T(RegExpNonRegExp, "% getter called on non-RegExp object") \ |
| 290 | T(ReinitializeIntl, "Trying to re-initialize % object.") \ |
| 291 | T(ResolvedOptionsCalledOnNonObject, \ |
| 292 | "resolvedOptions method called on a non-object or on a object that is " \ |
| 293 | "not Intl.%.") \ |
| 294 | T(ResolverNotAFunction, "Promise resolver % is not a function") \ |
| 295 | T(RestrictedFunctionProperties, \ |
| 296 | "'caller' and 'arguments' are restricted function properties and cannot " \ |
| 297 | "be accessed in this context.") \ |
| 298 | T(StaticPrototype, "Classes may not have static property named prototype") \ |
| 299 | T(StrictCannotAssign, "Cannot assign to read only '%' in strict mode") \ |
| 300 | T(StrictDeleteProperty, "Cannot delete property '%' of %") \ |
| 301 | T(StrictPoisonPill, \ |
| 302 | "'caller', 'callee', and 'arguments' properties may not be accessed on " \ |
| 303 | "strict mode functions or the arguments objects for calls to them") \ |
| 304 | T(StrictReadOnlyProperty, \ |
| 305 | "Cannot assign to read only property '%' of % '%'") \ |
| 306 | T(StrictCannotCreateProperty, "Cannot create property '%' on % '%'") \ |
| 307 | T(StrongArity, \ |
| 308 | "In strong mode, calling a function with too few arguments is deprecated") \ |
| 309 | T(StrongDeleteProperty, \ |
| 310 | "Deleting property '%' of strong object '%' is deprecated") \ |
| 311 | T(StrongExtendNull, "In strong mode, classes extending null are deprecated") \ |
| 312 | T(StrongImplicitConversion, \ |
| 313 | "In strong mode, implicit conversions are deprecated") \ |
| 314 | T(StrongRedefineDisallowed, \ |
| 315 | "On strong object %, redefining writable, non-configurable property '%' " \ |
| 316 | "to be non-writable is deprecated") \ |
| 317 | T(StrongSetProto, \ |
| 318 | "On strong object %, redefining the internal prototype is deprecated") \ |
| 319 | T(SymbolKeyFor, "% is not a symbol") \ |
| 320 | T(SymbolToNumber, "Cannot convert a Symbol value to a number") \ |
| 321 | T(SymbolToString, "Cannot convert a Symbol value to a string") \ |
| 322 | T(SimdToNumber, "Cannot convert a SIMD value to a number") \ |
| 323 | T(UndefinedOrNullToObject, "Cannot convert undefined or null to object") \ |
| 324 | T(ValueAndAccessor, \ |
| 325 | "Invalid property descriptor. Cannot both specify accessors and a value " \ |
| 326 | "or writable attribute, %") \ |
| 327 | T(VarRedeclaration, "Identifier '%' has already been declared") \ |
| 328 | T(WrongArgs, "%: Arguments list has wrong type") \ |
| 329 | /* ReferenceError */ \ |
| 330 | T(NonMethod, "'super' is referenced from non-method") \ |
| 331 | T(NotDefined, "% is not defined") \ |
| 332 | T(StrongSuperCallMissing, \ |
| 333 | "In strong mode, invoking the super constructor in a subclass is " \ |
| 334 | "required") \ |
| 335 | T(StrongUnboundGlobal, \ |
| 336 | "In strong mode, using an undeclared global variable '%' is not allowed") \ |
| 337 | T(UnsupportedSuper, "Unsupported reference to 'super'") \ |
| 338 | /* RangeError */ \ |
| 339 | T(DateRange, "Provided date is not in valid range.") \ |
| 340 | T(ExpectedTimezoneID, \ |
| 341 | "Expected Area/Location(/Location)* for time zone, got %") \ |
| 342 | T(ExpectedLocation, \ |
| 343 | "Expected letters optionally connected with underscores or hyphens for " \ |
| 344 | "a location, got %") \ |
| 345 | T(InvalidArrayBufferLength, "Invalid array buffer length") \ |
| 346 | T(ArrayBufferAllocationFailed, "Array buffer allocation failed") \ |
| 347 | T(InvalidArrayLength, "Invalid array length") \ |
| 348 | T(InvalidCodePoint, "Invalid code point %") \ |
| 349 | T(InvalidCountValue, "Invalid count value") \ |
| 350 | T(InvalidCurrencyCode, "Invalid currency code: %") \ |
| 351 | T(InvalidDataViewAccessorOffset, \ |
| 352 | "Offset is outside the bounds of the DataView") \ |
| 353 | T(InvalidDataViewLength, "Invalid data view length") \ |
| 354 | T(InvalidDataViewOffset, "Start offset is outside the bounds of the buffer") \ |
| 355 | T(InvalidHint, "Invalid hint: %") \ |
| 356 | T(InvalidLanguageTag, "Invalid language tag: %") \ |
| 357 | T(InvalidWeakMapKey, "Invalid value used as weak map key") \ |
| 358 | T(InvalidWeakSetValue, "Invalid value used in weak set") \ |
| 359 | T(InvalidStringLength, "Invalid string length") \ |
| 360 | T(InvalidTimeValue, "Invalid time value") \ |
| 361 | T(InvalidTypedArrayAlignment, "% of % should be a multiple of %") \ |
| 362 | T(InvalidTypedArrayLength, "Invalid typed array length") \ |
| 363 | T(InvalidTypedArrayOffset, "Start offset is too large:") \ |
| 364 | T(LetInLexicalBinding, "let is disallowed as a lexically bound name") \ |
| 365 | T(LocaleMatcher, "Illegal value for localeMatcher:%") \ |
| 366 | T(NormalizationForm, "The normalization form should be one of %.") \ |
| 367 | T(NumberFormatRange, "% argument must be between 0 and 20") \ |
| 368 | T(PropertyValueOutOfRange, "% value is out of range.") \ |
| 369 | T(StackOverflow, "Maximum call stack size exceeded") \ |
| 370 | T(ToPrecisionFormatRange, "toPrecision() argument must be between 1 and 21") \ |
| 371 | T(ToRadixFormatRange, "toString() radix argument must be between 2 and 36") \ |
| 372 | T(TypedArraySetNegativeOffset, "Start offset is negative") \ |
| 373 | T(TypedArraySetSourceTooLarge, "Source is too large") \ |
| 374 | T(UnsupportedTimeZone, "Unsupported time zone specified %") \ |
| 375 | T(ValueOutOfRange, "Value % out of range for % options property %") \ |
| 376 | /* SyntaxError */ \ |
| 377 | T(BadGetterArity, "Getter must not have any formal parameters.") \ |
| 378 | T(BadSetterArity, "Setter must have exactly one formal parameter.") \ |
| 379 | T(ConstructorIsAccessor, "Class constructor may not be an accessor") \ |
| 380 | T(ConstructorIsGenerator, "Class constructor may not be a generator") \ |
| 381 | T(DerivedConstructorReturn, \ |
| 382 | "Derived constructors may only return object or undefined") \ |
| 383 | T(DuplicateConstructor, "A class may only have one constructor") \ |
| 384 | T(DuplicateExport, "Duplicate export of '%'") \ |
| 385 | T(DuplicateProto, \ |
| 386 | "Duplicate __proto__ fields are not allowed in object literals") \ |
| 387 | T(ForInLoopInitializer, \ |
| 388 | "for-in loop variable declaration may not have an initializer.") \ |
| 389 | T(ForInOfLoopMultiBindings, \ |
| 390 | "Invalid left-hand side in % loop: Must have a single binding.") \ |
| 391 | T(ForOfLoopInitializer, \ |
| 392 | "for-of loop variable declaration may not have an initializer.") \ |
| 393 | T(IllegalAccess, "Illegal access") \ |
| 394 | T(IllegalBreak, "Illegal break statement") \ |
| 395 | T(IllegalContinue, "Illegal continue statement") \ |
| 396 | T(IllegalLanguageModeDirective, \ |
| 397 | "Illegal '%' directive in function with non-simple parameter list") \ |
| 398 | T(IllegalReturn, "Illegal return statement") \ |
| 399 | T(InvalidEscapedReservedWord, "Keyword must not contain escaped characters") \ |
| 400 | T(InvalidLhsInAssignment, "Invalid left-hand side in assignment") \ |
| 401 | T(InvalidCoverInitializedName, "Invalid shorthand property initializer") \ |
| 402 | T(InvalidDestructuringTarget, "Invalid destructuring assignment target") \ |
| 403 | T(InvalidLhsInFor, "Invalid left-hand side in for-loop") \ |
| 404 | T(InvalidLhsInPostfixOp, \ |
| 405 | "Invalid left-hand side expression in postfix operation") \ |
| 406 | T(InvalidLhsInPrefixOp, \ |
| 407 | "Invalid left-hand side expression in prefix operation") \ |
| 408 | T(InvalidRegExpFlags, "Invalid flags supplied to RegExp constructor '%'") \ |
| 409 | T(LabelRedeclaration, "Label '%' has already been declared") \ |
| 410 | T(MalformedArrowFunParamList, "Malformed arrow function parameter list") \ |
| 411 | T(MalformedRegExp, "Invalid regular expression: /%/: %") \ |
| 412 | T(MalformedRegExpFlags, "Invalid regular expression flags") \ |
| 413 | T(ModuleExportUndefined, "Export '%' is not defined in module") \ |
| 414 | T(MultipleDefaultsInSwitch, \ |
| 415 | "More than one default clause in switch statement") \ |
| 416 | T(NewlineAfterThrow, "Illegal newline after throw") \ |
| 417 | T(NoCatchOrFinally, "Missing catch or finally after try") \ |
| 418 | T(NotIsvar, "builtin %%IS_VAR: not a variable") \ |
| 419 | T(ParamAfterRest, "Rest parameter must be last formal parameter") \ |
| 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") \ |
| 428 | T(SingleFunctionLiteral, "Single function literal required") \ |
| 429 | T(SloppyLexical, \ |
| 430 | "Block-scoped declarations (let, const, function, class) not yet " \ |
| 431 | "supported outside strict mode") \ |
| 432 | T(SpeciesNotConstructor, \ |
| 433 | "object.constructor[Symbol.species] is not a constructor") \ |
| 434 | T(StrictDelete, "Delete of an unqualified identifier in strict mode.") \ |
| 435 | T(StrictEvalArguments, "Unexpected eval or arguments in strict mode") \ |
| 436 | T(StrictFunction, \ |
| 437 | "In strict mode code, functions can only be declared at top level or " \ |
| 438 | "immediately within another function.") \ |
| 439 | T(StrictOctalLiteral, "Octal literals are not allowed in strict mode.") \ |
| 440 | T(StrictWith, "Strict mode code may not include a with statement") \ |
| 441 | T(StrongArguments, \ |
| 442 | "In strong mode, 'arguments' is deprecated, use '...args' instead") \ |
| 443 | T(StrongConstructorDirective, \ |
| 444 | "\"use strong\" directive is disallowed in class constructor body") \ |
| 445 | T(StrongConstructorReturnMisplaced, \ |
| 446 | "In strong mode, returning from a constructor before its super " \ |
| 447 | "constructor invocation or all assignments to 'this' is deprecated") \ |
| 448 | T(StrongConstructorReturnValue, \ |
| 449 | "In strong mode, returning a value from a constructor is deprecated") \ |
| 450 | T(StrongConstructorSuper, \ |
| 451 | "In strong mode, 'super' can only be used to invoke the super " \ |
| 452 | "constructor, and cannot be nested inside another statement or " \ |
| 453 | "expression") \ |
| 454 | T(StrongConstructorThis, \ |
| 455 | "In strong mode, 'this' can only be used to initialize properties, and " \ |
| 456 | "cannot be nested inside another statement or expression") \ |
| 457 | T(StrongDelete, \ |
| 458 | "In strong mode, 'delete' is deprecated, use maps or sets instead") \ |
| 459 | T(StrongDirectEval, "In strong mode, direct calls to eval are deprecated") \ |
| 460 | T(StrongEllision, \ |
| 461 | "In strong mode, arrays with holes are deprecated, use maps instead") \ |
| 462 | T(StrongEmpty, \ |
| 463 | "In strong mode, empty sub-statements are deprecated, make them explicit " \ |
| 464 | "with '{}' instead") \ |
| 465 | T(StrongEqual, \ |
| 466 | "In strong mode, '==' and '!=' are deprecated, use '===' and '!==' " \ |
| 467 | "instead") \ |
| 468 | T(StrongForIn, \ |
| 469 | "In strong mode, 'for'-'in' loops are deprecated, use 'for'-'of' instead") \ |
| 470 | T(StrongPropertyAccess, \ |
| 471 | "In strong mode, accessing missing property '%' of % is deprecated") \ |
| 472 | T(StrongSuperCallDuplicate, \ |
| 473 | "In strong mode, invoking the super constructor multiple times is " \ |
| 474 | "deprecated") \ |
| 475 | T(StrongSuperCallMisplaced, \ |
| 476 | "In strong mode, the super constructor must be invoked before any " \ |
| 477 | "assignment to 'this'") \ |
| 478 | T(StrongSwitchFallthrough, \ |
| 479 | "In strong mode, switch fall-through is deprecated, terminate each case " \ |
| 480 | "with 'break', 'continue', 'return' or 'throw'") \ |
| 481 | T(StrongUndefined, \ |
| 482 | "In strong mode, binding or assigning to 'undefined' is deprecated") \ |
| 483 | T(StrongUseBeforeDeclaration, \ |
| 484 | "In strong mode, declaring variable '%' before its use is required") \ |
| 485 | T(StrongVar, \ |
| 486 | "In strong mode, 'var' is deprecated, use 'let' or 'const' instead") \ |
| 487 | T(TemplateOctalLiteral, \ |
| 488 | "Octal literals are not allowed in template strings.") \ |
| 489 | T(ThisFormalParameter, "'this' is not a valid formal parameter name") \ |
| 490 | T(TooManyArguments, \ |
| 491 | "Too many arguments in function call (only 65535 allowed)") \ |
| 492 | T(TooManyParameters, \ |
| 493 | "Too many parameters in function definition (only 65535 allowed)") \ |
| 494 | T(TooManyVariables, "Too many variables declared (only 4194303 allowed)") \ |
| 495 | T(TypedArrayTooShort, \ |
| 496 | "Derived TypedArray constructor created an array which was too small") \ |
| 497 | T(UnexpectedEOS, "Unexpected end of input") \ |
| 498 | T(UnexpectedReserved, "Unexpected reserved word") \ |
| 499 | T(UnexpectedStrictReserved, "Unexpected strict mode reserved word") \ |
| 500 | T(UnexpectedSuper, "'super' keyword unexpected here") \ |
| 501 | T(UnexpectedNewTarget, "new.target expression is not allowed here") \ |
| 502 | T(UnexpectedTemplateString, "Unexpected template string") \ |
| 503 | T(UnexpectedToken, "Unexpected token %") \ |
| 504 | T(UnexpectedTokenIdentifier, "Unexpected identifier") \ |
| 505 | T(UnexpectedTokenNumber, "Unexpected number") \ |
| 506 | T(UnexpectedTokenString, "Unexpected string") \ |
| 507 | T(UnexpectedTokenRegExp, "Unexpected regular expression") \ |
| 508 | T(UnknownLabel, "Undefined label '%'") \ |
| 509 | T(UnterminatedArgList, "missing ) after argument list") \ |
| 510 | T(UnterminatedRegExp, "Invalid regular expression: missing /") \ |
| 511 | T(UnterminatedTemplate, "Unterminated template literal") \ |
| 512 | T(UnterminatedTemplateExpr, "Missing } in template expression") \ |
| 513 | /* EvalError */ \ |
| 514 | T(CodeGenFromStrings, "%") \ |
| 515 | /* URIError */ \ |
| 516 | T(URIMalformed, "URI malformed") |
| 517 | |
| 518 | class MessageTemplate { |
| 519 | public: |
| 520 | enum Template { |
| 521 | #define TEMPLATE(NAME, STRING) k##NAME, |
| 522 | MESSAGE_TEMPLATES(TEMPLATE) |
| 523 | #undef TEMPLATE |
| 524 | kLastMessage |
| 525 | }; |
| 526 | |
| 527 | static const char* TemplateString(int template_index); |
| 528 | |
| 529 | static MaybeHandle<String> FormatMessage(int template_index, |
| 530 | Handle<String> arg0, |
| 531 | Handle<String> arg1, |
| 532 | Handle<String> arg2); |
| 533 | |
| 534 | static Handle<String> FormatMessage(Isolate* isolate, int template_index, |
| 535 | Handle<Object> arg); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 536 | }; |
| 537 | |
| 538 | |
| 539 | // A message handler is a convenience interface for accessing the list |
| 540 | // of message listeners registered in an environment |
| 541 | class MessageHandler { |
| 542 | public: |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 543 | // Returns a message object for the API to use. |
Steve Block | 1e0659c | 2011-05-24 12:43:12 +0100 | [diff] [blame] | 544 | static Handle<JSMessageObject> MakeMessageObject( |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 545 | Isolate* isolate, MessageTemplate::Template type, |
| 546 | MessageLocation* location, Handle<Object> argument, |
Steve Block | 1e0659c | 2011-05-24 12:43:12 +0100 | [diff] [blame] | 547 | Handle<JSArray> stack_frames); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 548 | |
| 549 | // Report a formatted message (needs JS allocation). |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 550 | static void ReportMessage(Isolate* isolate, MessageLocation* loc, |
| 551 | Handle<JSMessageObject> message); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 552 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 553 | static void DefaultMessageReport(Isolate* isolate, const MessageLocation* loc, |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 554 | Handle<Object> message_obj); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 555 | static Handle<String> GetMessage(Isolate* isolate, Handle<Object> data); |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 556 | static base::SmartArrayPointer<char> GetLocalizedMessage(Isolate* isolate, |
| 557 | Handle<Object> data); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 558 | }; |
| 559 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame^] | 560 | |
| 561 | } // namespace internal |
| 562 | } // namespace v8 |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 563 | |
| 564 | #endif // V8_MESSAGES_H_ |