@@ -130,33 +130,27 @@ namespace pl::core::err {
130
130
std::vector<Location> m_trace;
131
131
};
132
132
133
- class ErrorCollector {
133
+ class ErrorCollectorExplicitLocation
134
+ {
134
135
public:
135
-
136
- virtual ~ErrorCollector () = default ;
137
-
138
- virtual Location location () = 0;
136
+ virtual ~ErrorCollectorExplicitLocation () = default ;
139
137
140
138
template <typename ... Args>
141
- void error (const fmt::format_string<Args...>& fmt, Args&&... args) {
142
- this ->m_errors .emplace_back (fmt::format (fmt, std::forward<Args>(args)...), location () );
139
+ void error (const Location &location, const fmt::format_string<Args...> & fmt, Args&&... args) {
140
+ this ->m_errors .emplace_back (fmt::format (fmt, std::forward<Args>(args)...), location);
143
141
}
144
142
145
- void error (const std::string &message) {
146
- this ->m_errors .emplace_back (message, location ());
147
- }
148
-
149
- void errorDesc (const std::string &message, const std::string &description) {
150
- this ->m_errors .emplace_back (message, description, location ());
143
+ void errorDesc (const Location &location, const std::string &message, const std::string &description) {
144
+ this ->m_errors .emplace_back (message, description, location);
151
145
}
152
146
153
147
template <typename ... Args>
154
- void errorDesc (const fmt::format_string<Args...>& message, const std::string &description, Args&&... args) {
155
- this ->m_errors .emplace_back (fmt::format (message, std::forward<Args>(args)...), description, location () );
148
+ void errorDesc (const Location &location, const fmt::format_string<Args...>& message, const std::string &description, Args&&... args) {
149
+ this ->m_errors .emplace_back (fmt::format (message, std::forward<Args>(args)...), description, location);
156
150
}
157
151
158
- void error (CompileError& error) {
159
- error.getTrace ().push_back (location () );
152
+ void error (const Location &location, CompileError& error) {
153
+ error.getTrace ().push_back (location);
160
154
this ->m_errors .push_back (std::move (error));
161
155
}
162
156
@@ -188,8 +182,39 @@ namespace pl::core::err {
188
182
void clear () {
189
183
this ->m_errors .clear ();
190
184
}
185
+
191
186
private:
192
187
std::vector<CompileError> m_errors;
193
188
};
194
189
190
+ class ErrorCollector : public ErrorCollectorExplicitLocation {
191
+ public:
192
+
193
+ virtual ~ErrorCollector () = default ;
194
+
195
+ virtual Location location () = 0;
196
+
197
+ template <typename ... Args>
198
+ void error (const fmt::format_string<Args...> &fmt, Args&&... args) {
199
+ this ->ErrorCollectorExplicitLocation ::error (location (), fmt, std::forward<Args>(args)...);
200
+ }
201
+
202
+ void error (const std::string &message) {
203
+ this ->errorAt (location (), message);
204
+ }
205
+
206
+ void errorDesc (const std::string &message, const std::string &description) {
207
+ this ->ErrorCollectorExplicitLocation ::errorDesc (location (), message, description);
208
+ }
209
+
210
+ template <typename ... Args>
211
+ void errorDesc (const fmt::format_string<Args...>& message, const std::string &description, Args&&... args) {
212
+ this ->ErrorCollectorExplicitLocation ::errorDesc (location (), message, description, std::forward<Args>(args)...);
213
+ }
214
+
215
+ void error (CompileError& error) {
216
+ this ->ErrorCollectorExplicitLocation ::error (location (), error);
217
+ }
218
+ };
219
+
195
220
}
0 commit comments