// Copyright 2015 the V8 project authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef V8_PARSING_PENDING_COMPILATION_ERROR_HANDLER_H_ #define V8_PARSING_PENDING_COMPILATION_ERROR_HANDLER_H_ #include #include "src/base/export-template.h" #include "src/base/macros.h" #include "src/common/globals.h" #include "src/common/message-template.h" #include "src/handles/handles.h" namespace v8 { namespace internal { class AstRawString; class AstValueFactory; class Isolate; class Script; // Helper class for handling pending compilation errors consistently in various // compilation phases. class PendingCompilationErrorHandler { public: PendingCompilationErrorHandler() = default; PendingCompilationErrorHandler(const PendingCompilationErrorHandler&) = delete; PendingCompilationErrorHandler& operator=( const PendingCompilationErrorHandler&) = delete; void ReportMessageAt(int start_position, int end_position, MessageTemplate message, const char* arg = nullptr); void ReportMessageAt(int start_position, int end_position, MessageTemplate message, const AstRawString* arg); void ReportMessageAt(int start_position, int end_position, MessageTemplate message, const AstRawString* arg0, const char* arg1); void ReportWarningAt(int start_position, int end_position, MessageTemplate message, const char* arg = nullptr); bool stack_overflow() const { return stack_overflow_; } void set_stack_overflow() { has_pending_error_ = true; stack_overflow_ = true; } bool has_pending_error() const { return has_pending_error_; } bool has_pending_warnings() const { return !warning_messages_.empty(); } // Handle errors detected during parsing. template EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) void PrepareErrors(IsolateT* isolate, AstValueFactory* ast_value_factory); V8_EXPORT_PRIVATE void ReportErrors(Isolate* isolate, Handle