LCOV - code coverage report
Current view: top level - src - pending-compilation-error-handler.h (source / functions) Hit Total Coverage
Test: app.info Lines: 19 19 100.0 %
Date: 2017-04-26 Functions: 2 2 100.0 %

          Line data    Source code
       1             : // Copyright 2015 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             : #ifndef V8_PENDING_COMPILATION_ERROR_HANDLER_H_
       6             : #define V8_PENDING_COMPILATION_ERROR_HANDLER_H_
       7             : 
       8             : #include "src/base/macros.h"
       9             : #include "src/globals.h"
      10             : #include "src/handles.h"
      11             : #include "src/messages.h"
      12             : 
      13             : namespace v8 {
      14             : namespace internal {
      15             : 
      16             : class AstRawString;
      17             : class Isolate;
      18             : class Script;
      19             : 
      20             : // Helper class for handling pending compilation errors consistently in various
      21             : // compilation phases.
      22             : class PendingCompilationErrorHandler {
      23             :  public:
      24             :   PendingCompilationErrorHandler()
      25             :       : has_pending_error_(false),
      26             :         start_position_(-1),
      27             :         end_position_(-1),
      28             :         message_(MessageTemplate::kNone),
      29             :         arg_(nullptr),
      30             :         char_arg_(nullptr),
      31     3571936 :         error_type_(kSyntaxError) {}
      32             : 
      33      721473 :   void ReportMessageAt(int start_position, int end_position,
      34             :                        MessageTemplate::Template message,
      35             :                        const char* arg = nullptr,
      36             :                        ParseErrorType error_type = kSyntaxError) {
      37     1442946 :     if (has_pending_error_) return;
      38      473047 :     has_pending_error_ = true;
      39      473047 :     start_position_ = start_position;
      40      473047 :     end_position_ = end_position;
      41      473047 :     message_ = message;
      42      473047 :     char_arg_ = arg;
      43      473047 :     arg_ = nullptr;
      44      473047 :     error_type_ = error_type;
      45             :   }
      46             : 
      47      118244 :   void ReportMessageAt(int start_position, int end_position,
      48             :                        MessageTemplate::Template message,
      49             :                        const AstRawString* arg,
      50             :                        ParseErrorType error_type = kSyntaxError) {
      51      236536 :     if (has_pending_error_) return;
      52      118292 :     has_pending_error_ = true;
      53      118292 :     start_position_ = start_position;
      54      118292 :     end_position_ = end_position;
      55      118292 :     message_ = message;
      56      118292 :     char_arg_ = nullptr;
      57      118292 :     arg_ = arg;
      58      118292 :     error_type_ = error_type;
      59             :   }
      60             : 
      61             :   bool has_pending_error() const { return has_pending_error_; }
      62             : 
      63             :   void ThrowPendingError(Isolate* isolate, Handle<Script> script);
      64             :   Handle<String> FormatMessage(Isolate* isolate);
      65             : 
      66             :  private:
      67             :   Handle<String> ArgumentString(Isolate* isolate);
      68             : 
      69             :   bool has_pending_error_;
      70             :   int start_position_;
      71             :   int end_position_;
      72             :   MessageTemplate::Template message_;
      73             :   const AstRawString* arg_;
      74             :   const char* char_arg_;
      75             :   ParseErrorType error_type_;
      76             : 
      77             :   DISALLOW_COPY_AND_ASSIGN(PendingCompilationErrorHandler);
      78             : };
      79             : 
      80             : }  // namespace internal
      81             : }  // namespace v8
      82             : #endif  // V8_PENDING_COMPILATION_ERROR_HANDLER_H_

Generated by: LCOV version 1.10