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 #include "src/handles.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 if (has_pending_error_) return; | 51 if (has_pending_error_) return; |
52 has_pending_error_ = true; | 52 has_pending_error_ = true; |
53 start_position_ = start_position; | 53 start_position_ = start_position; |
54 end_position_ = end_position; | 54 end_position_ = end_position; |
55 message_ = message; | 55 message_ = message; |
56 char_arg_ = nullptr; | 56 char_arg_ = nullptr; |
57 arg_ = arg; | 57 arg_ = arg; |
58 error_type_ = error_type; | 58 error_type_ = error_type; |
59 } | 59 } |
60 | 60 |
61 void ReportMessageAt(int start_position, int end_position, | |
62 MessageTemplate::Template message, Handle<String> arg, | |
63 ParseErrorType error_type = kSyntaxError) { | |
64 if (has_pending_error_) return; | |
65 has_pending_error_ = true; | |
66 start_position_ = start_position; | |
67 end_position_ = end_position; | |
68 message_ = message; | |
69 char_arg_ = nullptr; | |
70 arg_ = nullptr; | |
71 handle_arg_ = arg; | |
72 error_type_ = error_type; | |
73 } | |
74 | |
75 bool has_pending_error() const { return has_pending_error_; } | 61 bool has_pending_error() const { return has_pending_error_; } |
76 | 62 |
77 void ThrowPendingError(Isolate* isolate, Handle<Script> script); | 63 void ThrowPendingError(Isolate* isolate, Handle<Script> script); |
78 Handle<String> FormatMessage(Isolate* isolate); | 64 Handle<String> FormatMessage(Isolate* isolate); |
79 | 65 |
80 private: | 66 private: |
81 Handle<String> ArgumentString(Isolate* isolate); | 67 Handle<String> ArgumentString(Isolate* isolate); |
82 | 68 |
83 bool has_pending_error_; | 69 bool has_pending_error_; |
84 int start_position_; | 70 int start_position_; |
85 int end_position_; | 71 int end_position_; |
86 MessageTemplate::Template message_; | 72 MessageTemplate::Template message_; |
87 const AstRawString* arg_; | 73 const AstRawString* arg_; |
88 const char* char_arg_; | 74 const char* char_arg_; |
89 Handle<String> handle_arg_; | |
90 ParseErrorType error_type_; | 75 ParseErrorType error_type_; |
91 | 76 |
92 DISALLOW_COPY_AND_ASSIGN(PendingCompilationErrorHandler); | 77 DISALLOW_COPY_AND_ASSIGN(PendingCompilationErrorHandler); |
93 }; | 78 }; |
94 | 79 |
95 } // namespace internal | 80 } // namespace internal |
96 } // namespace v8 | 81 } // namespace v8 |
97 #endif // V8_PENDING_COMPILATION_ERROR_HANDLER_H_ | 82 #endif // V8_PENDING_COMPILATION_ERROR_HANDLER_H_ |
OLD | NEW |