OILS / prebuilt / core / error.mycpp.h View on Github | oilshell.org

303 lines, 195 significant
1// prebuilt/core/error.mycpp.h: GENERATED by mycpp
2
3#ifndef CORE_ERROR_MYCPP_H
4#define CORE_ERROR_MYCPP_H
5
6#include "_gen/asdl/hnode.asdl.h"
7#include "cpp/data_lang.h"
8#include "mycpp/runtime.h"
9
10#include "_gen/core/runtime.asdl.h"
11#include "_gen/core/value.asdl.h"
12#include "_gen/frontend/syntax.asdl.h"
13
14using value_asdl::value; // This is a bit ad hoc
15
16namespace error { // forward declare
17
18 class _ErrorWithLocation;
19 class Usage;
20 class Parse;
21 class FailGlob;
22 class RedirectEval;
23 class FatalRuntime;
24 class Strict;
25 class ErrExit;
26 class Expr;
27 class Structured;
28 class AssertionErr;
29 class TypeErrVerbose;
30 class TypeErr;
31 class Runtime;
32 class Decode;
33 class Encode;
34
35} // forward declare namespace error
36
37namespace error { // declare
38
39using syntax_asdl::loc;
40BigStr* _ValType(value_asdl::value_t* val);
41class _ErrorWithLocation {
42 public:
43 _ErrorWithLocation(BigStr* msg, syntax_asdl::loc_t* location);
44 bool HasLocation();
45 BigStr* UserErrorString();
46 syntax_asdl::loc_t* location;
47 BigStr* msg;
48
49 static constexpr uint32_t field_mask() {
50 return maskbit(offsetof(_ErrorWithLocation, location))
51 | maskbit(offsetof(_ErrorWithLocation, msg));
52 }
53
54 static constexpr ObjHeader obj_header() {
55 return ObjHeader::ClassFixed(field_mask(), sizeof(_ErrorWithLocation));
56 }
57
58 DISALLOW_COPY_AND_ASSIGN(_ErrorWithLocation)
59};
60
61class Usage : public _ErrorWithLocation {
62 public:
63 Usage(BigStr* msg, syntax_asdl::loc_t* location);
64
65 static constexpr uint32_t field_mask() {
66 return _ErrorWithLocation::field_mask();
67 }
68
69 static constexpr ObjHeader obj_header() {
70 return ObjHeader::ClassFixed(field_mask(), sizeof(Usage));
71 }
72
73 DISALLOW_COPY_AND_ASSIGN(Usage)
74};
75
76class Parse : public _ErrorWithLocation {
77 public:
78 Parse(BigStr* msg, syntax_asdl::loc_t* location);
79
80 static constexpr uint32_t field_mask() {
81 return _ErrorWithLocation::field_mask();
82 }
83
84 static constexpr ObjHeader obj_header() {
85 return ObjHeader::ClassFixed(field_mask(), sizeof(Parse));
86 }
87
88 DISALLOW_COPY_AND_ASSIGN(Parse)
89};
90
91class FailGlob : public _ErrorWithLocation {
92 public:
93 FailGlob(BigStr* msg, syntax_asdl::loc_t* location);
94
95 static constexpr uint32_t field_mask() {
96 return _ErrorWithLocation::field_mask();
97 }
98
99 static constexpr ObjHeader obj_header() {
100 return ObjHeader::ClassFixed(field_mask(), sizeof(FailGlob));
101 }
102
103 DISALLOW_COPY_AND_ASSIGN(FailGlob)
104};
105
106class RedirectEval : public _ErrorWithLocation {
107 public:
108 RedirectEval(BigStr* msg, syntax_asdl::loc_t* location);
109
110 static constexpr uint32_t field_mask() {
111 return _ErrorWithLocation::field_mask();
112 }
113
114 static constexpr ObjHeader obj_header() {
115 return ObjHeader::ClassFixed(field_mask(), sizeof(RedirectEval));
116 }
117
118 DISALLOW_COPY_AND_ASSIGN(RedirectEval)
119};
120
121class FatalRuntime : public _ErrorWithLocation {
122 public:
123 FatalRuntime(int exit_status, BigStr* msg, syntax_asdl::loc_t* location);
124 int ExitStatus();
125
126 int exit_status;
127
128 static constexpr uint32_t field_mask() {
129 return _ErrorWithLocation::field_mask();
130 }
131
132 static constexpr ObjHeader obj_header() {
133 return ObjHeader::ClassFixed(field_mask(), sizeof(FatalRuntime));
134 }
135
136 DISALLOW_COPY_AND_ASSIGN(FatalRuntime)
137};
138
139class Strict : public FatalRuntime {
140 public:
141 Strict(BigStr* msg, syntax_asdl::loc_t* location);
142
143 static constexpr uint32_t field_mask() {
144 return FatalRuntime::field_mask();
145 }
146
147 static constexpr ObjHeader obj_header() {
148 return ObjHeader::ClassFixed(field_mask(), sizeof(Strict));
149 }
150
151 DISALLOW_COPY_AND_ASSIGN(Strict)
152};
153
154class ErrExit : public FatalRuntime {
155 public:
156 ErrExit(int exit_status, BigStr* msg, syntax_asdl::loc_t* location, bool show_code = false);
157
158 bool show_code;
159
160 static constexpr uint32_t field_mask() {
161 return FatalRuntime::field_mask();
162 }
163
164 static constexpr ObjHeader obj_header() {
165 return ObjHeader::ClassFixed(field_mask(), sizeof(ErrExit));
166 }
167
168 DISALLOW_COPY_AND_ASSIGN(ErrExit)
169};
170
171class Expr : public FatalRuntime {
172 public:
173 Expr(BigStr* msg, syntax_asdl::loc_t* location);
174
175 static constexpr uint32_t field_mask() {
176 return FatalRuntime::field_mask();
177 }
178
179 static constexpr ObjHeader obj_header() {
180 return ObjHeader::ClassFixed(field_mask(), sizeof(Expr));
181 }
182
183 DISALLOW_COPY_AND_ASSIGN(Expr)
184};
185
186class Structured : public FatalRuntime {
187 public:
188 Structured(int status, BigStr* msg, syntax_asdl::loc_t* location, Dict<BigStr*, value_asdl::value_t*>* properties = nullptr);
189 value::Dict* ToDict();
190
191 Dict<BigStr*, value_asdl::value_t*>* properties;
192
193 static constexpr uint32_t field_mask() {
194 return FatalRuntime::field_mask()
195 | maskbit(offsetof(Structured, properties));
196 }
197
198 static constexpr ObjHeader obj_header() {
199 return ObjHeader::ClassFixed(field_mask(), sizeof(Structured));
200 }
201
202 DISALLOW_COPY_AND_ASSIGN(Structured)
203};
204
205class AssertionErr : public Expr {
206 public:
207 AssertionErr(BigStr* msg, syntax_asdl::loc_t* location);
208
209 static constexpr uint32_t field_mask() {
210 return Expr::field_mask();
211 }
212
213 static constexpr ObjHeader obj_header() {
214 return ObjHeader::ClassFixed(field_mask(), sizeof(AssertionErr));
215 }
216
217 DISALLOW_COPY_AND_ASSIGN(AssertionErr)
218};
219
220class TypeErrVerbose : public Expr {
221 public:
222 TypeErrVerbose(BigStr* msg, syntax_asdl::loc_t* location);
223
224 static constexpr uint32_t field_mask() {
225 return Expr::field_mask();
226 }
227
228 static constexpr ObjHeader obj_header() {
229 return ObjHeader::ClassFixed(field_mask(), sizeof(TypeErrVerbose));
230 }
231
232 DISALLOW_COPY_AND_ASSIGN(TypeErrVerbose)
233};
234
235class TypeErr : public TypeErrVerbose {
236 public:
237 TypeErr(value_asdl::value_t* actual_val, BigStr* msg, syntax_asdl::loc_t* location);
238
239 static constexpr uint32_t field_mask() {
240 return TypeErrVerbose::field_mask();
241 }
242
243 static constexpr ObjHeader obj_header() {
244 return ObjHeader::ClassFixed(field_mask(), sizeof(TypeErr));
245 }
246
247 DISALLOW_COPY_AND_ASSIGN(TypeErr)
248};
249
250class Runtime {
251 public:
252 Runtime(BigStr* msg);
253 BigStr* UserErrorString();
254 BigStr* msg;
255
256 static constexpr ObjHeader obj_header() {
257 return ObjHeader::ClassScanned(1, sizeof(Runtime));
258 }
259
260 DISALLOW_COPY_AND_ASSIGN(Runtime)
261};
262
263class Decode {
264 public:
265 Decode(BigStr* msg, BigStr* s, int start_pos, int end_pos, int line_num);
266 BigStr* Message();
267 BigStr* __str__();
268 BigStr* msg;
269 BigStr* s;
270 int start_pos;
271 int end_pos;
272 int line_num;
273
274 static constexpr ObjHeader obj_header() {
275 return ObjHeader::ClassScanned(2, sizeof(Decode));
276 }
277
278 DISALLOW_COPY_AND_ASSIGN(Decode)
279};
280
281class Encode {
282 public:
283 Encode(BigStr* msg);
284 BigStr* Message();
285 BigStr* msg;
286
287 static constexpr ObjHeader obj_header() {
288 return ObjHeader::ClassScanned(1, sizeof(Encode));
289 }
290
291 DISALLOW_COPY_AND_ASSIGN(Encode)
292};
293
294[[noreturn]] void e_usage(BigStr* msg, syntax_asdl::loc_t* location);
295[[noreturn]] void e_strict(BigStr* msg, syntax_asdl::loc_t* location);
296[[noreturn]] void p_die(BigStr* msg, syntax_asdl::loc_t* location);
297[[noreturn]] void e_die(BigStr* msg, syntax_asdl::loc_t* location = nullptr);
298[[noreturn]] void e_die_status(int status, BigStr* msg, syntax_asdl::loc_t* location = nullptr);
299
300
301} // declare namespace error
302
303#endif // CORE_ERROR_MYCPP_H