LCOV - code coverage report
Current view: top level - js/src/vm - ErrorReporting.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 2 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 4 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
       2             :  * vim: set ts=8 sts=4 et sw=4 tw=99:
       3             :  * This Source Code Form is subject to the terms of the Mozilla Public
       4             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       5             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       6             : 
       7             : #ifndef vm_ErrorReporting_h
       8             : #define vm_ErrorReporting_h
       9             : 
      10             : #include "mozilla/Move.h"
      11             : 
      12             : #include <stdarg.h>
      13             : 
      14             : #include "jsapi.h" // for JSErrorNotes, JSErrorReport
      15             : 
      16             : #include "js/UniquePtr.h" // for UniquePtr
      17             : #include "js/Utility.h" // for UniqueTwoByteChars
      18             : 
      19             : struct JSContext;
      20             : 
      21             : namespace js {
      22             : 
      23             : /**
      24             :  * Metadata for a compilation error (or warning) at a particular offset, or at
      25             :  * no offset (i.e. with respect to a script overall).
      26             :  */
      27           0 : struct ErrorMetadata
      28             : {
      29             :     // The file/URL where the error occurred.
      30             :     const char* filename;
      31             : 
      32             :     // The line and column numbers where the error occurred.  If the error
      33             :     // is with respect to the entire script and not with respect to a
      34             :     // particular location, these will both be zero.
      35             :     uint32_t lineNumber;
      36             :     uint32_t columnNumber;
      37             : 
      38             :     // If the error occurs at a particular location, context surrounding the
      39             :     // location of the error: the line that contained the error, or a small
      40             :     // portion of it if the line is long.  (If the error occurs within a
      41             :     // regular expression, this context is based upon its pattern characters.)
      42             :     //
      43             :     // This information is provided on a best-effort basis: code populating
      44             :     // ErrorMetadata instances isn't obligated to supply this.
      45             :     JS::UniqueTwoByteChars lineOfContext;
      46             : 
      47             :     // If |lineOfContext| is provided, we show only a portion (a "window") of
      48             :     // the line around the erroneous token -- the first char in the token, plus
      49             :     // |lineOfContextRadius| chars before it and |lineOfContextRadius - 1|
      50             :     // chars after it.  This is because for a very long line, the full line is
      51             :     // (a) not that helpful, and (b) wastes a lot of memory.  See bug 634444.
      52             :     static constexpr size_t lineOfContextRadius = 60;
      53             : 
      54             :     // If |lineOfContext| is non-null, its length.
      55             :     size_t lineLength;
      56             : 
      57             :     // If |lineOfContext| is non-null, the offset within it of the token that
      58             :     // triggered the error.
      59             :     size_t tokenOffset;
      60             : 
      61             :     // Whether the error is "muted" because it derives from a cross-origin
      62             :     // load.  See the comment in TransitiveCompileOptions in jsapi.h for
      63             :     // details.
      64             :     bool isMuted;
      65             : };
      66             : 
      67           0 : class CompileError : public JSErrorReport
      68             : {
      69             :   public:
      70             :     void throwError(JSContext* cx);
      71             : };
      72             : 
      73             : /** Send a JSErrorReport to the warningReporter callback. */
      74             : extern void
      75             : CallWarningReporter(JSContext* cx, JSErrorReport* report);
      76             : 
      77             : /**
      78             :  * Report a compile error during script processing prior to execution of the
      79             :  * script.
      80             :  */
      81             : extern void
      82             : ReportCompileError(JSContext* cx, ErrorMetadata&& metadata, UniquePtr<JSErrorNotes> notes,
      83             :                    unsigned flags, unsigned errorNumber, va_list args);
      84             : 
      85             : /**
      86             :  * Report a compile warning during script processing prior to execution of the
      87             :  * script.  Returns true if the warning was successfully reported, false if an
      88             :  * error occurred.
      89             :  *
      90             :  * This function DOES NOT respect an existing werror option.  If the caller
      91             :  * wishes such option to be respected, it must do so itself.
      92             :  */
      93             : extern MOZ_MUST_USE bool
      94             : ReportCompileWarning(JSContext* cx, ErrorMetadata&& metadata, UniquePtr<JSErrorNotes> notes,
      95             :                      unsigned flags, unsigned errorNumber, va_list args);
      96             : 
      97             : /**
      98             :  * Report the given error Value to the given global.  The JSContext is not
      99             :  * assumed to be in any particular compartment, but the global and error are
     100             :  * expected to be same-compartment.
     101             :  */
     102             : extern void
     103             : ReportErrorToGlobal(JSContext* cx, JS::HandleObject global, JS::HandleValue error);
     104             : 
     105             : } // namespace js
     106             : 
     107             : #endif /* vm_ErrorReporting_h */

Generated by: LCOV version 1.13