Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(364)

Unified Diff: src/pending-compilation-error-handler.h

Issue 960543002: Move compilation error handling into a separate class. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/parser.cc ('k') | src/pending-compilation-error-handler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/pending-compilation-error-handler.h
diff --git a/src/pending-compilation-error-handler.h b/src/pending-compilation-error-handler.h
new file mode 100644
index 0000000000000000000000000000000000000000..60923d649d9c60677ba918b130a62f68dbda2769
--- /dev/null
+++ b/src/pending-compilation-error-handler.h
@@ -0,0 +1,77 @@
+// 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_PENDING_COMPILATION_ERROR_HANDLER_H_
+#define V8_PENDING_COMPILATION_ERROR_HANDLER_H_
+
+#include "src/base/macros.h"
+#include "src/globals.h"
+
+namespace v8 {
+namespace internal {
+
+class AstRawString;
+template <class T>
+class Handle;
+class Isolate;
+class Script;
+
+// Helper class for handling pending compilation errors consistently in various
+// compilation phases.
+class PendingCompilationErrorHandler {
+ public:
+ PendingCompilationErrorHandler()
+ : has_pending_error_(false),
+ start_position_(-1),
+ end_position_(-1),
+ message_(nullptr),
+ arg_(nullptr),
+ char_arg_(nullptr),
+ error_type_(kSyntaxError) {}
+
+ void ReportMessageAt(int start_position, int end_position,
+ const char* message, const char* arg = nullptr,
+ ParseErrorType error_type = kSyntaxError) {
+ if (has_pending_error_) return;
+ has_pending_error_ = true;
+ start_position_ = start_position;
+ end_position_ = end_position;
+ message_ = message;
+ char_arg_ = arg;
+ arg_ = nullptr;
+ error_type_ = error_type;
+ }
+
+ void ReportMessageAt(int start_position, int end_position,
+ const char* message, const AstRawString* arg,
+ ParseErrorType error_type = kSyntaxError) {
+ if (has_pending_error_) return;
+ has_pending_error_ = true;
+ start_position_ = start_position;
+ end_position_ = end_position;
+ message_ = message;
+ char_arg_ = nullptr;
+ arg_ = arg;
+ error_type_ = error_type;
+ }
+
+ bool has_pending_error() const { return has_pending_error_; }
+
+ void ThrowPendingError(Isolate* isolate, Handle<Script> script);
+
+ private:
+ bool has_pending_error_;
+ int start_position_;
+ int end_position_;
+ const char* message_;
+ const AstRawString* arg_;
+ const char* char_arg_;
+ ParseErrorType error_type_;
+
+ DISALLOW_COPY_AND_ASSIGN(PendingCompilationErrorHandler);
+};
+
+} // namespace internal
+} // namespace v8
+#endif // V8_PENDING_COMPILATION_ERROR_HANDLER_H_
« no previous file with comments | « src/parser.cc ('k') | src/pending-compilation-error-handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698