1 | // _gen/yaks/yaks.asdl.h is generated by asdl_main.py
|
2 |
|
3 | #ifndef YAKS_ASDL
|
4 | #define YAKS_ASDL
|
5 |
|
6 | #include <cstdint>
|
7 |
|
8 | #include "mycpp/runtime.h"
|
9 | #include "_gen/asdl/hnode.asdl.h"
|
10 | using hnode_asdl::hnode_t;
|
11 |
|
12 | namespace yaks_asdl {
|
13 |
|
14 | // use struct instead of namespace so 'using' works consistently
|
15 | #define ASDL_NAMES struct
|
16 |
|
17 | class Token;
|
18 | class Bool;
|
19 | class Int;
|
20 | class Str;
|
21 | class MultiStr;
|
22 | class kexpr_t;
|
23 | class Field_;
|
24 | class variant;
|
25 | class ktype_t;
|
26 | class NameType;
|
27 | class stmt_t;
|
28 | class Signature;
|
29 | class mod_def_t;
|
30 | class Module;
|
31 | class Program;
|
32 |
|
33 | enum class op_e {
|
34 | Plus = 1,
|
35 | Minus = 2,
|
36 | };
|
37 | typedef op_e op_t;
|
38 |
|
39 | BigStr* op_str(op_e tag, bool dot = true);
|
40 |
|
41 | ASDL_NAMES kexpr_e {
|
42 | enum no_name {
|
43 | Bool = 65,
|
44 | Int = 66,
|
45 | Str = 67,
|
46 | MultiStr = 68,
|
47 | Unary = 5,
|
48 | Binary = 6,
|
49 | Ternary = 7,
|
50 | Call = 8,
|
51 | };
|
52 | };
|
53 |
|
54 | BigStr* kexpr_str(int tag, bool dot = true);
|
55 |
|
56 | class kexpr_t {
|
57 | protected:
|
58 | kexpr_t() {
|
59 | }
|
60 | public:
|
61 | int tag() const {
|
62 | return ObjHeader::FromObject(this)->type_tag;
|
63 | }
|
64 | hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
|
65 | DISALLOW_COPY_AND_ASSIGN(kexpr_t)
|
66 | };
|
67 |
|
68 | class kexpr__Unary : public kexpr_t {
|
69 | public:
|
70 | kexpr__Unary(Token* op, kexpr_t* child)
|
71 | : op(op),
|
72 | child(child) {
|
73 | }
|
74 |
|
75 | static kexpr__Unary* CreateNull(bool alloc_lists = false) {
|
76 | return Alloc<kexpr__Unary>(nullptr, nullptr);
|
77 | }
|
78 |
|
79 | hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
|
80 |
|
81 | static constexpr ObjHeader obj_header() {
|
82 | return ObjHeader::AsdlClass(static_cast<uint16_t>(kexpr_e::Unary), 2);
|
83 | }
|
84 |
|
85 | Token* op;
|
86 | kexpr_t* child;
|
87 |
|
88 | DISALLOW_COPY_AND_ASSIGN(kexpr__Unary)
|
89 | };
|
90 |
|
91 | class kexpr__Binary : public kexpr_t {
|
92 | public:
|
93 | kexpr__Binary(Token* op, kexpr_t* left, kexpr_t* right)
|
94 | : op(op),
|
95 | left(left),
|
96 | right(right) {
|
97 | }
|
98 |
|
99 | static kexpr__Binary* CreateNull(bool alloc_lists = false) {
|
100 | return Alloc<kexpr__Binary>(nullptr, nullptr, nullptr);
|
101 | }
|
102 |
|
103 | hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
|
104 |
|
105 | static constexpr ObjHeader obj_header() {
|
106 | return ObjHeader::AsdlClass(static_cast<uint16_t>(kexpr_e::Binary), 3);
|
107 | }
|
108 |
|
109 | Token* op;
|
110 | kexpr_t* left;
|
111 | kexpr_t* right;
|
112 |
|
113 | DISALLOW_COPY_AND_ASSIGN(kexpr__Binary)
|
114 | };
|
115 |
|
116 | class kexpr__Ternary : public kexpr_t {
|
117 | public:
|
118 | kexpr__Ternary(Token* op, kexpr_t* left, kexpr_t* cond, kexpr_t* right)
|
119 | : op(op),
|
120 | left(left),
|
121 | cond(cond),
|
122 | right(right) {
|
123 | }
|
124 |
|
125 | static kexpr__Ternary* CreateNull(bool alloc_lists = false) {
|
126 | return Alloc<kexpr__Ternary>(nullptr, nullptr, nullptr, nullptr);
|
127 | }
|
128 |
|
129 | hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
|
130 |
|
131 | static constexpr ObjHeader obj_header() {
|
132 | return ObjHeader::AsdlClass(static_cast<uint16_t>(kexpr_e::Ternary), 4);
|
133 | }
|
134 |
|
135 | Token* op;
|
136 | kexpr_t* left;
|
137 | kexpr_t* cond;
|
138 | kexpr_t* right;
|
139 |
|
140 | DISALLOW_COPY_AND_ASSIGN(kexpr__Ternary)
|
141 | };
|
142 |
|
143 | class kexpr__Call : public kexpr_t {
|
144 | public:
|
145 | kexpr__Call(kexpr_t* f, List<kexpr_t*>* args)
|
146 | : f(f),
|
147 | args(args) {
|
148 | }
|
149 |
|
150 | static kexpr__Call* CreateNull(bool alloc_lists = false) {
|
151 | return Alloc<kexpr__Call>(nullptr, alloc_lists ? Alloc<List<kexpr_t*>>() :
|
152 | nullptr);
|
153 | }
|
154 |
|
155 | hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
|
156 |
|
157 | static constexpr ObjHeader obj_header() {
|
158 | return ObjHeader::AsdlClass(static_cast<uint16_t>(kexpr_e::Call), 2);
|
159 | }
|
160 |
|
161 | kexpr_t* f;
|
162 | List<kexpr_t*>* args;
|
163 |
|
164 | DISALLOW_COPY_AND_ASSIGN(kexpr__Call)
|
165 | };
|
166 |
|
167 | ASDL_NAMES kexpr {
|
168 | typedef kexpr__Unary Unary;
|
169 | typedef kexpr__Binary Binary;
|
170 | typedef kexpr__Ternary Ternary;
|
171 | typedef kexpr__Call Call;
|
172 | };
|
173 |
|
174 | ASDL_NAMES ktype_e {
|
175 | enum no_name {
|
176 | Bool = 1,
|
177 | Int = 2,
|
178 | Str = 3,
|
179 | List = 4,
|
180 | Dict = 5,
|
181 | Class = 6,
|
182 | Data = 7,
|
183 | Enum = 8,
|
184 | };
|
185 | };
|
186 |
|
187 | BigStr* ktype_str(int tag, bool dot = true);
|
188 |
|
189 | class ktype_t {
|
190 | protected:
|
191 | ktype_t() {
|
192 | }
|
193 | public:
|
194 | int tag() const {
|
195 | return ObjHeader::FromObject(this)->type_tag;
|
196 | }
|
197 | hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
|
198 | DISALLOW_COPY_AND_ASSIGN(ktype_t)
|
199 | };
|
200 |
|
201 | class ktype__Bool : public ktype_t {
|
202 | public:
|
203 | ktype__Bool() {}
|
204 |
|
205 | hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
|
206 |
|
207 | static constexpr ObjHeader obj_header() {
|
208 | return ObjHeader::AsdlClass(static_cast<uint16_t>(ktype_e::Bool), 0);
|
209 | }
|
210 |
|
211 |
|
212 | DISALLOW_COPY_AND_ASSIGN(ktype__Bool)
|
213 | };
|
214 |
|
215 | class ktype__Int : public ktype_t {
|
216 | public:
|
217 | ktype__Int() {}
|
218 |
|
219 | hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
|
220 |
|
221 | static constexpr ObjHeader obj_header() {
|
222 | return ObjHeader::AsdlClass(static_cast<uint16_t>(ktype_e::Int), 0);
|
223 | }
|
224 |
|
225 |
|
226 | DISALLOW_COPY_AND_ASSIGN(ktype__Int)
|
227 | };
|
228 |
|
229 | class ktype__Str : public ktype_t {
|
230 | public:
|
231 | ktype__Str() {}
|
232 |
|
233 | hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
|
234 |
|
235 | static constexpr ObjHeader obj_header() {
|
236 | return ObjHeader::AsdlClass(static_cast<uint16_t>(ktype_e::Str), 0);
|
237 | }
|
238 |
|
239 |
|
240 | DISALLOW_COPY_AND_ASSIGN(ktype__Str)
|
241 | };
|
242 |
|
243 | class ktype__List : public ktype_t {
|
244 | public:
|
245 | ktype__List(ktype_t* T)
|
246 | : T(T) {
|
247 | }
|
248 |
|
249 | static ktype__List* CreateNull(bool alloc_lists = false) {
|
250 | return Alloc<ktype__List>(nullptr);
|
251 | }
|
252 |
|
253 | hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
|
254 |
|
255 | static constexpr ObjHeader obj_header() {
|
256 | return ObjHeader::AsdlClass(static_cast<uint16_t>(ktype_e::List), 1);
|
257 | }
|
258 |
|
259 | ktype_t* T;
|
260 |
|
261 | DISALLOW_COPY_AND_ASSIGN(ktype__List)
|
262 | };
|
263 |
|
264 | class ktype__Dict : public ktype_t {
|
265 | public:
|
266 | ktype__Dict(ktype_t* K, ktype_t* V)
|
267 | : K(K),
|
268 | V(V) {
|
269 | }
|
270 |
|
271 | static ktype__Dict* CreateNull(bool alloc_lists = false) {
|
272 | return Alloc<ktype__Dict>(nullptr, nullptr);
|
273 | }
|
274 |
|
275 | hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
|
276 |
|
277 | static constexpr ObjHeader obj_header() {
|
278 | return ObjHeader::AsdlClass(static_cast<uint16_t>(ktype_e::Dict), 2);
|
279 | }
|
280 |
|
281 | ktype_t* K;
|
282 | ktype_t* V;
|
283 |
|
284 | DISALLOW_COPY_AND_ASSIGN(ktype__Dict)
|
285 | };
|
286 |
|
287 | class ktype__Class : public ktype_t {
|
288 | public:
|
289 | ktype__Class(BigStr* name)
|
290 | : name(name) {
|
291 | }
|
292 |
|
293 | static ktype__Class* CreateNull(bool alloc_lists = false) {
|
294 | return Alloc<ktype__Class>(kEmptyString);
|
295 | }
|
296 |
|
297 | hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
|
298 |
|
299 | static constexpr ObjHeader obj_header() {
|
300 | return ObjHeader::AsdlClass(static_cast<uint16_t>(ktype_e::Class), 1);
|
301 | }
|
302 |
|
303 | BigStr* name;
|
304 |
|
305 | DISALLOW_COPY_AND_ASSIGN(ktype__Class)
|
306 | };
|
307 |
|
308 | class ktype__Data : public ktype_t {
|
309 | public:
|
310 | ktype__Data(List<Field_*>* fields)
|
311 | : fields(fields) {
|
312 | }
|
313 |
|
314 | static ktype__Data* CreateNull(bool alloc_lists = false) {
|
315 | return Alloc<ktype__Data>(alloc_lists ? Alloc<List<Field_*>>() : nullptr);
|
316 | }
|
317 |
|
318 | hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
|
319 |
|
320 | static constexpr ObjHeader obj_header() {
|
321 | return ObjHeader::AsdlClass(static_cast<uint16_t>(ktype_e::Data), 1);
|
322 | }
|
323 |
|
324 | List<Field_*>* fields;
|
325 |
|
326 | DISALLOW_COPY_AND_ASSIGN(ktype__Data)
|
327 | };
|
328 |
|
329 | class ktype__Enum : public ktype_t {
|
330 | public:
|
331 | ktype__Enum(List<variant*>* variants)
|
332 | : variants(variants) {
|
333 | }
|
334 |
|
335 | static ktype__Enum* CreateNull(bool alloc_lists = false) {
|
336 | return Alloc<ktype__Enum>(alloc_lists ? Alloc<List<variant*>>() : nullptr);
|
337 | }
|
338 |
|
339 | hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
|
340 |
|
341 | static constexpr ObjHeader obj_header() {
|
342 | return ObjHeader::AsdlClass(static_cast<uint16_t>(ktype_e::Enum), 1);
|
343 | }
|
344 |
|
345 | List<variant*>* variants;
|
346 |
|
347 | DISALLOW_COPY_AND_ASSIGN(ktype__Enum)
|
348 | };
|
349 |
|
350 | extern GcGlobal<ktype__Bool> gktype__Bool;
|
351 | extern GcGlobal<ktype__Int> gktype__Int;
|
352 | extern GcGlobal<ktype__Str> gktype__Str;
|
353 | ASDL_NAMES ktype {
|
354 | static ktype__Bool* Bool;
|
355 | static ktype__Int* Int;
|
356 | static ktype__Str* Str;
|
357 | typedef ktype__List List;
|
358 | typedef ktype__Dict Dict;
|
359 | typedef ktype__Class Class;
|
360 | typedef ktype__Data Data;
|
361 | typedef ktype__Enum Enum;
|
362 | };
|
363 |
|
364 | ASDL_NAMES stmt_e {
|
365 | enum no_name {
|
366 | VarDecl = 1,
|
367 | PlaceMutation = 2,
|
368 | If = 3,
|
369 | Switch = 4,
|
370 | For = 5,
|
371 | While = 6,
|
372 | Break = 7,
|
373 | Continue = 8,
|
374 | Return = 9,
|
375 | Try = 10,
|
376 | With = 11,
|
377 | };
|
378 | };
|
379 |
|
380 | BigStr* stmt_str(int tag, bool dot = true);
|
381 |
|
382 | class stmt_t {
|
383 | protected:
|
384 | stmt_t() {
|
385 | }
|
386 | public:
|
387 | int tag() const {
|
388 | return ObjHeader::FromObject(this)->type_tag;
|
389 | }
|
390 | hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
|
391 | DISALLOW_COPY_AND_ASSIGN(stmt_t)
|
392 | };
|
393 |
|
394 | class stmt__VarDecl : public stmt_t {
|
395 | public:
|
396 | stmt__VarDecl(Token* keyword)
|
397 | : keyword(keyword) {
|
398 | }
|
399 |
|
400 | static stmt__VarDecl* CreateNull(bool alloc_lists = false) {
|
401 | return Alloc<stmt__VarDecl>(nullptr);
|
402 | }
|
403 |
|
404 | hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
|
405 |
|
406 | static constexpr ObjHeader obj_header() {
|
407 | return ObjHeader::AsdlClass(static_cast<uint16_t>(stmt_e::VarDecl), 1);
|
408 | }
|
409 |
|
410 | Token* keyword;
|
411 |
|
412 | DISALLOW_COPY_AND_ASSIGN(stmt__VarDecl)
|
413 | };
|
414 |
|
415 | class stmt__PlaceMutation : public stmt_t {
|
416 | public:
|
417 | stmt__PlaceMutation(Token* keyword)
|
418 | : keyword(keyword) {
|
419 | }
|
420 |
|
421 | static stmt__PlaceMutation* CreateNull(bool alloc_lists = false) {
|
422 | return Alloc<stmt__PlaceMutation>(nullptr);
|
423 | }
|
424 |
|
425 | hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
|
426 |
|
427 | static constexpr ObjHeader obj_header() {
|
428 | return ObjHeader::AsdlClass(static_cast<uint16_t>(stmt_e::PlaceMutation),
|
429 | 1);
|
430 | }
|
431 |
|
432 | Token* keyword;
|
433 |
|
434 | DISALLOW_COPY_AND_ASSIGN(stmt__PlaceMutation)
|
435 | };
|
436 |
|
437 | class stmt__If : public stmt_t {
|
438 | public:
|
439 | stmt__If() {}
|
440 |
|
441 | hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
|
442 |
|
443 | static constexpr ObjHeader obj_header() {
|
444 | return ObjHeader::AsdlClass(static_cast<uint16_t>(stmt_e::If), 0);
|
445 | }
|
446 |
|
447 |
|
448 | DISALLOW_COPY_AND_ASSIGN(stmt__If)
|
449 | };
|
450 |
|
451 | class stmt__Switch : public stmt_t {
|
452 | public:
|
453 | stmt__Switch() {}
|
454 |
|
455 | hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
|
456 |
|
457 | static constexpr ObjHeader obj_header() {
|
458 | return ObjHeader::AsdlClass(static_cast<uint16_t>(stmt_e::Switch), 0);
|
459 | }
|
460 |
|
461 |
|
462 | DISALLOW_COPY_AND_ASSIGN(stmt__Switch)
|
463 | };
|
464 |
|
465 | class stmt__For : public stmt_t {
|
466 | public:
|
467 | stmt__For() {}
|
468 |
|
469 | hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
|
470 |
|
471 | static constexpr ObjHeader obj_header() {
|
472 | return ObjHeader::AsdlClass(static_cast<uint16_t>(stmt_e::For), 0);
|
473 | }
|
474 |
|
475 |
|
476 | DISALLOW_COPY_AND_ASSIGN(stmt__For)
|
477 | };
|
478 |
|
479 | class stmt__While : public stmt_t {
|
480 | public:
|
481 | stmt__While() {}
|
482 |
|
483 | hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
|
484 |
|
485 | static constexpr ObjHeader obj_header() {
|
486 | return ObjHeader::AsdlClass(static_cast<uint16_t>(stmt_e::While), 0);
|
487 | }
|
488 |
|
489 |
|
490 | DISALLOW_COPY_AND_ASSIGN(stmt__While)
|
491 | };
|
492 |
|
493 | class stmt__Break : public stmt_t {
|
494 | public:
|
495 | stmt__Break() {}
|
496 |
|
497 | hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
|
498 |
|
499 | static constexpr ObjHeader obj_header() {
|
500 | return ObjHeader::AsdlClass(static_cast<uint16_t>(stmt_e::Break), 0);
|
501 | }
|
502 |
|
503 |
|
504 | DISALLOW_COPY_AND_ASSIGN(stmt__Break)
|
505 | };
|
506 |
|
507 | class stmt__Continue : public stmt_t {
|
508 | public:
|
509 | stmt__Continue() {}
|
510 |
|
511 | hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
|
512 |
|
513 | static constexpr ObjHeader obj_header() {
|
514 | return ObjHeader::AsdlClass(static_cast<uint16_t>(stmt_e::Continue), 0);
|
515 | }
|
516 |
|
517 |
|
518 | DISALLOW_COPY_AND_ASSIGN(stmt__Continue)
|
519 | };
|
520 |
|
521 | class stmt__Return : public stmt_t {
|
522 | public:
|
523 | stmt__Return(kexpr_t* e)
|
524 | : e(e) {
|
525 | }
|
526 |
|
527 | static stmt__Return* CreateNull(bool alloc_lists = false) {
|
528 | return Alloc<stmt__Return>(nullptr);
|
529 | }
|
530 |
|
531 | hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
|
532 |
|
533 | static constexpr ObjHeader obj_header() {
|
534 | return ObjHeader::AsdlClass(static_cast<uint16_t>(stmt_e::Return), 1);
|
535 | }
|
536 |
|
537 | kexpr_t* e;
|
538 |
|
539 | DISALLOW_COPY_AND_ASSIGN(stmt__Return)
|
540 | };
|
541 |
|
542 | class stmt__Try : public stmt_t {
|
543 | public:
|
544 | stmt__Try() {}
|
545 |
|
546 | hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
|
547 |
|
548 | static constexpr ObjHeader obj_header() {
|
549 | return ObjHeader::AsdlClass(static_cast<uint16_t>(stmt_e::Try), 0);
|
550 | }
|
551 |
|
552 |
|
553 | DISALLOW_COPY_AND_ASSIGN(stmt__Try)
|
554 | };
|
555 |
|
556 | class stmt__With : public stmt_t {
|
557 | public:
|
558 | stmt__With() {}
|
559 |
|
560 | hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
|
561 |
|
562 | static constexpr ObjHeader obj_header() {
|
563 | return ObjHeader::AsdlClass(static_cast<uint16_t>(stmt_e::With), 0);
|
564 | }
|
565 |
|
566 |
|
567 | DISALLOW_COPY_AND_ASSIGN(stmt__With)
|
568 | };
|
569 |
|
570 | extern GcGlobal<stmt__If> gstmt__If;
|
571 | extern GcGlobal<stmt__Switch> gstmt__Switch;
|
572 | extern GcGlobal<stmt__For> gstmt__For;
|
573 | extern GcGlobal<stmt__While> gstmt__While;
|
574 | extern GcGlobal<stmt__Break> gstmt__Break;
|
575 | extern GcGlobal<stmt__Continue> gstmt__Continue;
|
576 | extern GcGlobal<stmt__Try> gstmt__Try;
|
577 | extern GcGlobal<stmt__With> gstmt__With;
|
578 | ASDL_NAMES stmt {
|
579 | typedef stmt__VarDecl VarDecl;
|
580 | typedef stmt__PlaceMutation PlaceMutation;
|
581 | static stmt__If* If;
|
582 | static stmt__Switch* Switch;
|
583 | static stmt__For* For;
|
584 | static stmt__While* While;
|
585 | static stmt__Break* Break;
|
586 | static stmt__Continue* Continue;
|
587 | typedef stmt__Return Return;
|
588 | static stmt__Try* Try;
|
589 | static stmt__With* With;
|
590 | };
|
591 |
|
592 | enum class class_def_e {
|
593 | Constructor = 1,
|
594 | Destructor = 2,
|
595 | Method = 3,
|
596 | Field = 4,
|
597 | };
|
598 | typedef class_def_e class_def_t;
|
599 |
|
600 | BigStr* class_def_str(class_def_e tag, bool dot = true);
|
601 |
|
602 | ASDL_NAMES mod_def_e {
|
603 | enum no_name {
|
604 | Global = 1,
|
605 | Func = 2,
|
606 | Class = 3,
|
607 | Import = 4,
|
608 | Include = 5,
|
609 | Data = 6,
|
610 | Enum = 7,
|
611 | };
|
612 | };
|
613 |
|
614 | BigStr* mod_def_str(int tag, bool dot = true);
|
615 |
|
616 | class mod_def_t {
|
617 | protected:
|
618 | mod_def_t() {
|
619 | }
|
620 | public:
|
621 | int tag() const {
|
622 | return ObjHeader::FromObject(this)->type_tag;
|
623 | }
|
624 | hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
|
625 | DISALLOW_COPY_AND_ASSIGN(mod_def_t)
|
626 | };
|
627 |
|
628 | class mod_def__Global : public mod_def_t {
|
629 | public:
|
630 | mod_def__Global(NameType* name_type)
|
631 | : name_type(name_type) {
|
632 | }
|
633 |
|
634 | static mod_def__Global* CreateNull(bool alloc_lists = false) {
|
635 | return Alloc<mod_def__Global>(nullptr);
|
636 | }
|
637 |
|
638 | hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
|
639 |
|
640 | static constexpr ObjHeader obj_header() {
|
641 | return ObjHeader::AsdlClass(static_cast<uint16_t>(mod_def_e::Global), 1);
|
642 | }
|
643 |
|
644 | NameType* name_type;
|
645 |
|
646 | DISALLOW_COPY_AND_ASSIGN(mod_def__Global)
|
647 | };
|
648 |
|
649 | class mod_def__Func : public mod_def_t {
|
650 | public:
|
651 | mod_def__Func(BigStr* name, Signature* sig, List<stmt_t*>* statements)
|
652 | : name(name),
|
653 | sig(sig),
|
654 | statements(statements) {
|
655 | }
|
656 |
|
657 | static mod_def__Func* CreateNull(bool alloc_lists = false) {
|
658 | return Alloc<mod_def__Func>(kEmptyString, nullptr, alloc_lists ?
|
659 | Alloc<List<stmt_t*>>() : nullptr);
|
660 | }
|
661 |
|
662 | hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
|
663 |
|
664 | static constexpr ObjHeader obj_header() {
|
665 | return ObjHeader::AsdlClass(static_cast<uint16_t>(mod_def_e::Func), 3);
|
666 | }
|
667 |
|
668 | BigStr* name;
|
669 | Signature* sig;
|
670 | List<stmt_t*>* statements;
|
671 |
|
672 | DISALLOW_COPY_AND_ASSIGN(mod_def__Func)
|
673 | };
|
674 |
|
675 | class mod_def__Class : public mod_def_t {
|
676 | public:
|
677 | mod_def__Class(BigStr* name, List<class_def_t>* defs)
|
678 | : name(name),
|
679 | defs(defs) {
|
680 | }
|
681 |
|
682 | static mod_def__Class* CreateNull(bool alloc_lists = false) {
|
683 | return Alloc<mod_def__Class>(kEmptyString, alloc_lists ?
|
684 | Alloc<List<class_def_t>>() : nullptr);
|
685 | }
|
686 |
|
687 | hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
|
688 |
|
689 | static constexpr ObjHeader obj_header() {
|
690 | return ObjHeader::AsdlClass(static_cast<uint16_t>(mod_def_e::Class), 2);
|
691 | }
|
692 |
|
693 | BigStr* name;
|
694 | List<class_def_t>* defs;
|
695 |
|
696 | DISALLOW_COPY_AND_ASSIGN(mod_def__Class)
|
697 | };
|
698 |
|
699 | class mod_def__Import : public mod_def_t {
|
700 | public:
|
701 | mod_def__Import() {}
|
702 |
|
703 | hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
|
704 |
|
705 | static constexpr ObjHeader obj_header() {
|
706 | return ObjHeader::AsdlClass(static_cast<uint16_t>(mod_def_e::Import), 0);
|
707 | }
|
708 |
|
709 |
|
710 | DISALLOW_COPY_AND_ASSIGN(mod_def__Import)
|
711 | };
|
712 |
|
713 | class mod_def__Include : public mod_def_t {
|
714 | public:
|
715 | mod_def__Include(BigStr* path)
|
716 | : path(path) {
|
717 | }
|
718 |
|
719 | static mod_def__Include* CreateNull(bool alloc_lists = false) {
|
720 | return Alloc<mod_def__Include>(kEmptyString);
|
721 | }
|
722 |
|
723 | hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
|
724 |
|
725 | static constexpr ObjHeader obj_header() {
|
726 | return ObjHeader::AsdlClass(static_cast<uint16_t>(mod_def_e::Include), 1);
|
727 | }
|
728 |
|
729 | BigStr* path;
|
730 |
|
731 | DISALLOW_COPY_AND_ASSIGN(mod_def__Include)
|
732 | };
|
733 |
|
734 | class mod_def__Data : public mod_def_t {
|
735 | public:
|
736 | mod_def__Data() {}
|
737 |
|
738 | hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
|
739 |
|
740 | static constexpr ObjHeader obj_header() {
|
741 | return ObjHeader::AsdlClass(static_cast<uint16_t>(mod_def_e::Data), 0);
|
742 | }
|
743 |
|
744 |
|
745 | DISALLOW_COPY_AND_ASSIGN(mod_def__Data)
|
746 | };
|
747 |
|
748 | class mod_def__Enum : public mod_def_t {
|
749 | public:
|
750 | mod_def__Enum() {}
|
751 |
|
752 | hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
|
753 |
|
754 | static constexpr ObjHeader obj_header() {
|
755 | return ObjHeader::AsdlClass(static_cast<uint16_t>(mod_def_e::Enum), 0);
|
756 | }
|
757 |
|
758 |
|
759 | DISALLOW_COPY_AND_ASSIGN(mod_def__Enum)
|
760 | };
|
761 |
|
762 | extern GcGlobal<mod_def__Import> gmod_def__Import;
|
763 | extern GcGlobal<mod_def__Data> gmod_def__Data;
|
764 | extern GcGlobal<mod_def__Enum> gmod_def__Enum;
|
765 | ASDL_NAMES mod_def {
|
766 | typedef mod_def__Global Global;
|
767 | typedef mod_def__Func Func;
|
768 | typedef mod_def__Class Class;
|
769 | static mod_def__Import* Import;
|
770 | typedef mod_def__Include Include;
|
771 | static mod_def__Data* Data;
|
772 | static mod_def__Enum* Enum;
|
773 | };
|
774 |
|
775 | class Token {
|
776 | public:
|
777 | Token(BigStr* path, BigStr* chunk, int start, int length)
|
778 | : path(path),
|
779 | chunk(chunk),
|
780 | start(start),
|
781 | length(length) {
|
782 | }
|
783 |
|
784 | static Token* CreateNull(bool alloc_lists = false) {
|
785 | return Alloc<Token>(kEmptyString, kEmptyString, -1, -1);
|
786 | }
|
787 |
|
788 | hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
|
789 |
|
790 | static constexpr ObjHeader obj_header() {
|
791 | return ObjHeader::AsdlClass(64, 2);
|
792 | }
|
793 |
|
794 | BigStr* path;
|
795 | BigStr* chunk;
|
796 | int start;
|
797 | int length;
|
798 |
|
799 | DISALLOW_COPY_AND_ASSIGN(Token)
|
800 | };
|
801 |
|
802 | class Bool : public kexpr_t {
|
803 | public:
|
804 | Bool(bool b, Token* loc)
|
805 | : loc(loc),
|
806 | b(b) {
|
807 | }
|
808 |
|
809 | static Bool* CreateNull(bool alloc_lists = false) {
|
810 | return Alloc<Bool>(false, nullptr);
|
811 | }
|
812 |
|
813 | hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
|
814 |
|
815 | static constexpr ObjHeader obj_header() {
|
816 | return ObjHeader::AsdlClass(65, 1);
|
817 | }
|
818 |
|
819 | Token* loc;
|
820 | bool b;
|
821 |
|
822 | DISALLOW_COPY_AND_ASSIGN(Bool)
|
823 | };
|
824 |
|
825 | class Int : public kexpr_t {
|
826 | public:
|
827 | Int(int i, Token* loc)
|
828 | : loc(loc),
|
829 | i(i) {
|
830 | }
|
831 |
|
832 | static Int* CreateNull(bool alloc_lists = false) {
|
833 | return Alloc<Int>(-1, nullptr);
|
834 | }
|
835 |
|
836 | hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
|
837 |
|
838 | static constexpr ObjHeader obj_header() {
|
839 | return ObjHeader::AsdlClass(66, 1);
|
840 | }
|
841 |
|
842 | Token* loc;
|
843 | int i;
|
844 |
|
845 | DISALLOW_COPY_AND_ASSIGN(Int)
|
846 | };
|
847 |
|
848 | class Str : public kexpr_t {
|
849 | public:
|
850 | Str(BigStr* s, Token* loc)
|
851 | : s(s),
|
852 | loc(loc) {
|
853 | }
|
854 |
|
855 | static Str* CreateNull(bool alloc_lists = false) {
|
856 | return Alloc<Str>(kEmptyString, nullptr);
|
857 | }
|
858 |
|
859 | hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
|
860 |
|
861 | static constexpr ObjHeader obj_header() {
|
862 | return ObjHeader::AsdlClass(67, 2);
|
863 | }
|
864 |
|
865 | BigStr* s;
|
866 | Token* loc;
|
867 |
|
868 | DISALLOW_COPY_AND_ASSIGN(Str)
|
869 | };
|
870 |
|
871 | class MultiStr : public kexpr_t {
|
872 | public:
|
873 | MultiStr(List<Token*>* lines)
|
874 | : lines(lines) {
|
875 | }
|
876 |
|
877 | static MultiStr* CreateNull(bool alloc_lists = false) {
|
878 | return Alloc<MultiStr>(alloc_lists ? Alloc<List<Token*>>() : nullptr);
|
879 | }
|
880 |
|
881 | hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
|
882 |
|
883 | static constexpr ObjHeader obj_header() {
|
884 | return ObjHeader::AsdlClass(68, 1);
|
885 | }
|
886 |
|
887 | List<Token*>* lines;
|
888 |
|
889 | DISALLOW_COPY_AND_ASSIGN(MultiStr)
|
890 | };
|
891 |
|
892 | class Field_ {
|
893 | public:
|
894 | Field_(BigStr* name, ktype_t* typ)
|
895 | : name(name),
|
896 | typ(typ) {
|
897 | }
|
898 |
|
899 | static Field_* CreateNull(bool alloc_lists = false) {
|
900 | return Alloc<Field_>(kEmptyString, nullptr);
|
901 | }
|
902 |
|
903 | hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
|
904 |
|
905 | static constexpr ObjHeader obj_header() {
|
906 | return ObjHeader::AsdlClass(69, 2);
|
907 | }
|
908 |
|
909 | BigStr* name;
|
910 | ktype_t* typ;
|
911 |
|
912 | DISALLOW_COPY_AND_ASSIGN(Field_)
|
913 | };
|
914 |
|
915 | class variant {
|
916 | public:
|
917 | variant(List<Field_*>* fields)
|
918 | : fields(fields) {
|
919 | }
|
920 |
|
921 | static variant* CreateNull(bool alloc_lists = false) {
|
922 | return Alloc<variant>(alloc_lists ? Alloc<List<Field_*>>() : nullptr);
|
923 | }
|
924 |
|
925 | hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
|
926 |
|
927 | static constexpr ObjHeader obj_header() {
|
928 | return ObjHeader::AsdlClass(70, 1);
|
929 | }
|
930 |
|
931 | List<Field_*>* fields;
|
932 |
|
933 | DISALLOW_COPY_AND_ASSIGN(variant)
|
934 | };
|
935 |
|
936 | class NameType {
|
937 | public:
|
938 | NameType(BigStr* name, ktype_t* typ)
|
939 | : name(name),
|
940 | typ(typ) {
|
941 | }
|
942 |
|
943 | static NameType* CreateNull(bool alloc_lists = false) {
|
944 | return Alloc<NameType>(kEmptyString, nullptr);
|
945 | }
|
946 |
|
947 | hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
|
948 |
|
949 | static constexpr ObjHeader obj_header() {
|
950 | return ObjHeader::AsdlClass(71, 2);
|
951 | }
|
952 |
|
953 | BigStr* name;
|
954 | ktype_t* typ;
|
955 |
|
956 | DISALLOW_COPY_AND_ASSIGN(NameType)
|
957 | };
|
958 |
|
959 | class Signature {
|
960 | public:
|
961 | Signature(List<NameType*>* params, ktype_t* return_type)
|
962 | : params(params),
|
963 | return_type(return_type) {
|
964 | }
|
965 |
|
966 | static Signature* CreateNull(bool alloc_lists = false) {
|
967 | return Alloc<Signature>(alloc_lists ? Alloc<List<NameType*>>() : nullptr,
|
968 | nullptr);
|
969 | }
|
970 |
|
971 | hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
|
972 |
|
973 | static constexpr ObjHeader obj_header() {
|
974 | return ObjHeader::AsdlClass(72, 2);
|
975 | }
|
976 |
|
977 | List<NameType*>* params;
|
978 | ktype_t* return_type;
|
979 |
|
980 | DISALLOW_COPY_AND_ASSIGN(Signature)
|
981 | };
|
982 |
|
983 | class Module {
|
984 | public:
|
985 | Module(BigStr* name, List<mod_def_t*>* defs)
|
986 | : name(name),
|
987 | defs(defs) {
|
988 | }
|
989 |
|
990 | static Module* CreateNull(bool alloc_lists = false) {
|
991 | return Alloc<Module>(kEmptyString, alloc_lists ? Alloc<List<mod_def_t*>>()
|
992 | : nullptr);
|
993 | }
|
994 |
|
995 | hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
|
996 |
|
997 | static constexpr ObjHeader obj_header() {
|
998 | return ObjHeader::AsdlClass(73, 2);
|
999 | }
|
1000 |
|
1001 | BigStr* name;
|
1002 | List<mod_def_t*>* defs;
|
1003 |
|
1004 | DISALLOW_COPY_AND_ASSIGN(Module)
|
1005 | };
|
1006 |
|
1007 | class Program {
|
1008 | public:
|
1009 | Program(BigStr* main_module, List<Module*>* modules)
|
1010 | : main_module(main_module),
|
1011 | modules(modules) {
|
1012 | }
|
1013 |
|
1014 | static Program* CreateNull(bool alloc_lists = false) {
|
1015 | return Alloc<Program>(kEmptyString, alloc_lists ? Alloc<List<Module*>>() :
|
1016 | nullptr);
|
1017 | }
|
1018 |
|
1019 | hnode_t* PrettyTree(Dict<int, bool>* seen = nullptr);
|
1020 |
|
1021 | static constexpr ObjHeader obj_header() {
|
1022 | return ObjHeader::AsdlClass(74, 2);
|
1023 | }
|
1024 |
|
1025 | BigStr* main_module;
|
1026 | List<Module*>* modules;
|
1027 |
|
1028 | DISALLOW_COPY_AND_ASSIGN(Program)
|
1029 | };
|
1030 |
|
1031 |
|
1032 | } // namespace yaks_asdl
|
1033 |
|
1034 | #endif // YAKS_ASDL
|