OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_PENDING_COMPILATION_ERROR_HANDLER_H_ | 5 #ifndef V8_PENDING_COMPILATION_ERROR_HANDLER_H_ |
6 #define V8_PENDING_COMPILATION_ERROR_HANDLER_H_ | 6 #define V8_PENDING_COMPILATION_ERROR_HANDLER_H_ |
7 | 7 |
8 #include "src/base/macros.h" | 8 #include "src/base/macros.h" |
9 #include "src/globals.h" | 9 #include "src/globals.h" |
| 10 #include "src/handles.h" |
10 | 11 |
11 namespace v8 { | 12 namespace v8 { |
12 namespace internal { | 13 namespace internal { |
13 | 14 |
14 class AstRawString; | 15 class AstRawString; |
15 template <class T> | |
16 class Handle; | |
17 class Isolate; | 16 class Isolate; |
18 class Script; | 17 class Script; |
19 | 18 |
20 // Helper class for handling pending compilation errors consistently in various | 19 // Helper class for handling pending compilation errors consistently in various |
21 // compilation phases. | 20 // compilation phases. |
22 class PendingCompilationErrorHandler { | 21 class PendingCompilationErrorHandler { |
23 public: | 22 public: |
24 PendingCompilationErrorHandler() | 23 PendingCompilationErrorHandler() |
25 : has_pending_error_(false), | 24 : has_pending_error_(false), |
26 start_position_(-1), | 25 start_position_(-1), |
(...skipping 22 matching lines...) Expand all Loading... |
49 if (has_pending_error_) return; | 48 if (has_pending_error_) return; |
50 has_pending_error_ = true; | 49 has_pending_error_ = true; |
51 start_position_ = start_position; | 50 start_position_ = start_position; |
52 end_position_ = end_position; | 51 end_position_ = end_position; |
53 message_ = message; | 52 message_ = message; |
54 char_arg_ = nullptr; | 53 char_arg_ = nullptr; |
55 arg_ = arg; | 54 arg_ = arg; |
56 error_type_ = error_type; | 55 error_type_ = error_type; |
57 } | 56 } |
58 | 57 |
| 58 void ReportMessageAt(int start_position, int end_position, |
| 59 const char* message, Handle<String> arg, |
| 60 ParseErrorType error_type = kSyntaxError) { |
| 61 if (has_pending_error_) return; |
| 62 has_pending_error_ = true; |
| 63 start_position_ = start_position; |
| 64 end_position_ = end_position; |
| 65 message_ = message; |
| 66 char_arg_ = nullptr; |
| 67 arg_ = nullptr; |
| 68 handle_arg_ = arg; |
| 69 error_type_ = error_type; |
| 70 } |
| 71 |
59 bool has_pending_error() const { return has_pending_error_; } | 72 bool has_pending_error() const { return has_pending_error_; } |
60 | 73 |
61 void ThrowPendingError(Isolate* isolate, Handle<Script> script); | 74 void ThrowPendingError(Isolate* isolate, Handle<Script> script); |
62 | 75 |
63 private: | 76 private: |
64 bool has_pending_error_; | 77 bool has_pending_error_; |
65 int start_position_; | 78 int start_position_; |
66 int end_position_; | 79 int end_position_; |
67 const char* message_; | 80 const char* message_; |
68 const AstRawString* arg_; | 81 const AstRawString* arg_; |
69 const char* char_arg_; | 82 const char* char_arg_; |
| 83 Handle<String> handle_arg_; |
70 ParseErrorType error_type_; | 84 ParseErrorType error_type_; |
71 | 85 |
72 DISALLOW_COPY_AND_ASSIGN(PendingCompilationErrorHandler); | 86 DISALLOW_COPY_AND_ASSIGN(PendingCompilationErrorHandler); |
73 }; | 87 }; |
74 | 88 |
75 } // namespace internal | 89 } // namespace internal |
76 } // namespace v8 | 90 } // namespace v8 |
77 #endif // V8_PENDING_COMPILATION_ERROR_HANDLER_H_ | 91 #endif // V8_PENDING_COMPILATION_ERROR_HANDLER_H_ |
OLD | NEW |