LCOV - code coverage report
Current view: top level - src - messages.h (source / functions) Hit Total Coverage
Test: app.info Lines: 12 19 63.2 %
Date: 2017-10-20 Functions: 7 21 33.3 %

          Line data    Source code
       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
       3             : // found in the LICENSE file.
       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             : 
      13             : #include <memory>
      14             : 
      15             : #include "src/handles.h"
      16             : 
      17             : namespace v8 {
      18             : namespace internal {
      19             : 
      20             : // Forward declarations.
      21             : class AbstractCode;
      22             : class FrameArray;
      23             : class JSMessageObject;
      24             : class LookupIterator;
      25             : class SharedFunctionInfo;
      26             : class SourceInfo;
      27             : class WasmInstanceObject;
      28             : 
      29             : class MessageLocation {
      30             :  public:
      31             :   MessageLocation(Handle<Script> script, int start_pos, int end_pos);
      32             :   MessageLocation(Handle<Script> script, int start_pos, int end_pos,
      33             :                   Handle<SharedFunctionInfo> shared);
      34             :   MessageLocation();
      35             : 
      36             :   Handle<Script> script() const { return script_; }
      37             :   int start_pos() const { return start_pos_; }
      38             :   int end_pos() const { return end_pos_; }
      39             :   Handle<SharedFunctionInfo> shared() const { return shared_; }
      40             : 
      41             :  private:
      42             :   Handle<Script> script_;
      43             :   int start_pos_;
      44             :   int end_pos_;
      45             :   Handle<SharedFunctionInfo> shared_;
      46             : };
      47             : 
      48             : class StackFrameBase {
      49             :  public:
      50     1072005 :   virtual ~StackFrameBase() {}
      51             : 
      52             :   virtual Handle<Object> GetReceiver() const = 0;
      53             :   virtual Handle<Object> GetFunction() const = 0;
      54             : 
      55             :   virtual Handle<Object> GetFileName() = 0;
      56             :   virtual Handle<Object> GetFunctionName() = 0;
      57             :   virtual Handle<Object> GetScriptNameOrSourceUrl() = 0;
      58             :   virtual Handle<Object> GetMethodName() = 0;
      59             :   virtual Handle<Object> GetTypeName() = 0;
      60             :   virtual Handle<Object> GetEvalOrigin();
      61             : 
      62             :   virtual int GetPosition() const = 0;
      63             :   // Return 1-based line number, including line offset.
      64             :   virtual int GetLineNumber() = 0;
      65             :   // Return 1-based column number, including column offset if first line.
      66             :   virtual int GetColumnNumber() = 0;
      67             : 
      68             :   virtual bool IsNative() = 0;
      69             :   virtual bool IsToplevel() = 0;
      70             :   virtual bool IsEval();
      71             :   virtual bool IsConstructor() = 0;
      72             :   virtual bool IsStrict() const = 0;
      73             : 
      74             :   virtual MaybeHandle<String> ToString() = 0;
      75             : 
      76             :  protected:
      77     1072005 :   StackFrameBase() {}
      78           0 :   explicit StackFrameBase(Isolate* isolate) : isolate_(isolate) {}
      79             :   Isolate* isolate_;
      80             : 
      81             :  private:
      82             :   virtual bool HasScript() const = 0;
      83             :   virtual Handle<Script> GetScript() const = 0;
      84             : };
      85             : 
      86             : class JSStackFrame : public StackFrameBase {
      87             :  public:
      88             :   JSStackFrame(Isolate* isolate, Handle<Object> receiver,
      89             :                Handle<JSFunction> function, Handle<AbstractCode> code,
      90             :                int offset);
      91      357335 :   virtual ~JSStackFrame() {}
      92             : 
      93         230 :   Handle<Object> GetReceiver() const override { return receiver_; }
      94             :   Handle<Object> GetFunction() const override;
      95             : 
      96             :   Handle<Object> GetFileName() override;
      97             :   Handle<Object> GetFunctionName() override;
      98             :   Handle<Object> GetScriptNameOrSourceUrl() override;
      99             :   Handle<Object> GetMethodName() override;
     100             :   Handle<Object> GetTypeName() override;
     101             : 
     102             :   int GetPosition() const override;
     103             :   int GetLineNumber() override;
     104             :   int GetColumnNumber() override;
     105             : 
     106             :   bool IsNative() override;
     107             :   bool IsToplevel() override;
     108       92717 :   bool IsConstructor() override { return is_constructor_; }
     109         770 :   bool IsStrict() const override { return is_strict_; }
     110             : 
     111             :   MaybeHandle<String> ToString() override;
     112             : 
     113             :  private:
     114             :   JSStackFrame();
     115             :   void FromFrameArray(Isolate* isolate, Handle<FrameArray> array, int frame_ix);
     116             : 
     117             :   bool HasScript() const override;
     118             :   Handle<Script> GetScript() const override;
     119             : 
     120             :   Handle<Object> receiver_;
     121             :   Handle<JSFunction> function_;
     122             :   Handle<AbstractCode> code_;
     123             :   int offset_;
     124             : 
     125             :   bool is_constructor_;
     126             :   bool is_strict_;
     127             : 
     128             :   friend class FrameArrayIterator;
     129             : };
     130             : 
     131             : class WasmStackFrame : public StackFrameBase {
     132             :  public:
     133      714670 :   virtual ~WasmStackFrame() {}
     134             : 
     135             :   Handle<Object> GetReceiver() const override;
     136             :   Handle<Object> GetFunction() const override;
     137             : 
     138         180 :   Handle<Object> GetFileName() override { return Null(); }
     139             :   Handle<Object> GetFunctionName() override;
     140           0 :   Handle<Object> GetScriptNameOrSourceUrl() override { return Null(); }
     141           0 :   Handle<Object> GetMethodName() override { return Null(); }
     142           0 :   Handle<Object> GetTypeName() override { return Null(); }
     143             : 
     144             :   int GetPosition() const override;
     145         250 :   int GetLineNumber() override { return wasm_func_index_; }
     146           0 :   int GetColumnNumber() override { return -1; }
     147             : 
     148         110 :   bool IsNative() override { return false; }
     149           0 :   bool IsToplevel() override { return false; }
     150           0 :   bool IsConstructor() override { return false; }
     151         260 :   bool IsStrict() const override { return false; }
     152             :   bool IsInterpreted() const { return code_.is_null(); }
     153             : 
     154             :   MaybeHandle<String> ToString() override;
     155             : 
     156             :  protected:
     157             :   Handle<Object> Null() const;
     158             : 
     159             :   bool HasScript() const override;
     160             :   Handle<Script> GetScript() const override;
     161             : 
     162             :   Handle<WasmInstanceObject> wasm_instance_;
     163             :   uint32_t wasm_func_index_;
     164             :   Handle<AbstractCode> code_;  // null handle for interpreted frames.
     165             :   int offset_;
     166             : 
     167             :  private:
     168             :   WasmStackFrame();
     169             :   void FromFrameArray(Isolate* isolate, Handle<FrameArray> array, int frame_ix);
     170             : 
     171             :   friend class FrameArrayIterator;
     172             :   friend class AsmJsWasmStackFrame;
     173             : };
     174             : 
     175             : class AsmJsWasmStackFrame : public WasmStackFrame {
     176             :  public:
     177      357335 :   virtual ~AsmJsWasmStackFrame() {}
     178             : 
     179             :   Handle<Object> GetReceiver() const override;
     180             :   Handle<Object> GetFunction() const override;
     181             : 
     182             :   Handle<Object> GetFileName() override;
     183             :   Handle<Object> GetScriptNameOrSourceUrl() override;
     184             : 
     185             :   int GetPosition() const override;
     186             :   int GetLineNumber() override;
     187             :   int GetColumnNumber() override;
     188             : 
     189             :   MaybeHandle<String> ToString() override;
     190             : 
     191             :  private:
     192             :   friend class FrameArrayIterator;
     193             :   AsmJsWasmStackFrame();
     194             :   void FromFrameArray(Isolate* isolate, Handle<FrameArray> array, int frame_ix);
     195             : 
     196             :   bool is_at_number_conversion_;
     197             : };
     198             : 
     199             : class FrameArrayIterator {
     200             :  public:
     201             :   FrameArrayIterator(Isolate* isolate, Handle<FrameArray> array,
     202             :                      int frame_ix = 0);
     203             : 
     204             :   StackFrameBase* Frame();
     205             : 
     206             :   bool HasNext() const;
     207             :   void Next();
     208             : 
     209             :  private:
     210             :   Isolate* isolate_;
     211             : 
     212             :   Handle<FrameArray> array_;
     213             :   int next_frame_ix_;
     214             : 
     215             :   WasmStackFrame wasm_frame_;
     216             :   AsmJsWasmStackFrame asm_wasm_frame_;
     217             :   JSStackFrame js_frame_;
     218             : };
     219             : 
     220             : // Determines how stack trace collection skips frames.
     221             : enum FrameSkipMode {
     222             :   // Unconditionally skips the first frame. Used e.g. when the Error constructor
     223             :   // is called, in which case the first frame is always a BUILTIN_EXIT frame.
     224             :   SKIP_FIRST,
     225             :   // Skip all frames until a specified caller function is seen.
     226             :   SKIP_UNTIL_SEEN,
     227             :   SKIP_NONE,
     228             : };
     229             : 
     230             : class ErrorUtils : public AllStatic {
     231             :  public:
     232             :   static MaybeHandle<Object> Construct(
     233             :       Isolate* isolate, Handle<JSFunction> target, Handle<Object> new_target,
     234             :       Handle<Object> message, FrameSkipMode mode, Handle<Object> caller,
     235             :       bool suppress_detailed_trace);
     236             : 
     237             :   static MaybeHandle<String> ToString(Isolate* isolate, Handle<Object> recv);
     238             : 
     239             :   static MaybeHandle<Object> MakeGenericError(
     240             :       Isolate* isolate, Handle<JSFunction> constructor, int template_index,
     241             :       Handle<Object> arg0, Handle<Object> arg1, Handle<Object> arg2,
     242             :       FrameSkipMode mode);
     243             : 
     244             :   // Formats a textual stack trace from the given structured stack trace.
     245             :   // Note that this can call arbitrary JS code through Error.prepareStackTrace.
     246             :   static MaybeHandle<Object> FormatStackTrace(Isolate* isolate,
     247             :                                               Handle<JSObject> error,
     248             :                                               Handle<Object> stack_trace);
     249             : };
     250             : 
     251             : #define MESSAGE_TEMPLATES(T)                                                   \
     252             :   /* Error */                                                                  \
     253             :   T(None, "")                                                                  \
     254             :   T(CyclicProto, "Cyclic __proto__ value")                                     \
     255             :   T(Debugger, "Debugger: %")                                                   \
     256             :   T(DebuggerLoading, "Error loading debugger")                                 \
     257             :   T(DefaultOptionsMissing, "Internal % error. Default options are missing.")   \
     258             :   T(UncaughtException, "Uncaught %")                                           \
     259             :   T(Unsupported, "Not supported")                                              \
     260             :   T(WrongServiceType, "Internal error, wrong service type: %")                 \
     261             :   T(WrongValueType, "Internal error. Wrong value type.")                       \
     262             :   /* TypeError */                                                              \
     263             :   T(ApplyNonFunction,                                                          \
     264             :     "Function.prototype.apply was called on %, which is a % and not a "        \
     265             :     "function")                                                                \
     266             :   T(ArrayBufferTooShort,                                                       \
     267             :     "Derived ArrayBuffer constructor created a buffer which was too small")    \
     268             :   T(ArrayBufferSpeciesThis,                                                    \
     269             :     "ArrayBuffer subclass returned this from species constructor")             \
     270             :   T(ArrayFunctionsOnFrozen, "Cannot modify frozen array elements")             \
     271             :   T(ArrayFunctionsOnSealed, "Cannot add/remove sealed array elements")         \
     272             :   T(AwaitNotInAsyncFunction, "await is only valid in async function")          \
     273             :   T(AtomicsWaitNotAllowed, "Atomics.wait cannot be called in this context")    \
     274             :   T(BadSortComparisonFunction,                                                 \
     275             :     "The comparison function must be either a function or undefined")          \
     276             :   T(BigIntMixedTypes,                                                          \
     277             :     "Cannot mix BigInt and other types, use explicit conversions")             \
     278             :   T(BigIntShr, "BigInts have no unsigned right shift, use >> instead")         \
     279             :   T(BigIntToNumber, "Cannot convert a BigInt value to a number")               \
     280             :   T(CalledNonCallable, "% is not a function")                                  \
     281             :   T(CalledOnNonObject, "% called on non-object")                               \
     282             :   T(CalledOnNullOrUndefined, "% called on null or undefined")                  \
     283             :   T(CallSiteExpectsFunction,                                                   \
     284             :     "CallSite expects wasm object as first or function as second argument, "   \
     285             :     "got <%, %>")                                                              \
     286             :   T(CallSiteMethod, "CallSite method % expects CallSite as receiver")          \
     287             :   T(CannotConvertToPrimitive, "Cannot convert object to primitive value")      \
     288             :   T(CannotPreventExt, "Cannot prevent extensions")                             \
     289             :   T(CannotFreeze, "Cannot freeze")                                             \
     290             :   T(CannotFreezeArrayBufferView,                                               \
     291             :     "Cannot freeze array buffer views with elements")                          \
     292             :   T(CannotSeal, "Cannot seal")                                                 \
     293             :   T(CircularStructure, "Converting circular structure to JSON")                \
     294             :   T(ConstructAbstractClass, "Abstract class % not directly constructable")     \
     295             :   T(ConstAssign, "Assignment to constant variable.")                           \
     296             :   T(ConstructorNonCallable,                                                    \
     297             :     "Class constructor % cannot be invoked without 'new'")                     \
     298             :   T(ConstructorNotFunction, "Constructor % requires 'new'")                    \
     299             :   T(ConstructorNotReceiver, "The .constructor property is not an object")      \
     300             :   T(CurrencyCode, "Currency code is required with currency style.")            \
     301             :   T(CyclicModuleDependency, "Detected cycle while resolving name '%'")         \
     302             :   T(DataViewNotArrayBuffer,                                                    \
     303             :     "First argument to DataView constructor must be an ArrayBuffer")           \
     304             :   T(DateType, "this is not a Date object.")                                    \
     305             :   T(DebuggerFrame, "Debugger: Invalid frame index.")                           \
     306             :   T(DebuggerType, "Debugger: Parameters have wrong types.")                    \
     307             :   T(DeclarationMissingInitializer, "Missing initializer in % declaration")     \
     308             :   T(DefineDisallowed, "Cannot define property %, object is not extensible")    \
     309             :   T(DetachedOperation, "Cannot perform % on a detached ArrayBuffer")           \
     310             :   T(DuplicateTemplateProperty, "Object template has duplicate property '%'")   \
     311             :   T(ExtendsValueNotConstructor,                                                \
     312             :     "Class extends value % is not a constructor or null")                      \
     313             :   T(FirstArgumentNotRegExp,                                                    \
     314             :     "First argument to % must not be a regular expression")                    \
     315             :   T(FunctionBind, "Bind must be called on a function")                         \
     316             :   T(GeneratorRunning, "Generator is already running")                          \
     317             :   T(IllegalInvocation, "Illegal invocation")                                   \
     318             :   T(ImmutablePrototypeSet,                                                     \
     319             :     "Immutable prototype object '%' cannot have their prototype set")          \
     320             :   T(ImportCallNotNewExpression, "Cannot use new with import")                  \
     321             :   T(ImportMetaOutsideModule, "Cannot use 'import.meta' outside a module")      \
     322             :   T(IncompatibleMethodReceiver, "Method % called on incompatible receiver %")  \
     323             :   T(InstanceofNonobjectProto,                                                  \
     324             :     "Function has non-object prototype '%' in instanceof check")               \
     325             :   T(InvalidArgument, "invalid_argument")                                       \
     326             :   T(InvalidInOperatorUse, "Cannot use 'in' operator to search for '%' in %")   \
     327             :   T(InvalidRegExpExecResult,                                                   \
     328             :     "RegExp exec method returned something other than an Object or null")      \
     329             :   T(IteratorResultNotAnObject, "Iterator result % is not an object")           \
     330             :   T(IteratorValueNotAnObject, "Iterator value % is not an entry object")       \
     331             :   T(LanguageID, "Language ID should be string or object.")                     \
     332             :   T(MethodCalledOnWrongObject,                                                 \
     333             :     "Method % called on a non-object or on a wrong type of object.")           \
     334             :   T(MethodInvokedOnNullOrUndefined,                                            \
     335             :     "Method invoked on undefined or null value.")                              \
     336             :   T(MethodInvokedOnWrongType, "Method invoked on an object that is not %.")    \
     337             :   T(NoAccess, "no access")                                                     \
     338             :   T(NonCallableInInstanceOfCheck,                                              \
     339             :     "Right-hand side of 'instanceof' is not callable")                         \
     340             :   T(NonCoercible, "Cannot destructure 'undefined' or 'null'.")                 \
     341             :   T(NonCoercibleWithProperty,                                                  \
     342             :     "Cannot destructure property `%` of 'undefined' or 'null'.")               \
     343             :   T(NonExtensibleProto, "% is not extensible")                                 \
     344             :   T(NonObjectInInstanceOfCheck,                                                \
     345             :     "Right-hand side of 'instanceof' is not an object")                        \
     346             :   T(NonObjectPropertyLoad, "Cannot read property '%' of %")                    \
     347             :   T(NonObjectPropertyStore, "Cannot set property '%' of %")                    \
     348             :   T(NoSetterInCallback, "Cannot set property % of % which has only a getter")  \
     349             :   T(NotAnIterator, "% is not an iterator")                                     \
     350             :   T(NotAPromise, "% is not a promise")                                         \
     351             :   T(NotConstructor, "% is not a constructor")                                  \
     352             :   T(NotDateObject, "this is not a Date object.")                               \
     353             :   T(NotGeneric, "% requires that 'this' be a %")                               \
     354             :   T(NotCallableOrIterable,                                                     \
     355             :     "% is not a function or its return value is not iterable")                 \
     356             :   T(NotCallableOrAsyncIterable,                                                \
     357             :     "% is not a function or its return value is not async iterable")           \
     358             :   T(NotIterable, "% is not iterable")                                          \
     359             :   T(NotAsyncIterable, "% is not async iterable")                               \
     360             :   T(NotPropertyName, "% is not a valid property name")                         \
     361             :   T(NotTypedArray, "this is not a typed array.")                               \
     362             :   T(NotSuperConstructor, "Super constructor % of % is not a constructor")      \
     363             :   T(NotSuperConstructorAnonymousClass,                                         \
     364             :     "Super constructor % of anonymous class is not a constructor")             \
     365             :   T(NotIntegerSharedTypedArray, "% is not an integer shared typed array.")     \
     366             :   T(NotInt32SharedTypedArray, "% is not an int32 shared typed array.")         \
     367             :   T(ObjectGetterExpectingFunction,                                             \
     368             :     "Object.prototype.__defineGetter__: Expecting function")                   \
     369             :   T(ObjectGetterCallable, "Getter must be a function: %")                      \
     370             :   T(ObjectNotExtensible, "Cannot add property %, object is not extensible")    \
     371             :   T(ObjectSetterExpectingFunction,                                             \
     372             :     "Object.prototype.__defineSetter__: Expecting function")                   \
     373             :   T(ObjectSetterCallable, "Setter must be a function: %")                      \
     374             :   T(OrdinaryFunctionCalledAsConstructor,                                       \
     375             :     "Function object that's not a constructor was created with new")           \
     376             :   T(PromiseCyclic, "Chaining cycle detected for promise %")                    \
     377             :   T(PromiseExecutorAlreadyInvoked,                                             \
     378             :     "Promise executor has already been invoked with non-undefined arguments")  \
     379             :   T(PromiseNonCallable, "Promise resolve or reject function is not callable")  \
     380             :   T(PropertyDescObject, "Property description must be an object: %")           \
     381             :   T(PropertyNotFunction,                                                       \
     382             :     "'%' returned for property '%' of object '%' is not a function")           \
     383             :   T(ProtoObjectOrNull, "Object prototype may only be an Object or null: %")    \
     384             :   T(PrototypeParentNotAnObject,                                                \
     385             :     "Class extends value does not have valid prototype property %")            \
     386             :   T(ProxyConstructNonObject,                                                   \
     387             :     "'construct' on proxy: trap returned non-object ('%')")                    \
     388             :   T(ProxyDefinePropertyNonConfigurable,                                        \
     389             :     "'defineProperty' on proxy: trap returned truish for defining "            \
     390             :     "non-configurable property '%' which is either non-existant or "           \
     391             :     "configurable in the proxy target")                                        \
     392             :   T(ProxyDefinePropertyNonExtensible,                                          \
     393             :     "'defineProperty' on proxy: trap returned truish for adding property '%' " \
     394             :     " to the non-extensible proxy target")                                     \
     395             :   T(ProxyDefinePropertyIncompatible,                                           \
     396             :     "'defineProperty' on proxy: trap returned truish for adding property '%' " \
     397             :     " that is incompatible with the existing property in the proxy target")    \
     398             :   T(ProxyDeletePropertyNonConfigurable,                                        \
     399             :     "'deleteProperty' on proxy: trap returned truish for property '%' which "  \
     400             :     "is non-configurable in the proxy target")                                 \
     401             :   T(ProxyGetNonConfigurableData,                                               \
     402             :     "'get' on proxy: property '%' is a read-only and "                         \
     403             :     "non-configurable data property on the proxy target but the proxy "        \
     404             :     "did not return its actual value (expected '%' but got '%')")              \
     405             :   T(ProxyGetNonConfigurableAccessor,                                           \
     406             :     "'get' on proxy: property '%' is a non-configurable accessor "             \
     407             :     "property on the proxy target and does not have a getter function, but "   \
     408             :     "the trap did not return 'undefined' (got '%')")                           \
     409             :   T(ProxyGetOwnPropertyDescriptorIncompatible,                                 \
     410             :     "'getOwnPropertyDescriptor' on proxy: trap returned descriptor for "       \
     411             :     "property '%' that is incompatible with the existing property in the "     \
     412             :     "proxy target")                                                            \
     413             :   T(ProxyGetOwnPropertyDescriptorInvalid,                                      \
     414             :     "'getOwnPropertyDescriptor' on proxy: trap returned neither object nor "   \
     415             :     "undefined for property '%'")                                              \
     416             :   T(ProxyGetOwnPropertyDescriptorNonConfigurable,                              \
     417             :     "'getOwnPropertyDescriptor' on proxy: trap reported non-configurability "  \
     418             :     "for property '%' which is either non-existant or configurable in the "    \
     419             :     "proxy target")                                                            \
     420             :   T(ProxyGetOwnPropertyDescriptorNonExtensible,                                \
     421             :     "'getOwnPropertyDescriptor' on proxy: trap returned undefined for "        \
     422             :     "property '%' which exists in the non-extensible proxy target")            \
     423             :   T(ProxyGetOwnPropertyDescriptorUndefined,                                    \
     424             :     "'getOwnPropertyDescriptor' on proxy: trap returned undefined for "        \
     425             :     "property '%' which is non-configurable in the proxy target")              \
     426             :   T(ProxyGetPrototypeOfInvalid,                                                \
     427             :     "'getPrototypeOf' on proxy: trap returned neither object nor null")        \
     428             :   T(ProxyGetPrototypeOfNonExtensible,                                          \
     429             :     "'getPrototypeOf' on proxy: proxy target is non-extensible but the "       \
     430             :     "trap did not return its actual prototype")                                \
     431             :   T(ProxyHandlerOrTargetRevoked,                                               \
     432             :     "Cannot create proxy with a revoked proxy as target or handler")           \
     433             :   T(ProxyHasNonConfigurable,                                                   \
     434             :     "'has' on proxy: trap returned falsish for property '%' which exists in "  \
     435             :     "the proxy target as non-configurable")                                    \
     436             :   T(ProxyHasNonExtensible,                                                     \
     437             :     "'has' on proxy: trap returned falsish for property '%' but the proxy "    \
     438             :     "target is not extensible")                                                \
     439             :   T(ProxyIsExtensibleInconsistent,                                             \
     440             :     "'isExtensible' on proxy: trap result does not reflect extensibility of "  \
     441             :     "proxy target (which is '%')")                                             \
     442             :   T(ProxyNonObject,                                                            \
     443             :     "Cannot create proxy with a non-object as target or handler")              \
     444             :   T(ProxyOwnKeysMissing,                                                       \
     445             :     "'ownKeys' on proxy: trap result did not include '%'")                     \
     446             :   T(ProxyOwnKeysNonExtensible,                                                 \
     447             :     "'ownKeys' on proxy: trap returned extra keys but proxy target is "        \
     448             :     "non-extensible")                                                          \
     449             :   T(ProxyPreventExtensionsExtensible,                                          \
     450             :     "'preventExtensions' on proxy: trap returned truish but the proxy target " \
     451             :     "is extensible")                                                           \
     452             :   T(ProxyPrivate, "Cannot pass private property name to proxy trap")           \
     453             :   T(ProxyRevoked, "Cannot perform '%' on a proxy that has been revoked")       \
     454             :   T(ProxySetFrozenData,                                                        \
     455             :     "'set' on proxy: trap returned truish for property '%' which exists in "   \
     456             :     "the proxy target as a non-configurable and non-writable data property "   \
     457             :     "with a different value")                                                  \
     458             :   T(ProxySetFrozenAccessor,                                                    \
     459             :     "'set' on proxy: trap returned truish for property '%' which exists in "   \
     460             :     "the proxy target as a non-configurable and non-writable accessor "        \
     461             :     "property without a setter")                                               \
     462             :   T(ProxySetPrototypeOfNonExtensible,                                          \
     463             :     "'setPrototypeOf' on proxy: trap returned truish for setting a new "       \
     464             :     "prototype on the non-extensible proxy target")                            \
     465             :   T(ProxyTrapReturnedFalsish, "'%' on proxy: trap returned falsish")           \
     466             :   T(ProxyTrapReturnedFalsishFor,                                               \
     467             :     "'%' on proxy: trap returned falsish for property '%'")                    \
     468             :   T(RedefineDisallowed, "Cannot redefine property: %")                         \
     469             :   T(RedefineExternalArray,                                                     \
     470             :     "Cannot redefine a property of an object with external array elements")    \
     471             :   T(ReduceNoInitial, "Reduce of empty array with no initial value")            \
     472             :   T(RegExpFlags,                                                               \
     473             :     "Cannot supply flags when constructing one RegExp from another")           \
     474             :   T(RegExpNonObject, "% getter called on non-object %")                        \
     475             :   T(RegExpNonRegExp, "% getter called on non-RegExp object")                   \
     476             :   T(ResolverNotAFunction, "Promise resolver % is not a function")              \
     477             :   T(ReturnMethodNotCallable, "The iterator's 'return' method is not callable") \
     478             :   T(SharedArrayBufferTooShort,                                                 \
     479             :     "Derived SharedArrayBuffer constructor created a buffer which was too "    \
     480             :     "small")                                                                   \
     481             :   T(SharedArrayBufferSpeciesThis,                                              \
     482             :     "SharedArrayBuffer subclass returned this from species constructor")       \
     483             :   T(StaticPrototype, "Classes may not have static property named prototype")   \
     484             :   T(StrictDeleteProperty, "Cannot delete property '%' of %")                   \
     485             :   T(StrictPoisonPill,                                                          \
     486             :     "'caller', 'callee', and 'arguments' properties may not be accessed on "   \
     487             :     "strict mode functions or the arguments objects for calls to them")        \
     488             :   T(StrictReadOnlyProperty,                                                    \
     489             :     "Cannot assign to read only property '%' of % '%'")                        \
     490             :   T(StrictCannotCreateProperty, "Cannot create property '%' on % '%'")         \
     491             :   T(SymbolIteratorInvalid,                                                     \
     492             :     "Result of the Symbol.iterator method is not an object")                   \
     493             :   T(SymbolAsyncIteratorInvalid,                                                \
     494             :     "Result of the Symbol.asyncIterator method is not an object")              \
     495             :   T(SymbolKeyFor, "% is not a symbol")                                         \
     496             :   T(SymbolToNumber, "Cannot convert a Symbol value to a number")               \
     497             :   T(SymbolToString, "Cannot convert a Symbol value to a string")               \
     498             :   T(ThrowMethodMissing, "The iterator does not provide a 'throw' method.")     \
     499             :   T(UndefinedOrNullToObject, "Cannot convert undefined or null to object")     \
     500             :   T(ValueAndAccessor,                                                          \
     501             :     "Invalid property descriptor. Cannot both specify accessors and a value "  \
     502             :     "or writable attribute, %")                                                \
     503             :   T(VarRedeclaration, "Identifier '%' has already been declared")              \
     504             :   T(WrongArgs, "%: Arguments list has wrong type")                             \
     505             :   /* ReferenceError */                                                         \
     506             :   T(NotDefined, "% is not defined")                                            \
     507             :   T(SuperAlreadyCalled, "Super constructor may only be called once")           \
     508             :   T(UnsupportedSuper, "Unsupported reference to 'super'")                      \
     509             :   /* RangeError */                                                             \
     510             :   T(BigIntDivZero, "Division by zero")                                         \
     511             :   T(BigIntTooBig, "Maximum BigInt size exceeded")                              \
     512             :   T(DateRange, "Provided date is not in valid range.")                         \
     513             :   T(ExpectedTimezoneID,                                                        \
     514             :     "Expected Area/Location(/Location)* for time zone, got %")                 \
     515             :   T(ExpectedLocation,                                                          \
     516             :     "Expected letters optionally connected with underscores or hyphens for "   \
     517             :     "a location, got %")                                                       \
     518             :   T(InvalidArrayBufferLength, "Invalid array buffer length")                   \
     519             :   T(ArrayBufferAllocationFailed, "Array buffer allocation failed")             \
     520             :   T(InvalidArrayLength, "Invalid array length")                                \
     521             :   T(InvalidAtomicAccessIndex, "Invalid atomic access index")                   \
     522             :   T(InvalidCodePoint, "Invalid code point %")                                  \
     523             :   T(InvalidCountValue, "Invalid count value")                                  \
     524             :   T(InvalidCurrencyCode, "Invalid currency code: %")                           \
     525             :   T(InvalidDataViewAccessorOffset,                                             \
     526             :     "Offset is outside the bounds of the DataView")                            \
     527             :   T(InvalidDataViewLength, "Invalid DataView length %")                        \
     528             :   T(InvalidOffset, "Start offset % is outside the bounds of the buffer")       \
     529             :   T(InvalidHint, "Invalid hint: %")                                            \
     530             :   T(InvalidLanguageTag, "Invalid language tag: %")                             \
     531             :   T(InvalidWeakMapKey, "Invalid value used as weak map key")                   \
     532             :   T(InvalidWeakSetValue, "Invalid value used in weak set")                     \
     533             :   T(InvalidStringLength, "Invalid string length")                              \
     534             :   T(InvalidTimeValue, "Invalid time value")                                    \
     535             :   T(InvalidTypedArrayAlignment, "% of % should be a multiple of %")            \
     536             :   T(InvalidTypedArrayIndex, "Invalid typed array index")                       \
     537             :   T(InvalidTypedArrayLength, "Invalid typed array length: %")                  \
     538             :   T(LetInLexicalBinding, "let is disallowed as a lexically bound name")        \
     539             :   T(LocaleMatcher, "Illegal value for localeMatcher:%")                        \
     540             :   T(NormalizationForm, "The normalization form should be one of %.")           \
     541             :   T(NumberFormatRange, "% argument must be between 0 and 100")                 \
     542             :   T(PropertyValueOutOfRange, "% value is out of range.")                       \
     543             :   T(StackOverflow, "Maximum call stack size exceeded")                         \
     544             :   T(ToPrecisionFormatRange,                                                    \
     545             :     "toPrecision() argument must be between 1 and 100")                        \
     546             :   T(ToRadixFormatRange, "toString() radix argument must be between 2 and 36")  \
     547             :   T(TypedArraySetNegativeOffset, "Start offset is negative")                   \
     548             :   T(TypedArraySetSourceTooLarge, "Source is too large")                        \
     549             :   T(UnsupportedTimeZone, "Unsupported time zone specified %")                  \
     550             :   T(ValueOutOfRange, "Value % out of range for % options property %")          \
     551             :   /* SyntaxError */                                                            \
     552             :   T(AmbiguousExport,                                                           \
     553             :     "The requested module contains conflicting star exports for name '%'")     \
     554             :   T(BadGetterArity, "Getter must not have any formal parameters.")             \
     555             :   T(BadSetterArity, "Setter must have exactly one formal parameter.")          \
     556             :   T(BigIntInvalidString, "Invalid BigInt string")                              \
     557             :   T(ConstructorIsAccessor, "Class constructor may not be an accessor")         \
     558             :   T(ConstructorIsGenerator, "Class constructor may not be a generator")        \
     559             :   T(ConstructorIsAsync, "Class constructor may not be an async method")        \
     560             :   T(ClassConstructorReturnedNonObject,                                         \
     561             :     "Class constructors may only return object or undefined")                  \
     562             :   T(DerivedConstructorReturnedNonObject,                                       \
     563             :     "Derived constructors may only return object or undefined")                \
     564             :   T(DuplicateConstructor, "A class may only have one constructor")             \
     565             :   T(DuplicateExport, "Duplicate export of '%'")                                \
     566             :   T(DuplicateProto,                                                            \
     567             :     "Duplicate __proto__ fields are not allowed in object literals")           \
     568             :   T(ForInOfLoopInitializer,                                                    \
     569             :     "% loop variable declaration may not have an initializer.")                \
     570             :   T(ForInOfLoopMultiBindings,                                                  \
     571             :     "Invalid left-hand side in % loop: Must have a single binding.")           \
     572             :   T(GeneratorInSingleStatementContext,                                         \
     573             :     "Generators can only be declared at the top level or inside a block.")     \
     574             :   T(AsyncFunctionInSingleStatementContext,                                     \
     575             :     "Async functions can only be declared at the top level or inside a "       \
     576             :     "block.")                                                                  \
     577             :   T(IllegalBreak, "Illegal break statement")                                   \
     578             :   T(NoIterationStatement,                                                      \
     579             :     "Illegal continue statement: no surrounding iteration statement")          \
     580             :   T(IllegalContinue,                                                           \
     581             :     "Illegal continue statement: '%' does not denote an iteration statement")  \
     582             :   T(IllegalLanguageModeDirective,                                              \
     583             :     "Illegal '%' directive in function with non-simple parameter list")        \
     584             :   T(IllegalReturn, "Illegal return statement")                                 \
     585             :   T(InvalidRestBindingPattern,                                                 \
     586             :     "`...` must be followed by an identifier in declaration contexts")         \
     587             :   T(InvalidRestAssignmentPattern,                                              \
     588             :     "`...` must be followed by an assignable reference in assignment "         \
     589             :     "contexts")                                                                \
     590             :   T(InvalidEscapedReservedWord, "Keyword must not contain escaped characters") \
     591             :   T(InvalidEscapedMetaProperty, "'%' must not contain escaped characters")     \
     592             :   T(InvalidLhsInAssignment, "Invalid left-hand side in assignment")            \
     593             :   T(InvalidCoverInitializedName, "Invalid shorthand property initializer")     \
     594             :   T(InvalidDestructuringTarget, "Invalid destructuring assignment target")     \
     595             :   T(InvalidLhsInFor, "Invalid left-hand side in for-loop")                     \
     596             :   T(InvalidLhsInPostfixOp,                                                     \
     597             :     "Invalid left-hand side expression in postfix operation")                  \
     598             :   T(InvalidLhsInPrefixOp,                                                      \
     599             :     "Invalid left-hand side expression in prefix operation")                   \
     600             :   T(InvalidRegExpFlags, "Invalid flags supplied to RegExp constructor '%'")    \
     601             :   T(InvalidOrUnexpectedToken, "Invalid or unexpected token")                   \
     602             :   T(JsonParseUnexpectedEOS, "Unexpected end of JSON input")                    \
     603             :   T(JsonParseUnexpectedToken, "Unexpected token % in JSON at position %")      \
     604             :   T(JsonParseUnexpectedTokenNumber, "Unexpected number in JSON at position %") \
     605             :   T(JsonParseUnexpectedTokenString, "Unexpected string in JSON at position %") \
     606             :   T(LabelRedeclaration, "Label '%' has already been declared")                 \
     607             :   T(LabelledFunctionDeclaration,                                               \
     608             :     "Labelled function declaration not allowed as the body of a control flow " \
     609             :     "structure")                                                               \
     610             :   T(MalformedArrowFunParamList, "Malformed arrow function parameter list")     \
     611             :   T(MalformedRegExp, "Invalid regular expression: /%/: %")                     \
     612             :   T(MalformedRegExpFlags, "Invalid regular expression flags")                  \
     613             :   T(ModuleExportUndefined, "Export '%' is not defined in module")              \
     614             :   T(HtmlCommentInModule, "HTML comments are not allowed in modules")           \
     615             :   T(MultipleDefaultsInSwitch,                                                  \
     616             :     "More than one default clause in switch statement")                        \
     617             :   T(NewlineAfterThrow, "Illegal newline after throw")                          \
     618             :   T(NoCatchOrFinally, "Missing catch or finally after try")                    \
     619             :   T(NotIsvar, "builtin %%IS_VAR: not a variable")                              \
     620             :   T(ParamAfterRest, "Rest parameter must be last formal parameter")            \
     621             :   T(PushPastSafeLength,                                                        \
     622             :     "Pushing % elements on an array-like of length % "                         \
     623             :     "is disallowed, as the total surpasses 2**53-1")                           \
     624             :   T(ElementAfterRest, "Rest element must be last element")                     \
     625             :   T(BadSetterRestParameter,                                                    \
     626             :     "Setter function argument must not be a rest parameter")                   \
     627             :   T(ParamDupe, "Duplicate parameter name not allowed in this context")         \
     628             :   T(ParenthesisInArgString, "Function arg string contains parenthesis")        \
     629             :   T(ArgStringTerminatesParametersEarly,                                        \
     630             :     "Arg string terminates parameters early")                                  \
     631             :   T(UnexpectedEndOfArgString, "Unexpected end of arg string")                  \
     632             :   T(RestDefaultInitializer,                                                    \
     633             :     "Rest parameter may not have a default initializer")                       \
     634             :   T(RuntimeWrongNumArgs, "Runtime function given wrong number of arguments")   \
     635             :   T(SuperNotCalled,                                                            \
     636             :     "Must call super constructor in derived class before accessing 'this' or " \
     637             :     "returning from derived constructor")                                      \
     638             :   T(SingleFunctionLiteral, "Single function literal required")                 \
     639             :   T(SloppyFunction,                                                            \
     640             :     "In non-strict mode code, functions can only be declared at top level, "   \
     641             :     "inside a block, or as the body of an if statement.")                      \
     642             :   T(SpeciesNotConstructor,                                                     \
     643             :     "object.constructor[Symbol.species] is not a constructor")                 \
     644             :   T(StrictDelete, "Delete of an unqualified identifier in strict mode.")       \
     645             :   T(StrictEvalArguments, "Unexpected eval or arguments in strict mode")        \
     646             :   T(StrictFunction,                                                            \
     647             :     "In strict mode code, functions can only be declared at top level or "     \
     648             :     "inside a block.")                                                         \
     649             :   T(StrictOctalLiteral, "Octal literals are not allowed in strict mode.")      \
     650             :   T(StrictDecimalWithLeadingZero,                                              \
     651             :     "Decimals with leading zeros are not allowed in strict mode.")             \
     652             :   T(StrictOctalEscape,                                                         \
     653             :     "Octal escape sequences are not allowed in strict mode.")                  \
     654             :   T(StrictWith, "Strict mode code may not include a with statement")           \
     655             :   T(TemplateOctalLiteral,                                                      \
     656             :     "Octal escape sequences are not allowed in template strings.")             \
     657             :   T(ThisFormalParameter, "'this' is not a valid formal parameter name")        \
     658             :   T(AwaitBindingIdentifier,                                                    \
     659             :     "'await' is not a valid identifier name in an async function")             \
     660             :   T(AwaitExpressionFormalParameter,                                            \
     661             :     "Illegal await-expression in formal parameters of async function")         \
     662             :   T(TooManyArguments,                                                          \
     663             :     "Too many arguments in function call (only 65535 allowed)")                \
     664             :   T(TooManyParameters,                                                         \
     665             :     "Too many parameters in function definition (only 65535 allowed)")         \
     666             :   T(TooManySpreads,                                                            \
     667             :     "Literal containing too many nested spreads (up to 65534 allowed)")        \
     668             :   T(TooManyVariables, "Too many variables declared (only 4194303 allowed)")    \
     669             :   T(TypedArrayTooShort,                                                        \
     670             :     "Derived TypedArray constructor created an array which was too small")     \
     671             :   T(UnexpectedEOS, "Unexpected end of input")                                  \
     672             :   T(UnexpectedFunctionSent,                                                    \
     673             :     "function.sent expression is not allowed outside a generator")             \
     674             :   T(UnexpectedReserved, "Unexpected reserved word")                            \
     675             :   T(UnexpectedStrictReserved, "Unexpected strict mode reserved word")          \
     676             :   T(UnexpectedSuper, "'super' keyword unexpected here")                        \
     677             :   T(UnexpectedNewTarget, "new.target expression is not allowed here")          \
     678             :   T(UnexpectedTemplateString, "Unexpected template string")                    \
     679             :   T(UnexpectedToken, "Unexpected token %")                                     \
     680             :   T(UnexpectedTokenIdentifier, "Unexpected identifier")                        \
     681             :   T(UnexpectedTokenNumber, "Unexpected number")                                \
     682             :   T(UnexpectedTokenString, "Unexpected string")                                \
     683             :   T(UnexpectedTokenRegExp, "Unexpected regular expression")                    \
     684             :   T(UnexpectedLexicalDeclaration,                                              \
     685             :     "Lexical declaration cannot appear in a single-statement context")         \
     686             :   T(UnknownLabel, "Undefined label '%'")                                       \
     687             :   T(UnresolvableExport,                                                        \
     688             :     "The requested module does not provide an export named '%'")               \
     689             :   T(UnterminatedArgList, "missing ) after argument list")                      \
     690             :   T(UnterminatedRegExp, "Invalid regular expression: missing /")               \
     691             :   T(UnterminatedTemplate, "Unterminated template literal")                     \
     692             :   T(UnterminatedTemplateExpr, "Missing } in template expression")              \
     693             :   T(FoundNonCallableHasInstance, "Found non-callable @@hasInstance")           \
     694             :   T(InvalidHexEscapeSequence, "Invalid hexadecimal escape sequence")           \
     695             :   T(InvalidUnicodeEscapeSequence, "Invalid Unicode escape sequence")           \
     696             :   T(UndefinedUnicodeCodePoint, "Undefined Unicode code-point")                 \
     697             :   T(YieldInParameter, "Yield expression not allowed in formal parameter")      \
     698             :   /* EvalError */                                                              \
     699             :   T(CodeGenFromStrings, "%")                                                   \
     700             :   T(NoSideEffectDebugEvaluate, "Possible side-effect in debug-evaluate")       \
     701             :   /* URIError */                                                               \
     702             :   T(URIMalformed, "URI malformed")                                             \
     703             :   /* Wasm errors (currently Error) */                                          \
     704             :   T(WasmTrapUnreachable, "unreachable")                                        \
     705             :   T(WasmTrapMemOutOfBounds, "memory access out of bounds")                     \
     706             :   T(WasmTrapDivByZero, "divide by zero")                                       \
     707             :   T(WasmTrapDivUnrepresentable, "divide result unrepresentable")               \
     708             :   T(WasmTrapRemByZero, "remainder by zero")                                    \
     709             :   T(WasmTrapFloatUnrepresentable, "integer result unrepresentable")            \
     710             :   T(WasmTrapFuncInvalid, "invalid function")                                   \
     711             :   T(WasmTrapFuncSigMismatch, "function signature mismatch")                    \
     712             :   T(WasmTrapInvalidIndex, "invalid index into function table")                 \
     713             :   T(WasmTrapTypeError, "invalid type")                                         \
     714             :   T(WasmExceptionError, "wasm exception")                                      \
     715             :   /* Asm.js validation related */                                              \
     716             :   T(AsmJsInvalid, "Invalid asm.js: %")                                         \
     717             :   T(AsmJsCompiled, "Converted asm.js to WebAssembly: %")                       \
     718             :   T(AsmJsInstantiated, "Instantiated asm.js: %")                               \
     719             :   T(AsmJsLinkingFailed, "Linking failure in asm.js: %")                        \
     720             :   /* DataCloneError messages */                                                \
     721             :   T(DataCloneError, "% could not be cloned.")                                  \
     722             :   T(DataCloneErrorOutOfMemory, "Data cannot be cloned, out of memory.")        \
     723             :   T(DataCloneErrorNeuteredArrayBuffer,                                         \
     724             :     "An ArrayBuffer is neutered and could not be cloned.")                     \
     725             :   T(DataCloneErrorSharedArrayBufferTransferred,                                \
     726             :     "A SharedArrayBuffer could not be cloned. SharedArrayBuffer must not be "  \
     727             :     "transferred.")                                                            \
     728             :   T(DataCloneDeserializationError, "Unable to deserialize cloned data.")       \
     729             :   T(DataCloneDeserializationVersionError,                                      \
     730             :     "Unable to deserialize cloned data due to invalid or unsupported "         \
     731             :     "version.")
     732             : 
     733             : class MessageTemplate {
     734             :  public:
     735             :   enum Template {
     736             : #define TEMPLATE(NAME, STRING) k##NAME,
     737             :     MESSAGE_TEMPLATES(TEMPLATE)
     738             : #undef TEMPLATE
     739             :         kLastMessage
     740             :   };
     741             : 
     742             :   static const char* TemplateString(int template_index);
     743             : 
     744             :   static MaybeHandle<String> FormatMessage(int template_index,
     745             :                                            Handle<String> arg0,
     746             :                                            Handle<String> arg1,
     747             :                                            Handle<String> arg2);
     748             : 
     749             :   static Handle<String> FormatMessage(Isolate* isolate, int template_index,
     750             :                                       Handle<Object> arg);
     751             : };
     752             : 
     753             : 
     754             : // A message handler is a convenience interface for accessing the list
     755             : // of message listeners registered in an environment
     756             : class MessageHandler {
     757             :  public:
     758             :   // Returns a message object for the API to use.
     759             :   static Handle<JSMessageObject> MakeMessageObject(
     760             :       Isolate* isolate, MessageTemplate::Template type,
     761             :       const MessageLocation* location, Handle<Object> argument,
     762             :       Handle<FixedArray> stack_frames);
     763             : 
     764             :   // Report a formatted message (needs JS allocation).
     765             :   static void ReportMessage(Isolate* isolate, const MessageLocation* loc,
     766             :                             Handle<JSMessageObject> message);
     767             : 
     768             :   static void DefaultMessageReport(Isolate* isolate, const MessageLocation* loc,
     769             :                                    Handle<Object> message_obj);
     770             :   static Handle<String> GetMessage(Isolate* isolate, Handle<Object> data);
     771             :   static std::unique_ptr<char[]> GetLocalizedMessage(Isolate* isolate,
     772             :                                                      Handle<Object> data);
     773             : 
     774             :  private:
     775             :   static void ReportMessageNoExceptions(Isolate* isolate,
     776             :                                         const MessageLocation* loc,
     777             :                                         Handle<Object> message_obj,
     778             :                                         v8::Local<v8::Value> api_exception_obj);
     779             : };
     780             : 
     781             : 
     782             : }  // namespace internal
     783             : }  // namespace v8
     784             : 
     785             : #endif  // V8_MESSAGES_H_

Generated by: LCOV version 1.10