OILS / _gen / core / value.asdl.cc View on Github | oilshell.org

1193 lines, 834 significant
1// _gen/core/value.asdl.cc is generated by asdl_main.py
2
3#include "_gen/core/value.asdl.h"
4#include <assert.h>
5#include "prebuilt/asdl/runtime.mycpp.h" // generated code uses wrappers here
6#include "_gen/frontend/syntax.asdl.h" // "use" in ASDL
7#include "_gen/core/runtime.asdl.h" // "use" in ASDL
8
9// Generated code uses these types
10using hnode_asdl::hnode;
11using hnode_asdl::Field;
12using hnode_asdl::color_e;
13
14
15namespace value_asdl {
16
17
18hnode_t* IntBox::PrettyTree(Dict<int, bool>* seen) {
19 seen = seen ? seen : Alloc<Dict<int, bool>>();
20 int heap_id = ObjectId(this);
21 if (dict_contains(seen, heap_id)) {
22 return Alloc<hnode::AlreadySeen>(heap_id);
23 }
24 seen->set(heap_id, true);
25 hnode::Record* out_node = runtime::NewRecord(StrFromC("IntBox"));
26 List<Field*>* L = out_node->fields;
27
28 hnode_t* x0 = Alloc<hnode::Leaf>(str(this->i), color_e::OtherConst);
29 L->append(Alloc<Field>(StrFromC("i"), x0));
30
31 return out_node;
32}
33
34
35hnode_t* ProcDefaults::PrettyTree(Dict<int, bool>* seen) {
36 seen = seen ? seen : Alloc<Dict<int, bool>>();
37 int heap_id = ObjectId(this);
38 if (dict_contains(seen, heap_id)) {
39 return Alloc<hnode::AlreadySeen>(heap_id);
40 }
41 seen->set(heap_id, true);
42 hnode::Record* out_node = runtime::NewRecord(StrFromC("ProcDefaults"));
43 List<Field*>* L = out_node->fields;
44
45 if (this->for_word != nullptr) { // List
46 hnode::Array* x0 = Alloc<hnode::Array>(Alloc<List<hnode_t*>>());
47 for (ListIter<value_t*> it(this->for_word); !it.Done(); it.Next()) {
48 value_t* i0 = it.Value();
49 hnode_t* h = (i0 == nullptr) ? Alloc<hnode::Leaf>(StrFromC("_"),
50 color_e::OtherConst) : i0->PrettyTree(seen);
51 x0->children->append(h);
52 }
53 L->append(Alloc<Field>(StrFromC("for_word"), x0));
54 }
55
56 if (this->for_typed != nullptr) { // List
57 hnode::Array* x1 = Alloc<hnode::Array>(Alloc<List<hnode_t*>>());
58 for (ListIter<value_t*> it(this->for_typed); !it.Done(); it.Next()) {
59 value_t* i1 = it.Value();
60 hnode_t* h = (i1 == nullptr) ? Alloc<hnode::Leaf>(StrFromC("_"),
61 color_e::OtherConst) : i1->PrettyTree(seen);
62 x1->children->append(h);
63 }
64 L->append(Alloc<Field>(StrFromC("for_typed"), x1));
65 }
66
67 if (this->for_named) { // Dict
68 auto m = Alloc<hnode::Leaf>(StrFromC("Dict"), color_e::OtherConst);
69 hnode::Array* x2 = Alloc<hnode::Array>(NewList<hnode_t*>({m}));
70 for (DictIter<BigStr*, value_t*> it(this->for_named); !it.Done();
71 it.Next()) {
72 auto k2 = it.Key();
73 auto v2 = it.Value();
74 x2->children->append(runtime::NewLeaf(k2, color_e::StringConst));
75 x2->children->append(v2->PrettyTree(seen));
76 }
77 L->append(Alloc<Field>(StrFromC ("for_named"), x2));
78 }
79
80 if (this->for_block) { // Optional
81 hnode_t* x3 = this->for_block->PrettyTree(seen);
82 L->append(Alloc<Field>(StrFromC("for_block"), x3));
83 }
84
85 return out_node;
86}
87
88
89hnode_t* LeftName::PrettyTree(Dict<int, bool>* seen) {
90 seen = seen ? seen : Alloc<Dict<int, bool>>();
91 int heap_id = ObjectId(this);
92 if (dict_contains(seen, heap_id)) {
93 return Alloc<hnode::AlreadySeen>(heap_id);
94 }
95 seen->set(heap_id, true);
96 hnode::Record* out_node = runtime::NewRecord(StrFromC("LeftName"));
97 List<Field*>* L = out_node->fields;
98
99 hnode_t* x0 = runtime::NewLeaf(this->name, color_e::StringConst);
100 L->append(Alloc<Field>(StrFromC("name"), x0));
101
102 hnode_t* x1 = this->blame_loc->PrettyTree(seen);
103 L->append(Alloc<Field>(StrFromC("blame_loc"), x1));
104
105 return out_node;
106}
107
108BigStr* y_lvalue_str(int tag, bool dot) {
109 char buf[32];
110 const char* v = nullptr;
111 switch (tag) {
112 case y_lvalue_e::Local:
113 v = "Local"; break;
114 case y_lvalue_e::Container:
115 v = "Container"; break;
116 default:
117 assert(0);
118 }
119 if (dot) {
120 snprintf(buf, 32, "y_lvalue.%s", v);
121 return StrFromC(buf);
122 } else {
123 return StrFromC(v);
124 }
125}
126
127hnode_t* y_lvalue__Container::PrettyTree(Dict<int, bool>* seen) {
128 seen = seen ? seen : Alloc<Dict<int, bool>>();
129 int heap_id = ObjectId(this);
130 if (dict_contains(seen, heap_id)) {
131 return Alloc<hnode::AlreadySeen>(heap_id);
132 }
133 seen->set(heap_id, true);
134 hnode::Record* out_node = runtime::NewRecord(y_lvalue_str(this->tag()));
135 List<Field*>* L = out_node->fields;
136
137 hnode_t* x0 = this->obj->PrettyTree(seen);
138 L->append(Alloc<Field>(StrFromC("obj"), x0));
139
140 hnode_t* x1 = this->index->PrettyTree(seen);
141 L->append(Alloc<Field>(StrFromC("index"), x1));
142
143 return out_node;
144}
145
146
147hnode_t* y_lvalue_t::PrettyTree(Dict<int, bool>* seen) {
148 switch (this->tag()) {
149 case y_lvalue_e::Local: {
150 LeftName* obj = static_cast<LeftName*>(this);
151 return obj->PrettyTree(seen);
152 }
153 case y_lvalue_e::Container: {
154 y_lvalue__Container* obj = static_cast<y_lvalue__Container*>(this);
155 return obj->PrettyTree(seen);
156 }
157 default:
158 assert(0);
159 }
160}
161BigStr* sh_lvalue_str(int tag, bool dot) {
162 char buf[32];
163 const char* v = nullptr;
164 switch (tag) {
165 case sh_lvalue_e::Var:
166 v = "Var"; break;
167 case sh_lvalue_e::Indexed:
168 v = "Indexed"; break;
169 case sh_lvalue_e::Keyed:
170 v = "Keyed"; break;
171 default:
172 assert(0);
173 }
174 if (dot) {
175 snprintf(buf, 32, "sh_lvalue.%s", v);
176 return StrFromC(buf);
177 } else {
178 return StrFromC(v);
179 }
180}
181
182hnode_t* sh_lvalue__Indexed::PrettyTree(Dict<int, bool>* seen) {
183 seen = seen ? seen : Alloc<Dict<int, bool>>();
184 int heap_id = ObjectId(this);
185 if (dict_contains(seen, heap_id)) {
186 return Alloc<hnode::AlreadySeen>(heap_id);
187 }
188 seen->set(heap_id, true);
189 hnode::Record* out_node = runtime::NewRecord(sh_lvalue_str(this->tag()));
190 List<Field*>* L = out_node->fields;
191
192 hnode_t* x0 = runtime::NewLeaf(this->name, color_e::StringConst);
193 L->append(Alloc<Field>(StrFromC("name"), x0));
194
195 hnode_t* x1 = Alloc<hnode::Leaf>(str(this->index), color_e::OtherConst);
196 L->append(Alloc<Field>(StrFromC("index"), x1));
197
198 hnode_t* x2 = this->blame_loc->PrettyTree(seen);
199 L->append(Alloc<Field>(StrFromC("blame_loc"), x2));
200
201 return out_node;
202}
203
204
205hnode_t* sh_lvalue__Keyed::PrettyTree(Dict<int, bool>* seen) {
206 seen = seen ? seen : Alloc<Dict<int, bool>>();
207 int heap_id = ObjectId(this);
208 if (dict_contains(seen, heap_id)) {
209 return Alloc<hnode::AlreadySeen>(heap_id);
210 }
211 seen->set(heap_id, true);
212 hnode::Record* out_node = runtime::NewRecord(sh_lvalue_str(this->tag()));
213 List<Field*>* L = out_node->fields;
214
215 hnode_t* x0 = runtime::NewLeaf(this->name, color_e::StringConst);
216 L->append(Alloc<Field>(StrFromC("name"), x0));
217
218 hnode_t* x1 = runtime::NewLeaf(this->key, color_e::StringConst);
219 L->append(Alloc<Field>(StrFromC("key"), x1));
220
221 hnode_t* x2 = this->blame_loc->PrettyTree(seen);
222 L->append(Alloc<Field>(StrFromC("blame_loc"), x2));
223
224 return out_node;
225}
226
227
228hnode_t* sh_lvalue_t::PrettyTree(Dict<int, bool>* seen) {
229 switch (this->tag()) {
230 case sh_lvalue_e::Var: {
231 LeftName* obj = static_cast<LeftName*>(this);
232 return obj->PrettyTree(seen);
233 }
234 case sh_lvalue_e::Indexed: {
235 sh_lvalue__Indexed* obj = static_cast<sh_lvalue__Indexed*>(this);
236 return obj->PrettyTree(seen);
237 }
238 case sh_lvalue_e::Keyed: {
239 sh_lvalue__Keyed* obj = static_cast<sh_lvalue__Keyed*>(this);
240 return obj->PrettyTree(seen);
241 }
242 default:
243 assert(0);
244 }
245}
246BigStr* eggex_ops_str(int tag, bool dot) {
247 char buf[32];
248 const char* v = nullptr;
249 switch (tag) {
250 case eggex_ops_e::No:
251 v = "No"; break;
252 case eggex_ops_e::Yes:
253 v = "Yes"; break;
254 default:
255 assert(0);
256 }
257 if (dot) {
258 snprintf(buf, 32, "eggex_ops.%s", v);
259 return StrFromC(buf);
260 } else {
261 return StrFromC(v);
262 }
263}
264
265eggex_ops__No* eggex_ops::No = &geggex_ops__No.obj;
266
267GcGlobal<eggex_ops__No> geggex_ops__No =
268 { ObjHeader::Global(eggex_ops_e::No) };
269
270hnode_t* eggex_ops__No::PrettyTree(Dict<int, bool>* seen) {
271 seen = seen ? seen : Alloc<Dict<int, bool>>();
272 int heap_id = ObjectId(this);
273 if (dict_contains(seen, heap_id)) {
274 return Alloc<hnode::AlreadySeen>(heap_id);
275 }
276 seen->set(heap_id, true);
277 hnode::Record* out_node = runtime::NewRecord(eggex_ops_str(this->tag()));
278 return out_node;
279}
280
281
282hnode_t* eggex_ops__Yes::PrettyTree(Dict<int, bool>* seen) {
283 seen = seen ? seen : Alloc<Dict<int, bool>>();
284 int heap_id = ObjectId(this);
285 if (dict_contains(seen, heap_id)) {
286 return Alloc<hnode::AlreadySeen>(heap_id);
287 }
288 seen->set(heap_id, true);
289 hnode::Record* out_node = runtime::NewRecord(eggex_ops_str(this->tag()));
290 List<Field*>* L = out_node->fields;
291
292 if (this->convert_funcs != nullptr) { // List
293 hnode::Array* x0 = Alloc<hnode::Array>(Alloc<List<hnode_t*>>());
294 for (ListIter<value_t*> it(this->convert_funcs); !it.Done(); it.Next()) {
295 value_t* i0 = it.Value();
296 hnode_t* h = (i0 == nullptr) ? Alloc<hnode::Leaf>(StrFromC("_"),
297 color_e::OtherConst) : i0->PrettyTree(seen);
298 x0->children->append(h);
299 }
300 L->append(Alloc<Field>(StrFromC("convert_funcs"), x0));
301 }
302
303 if (this->convert_toks != nullptr) { // List
304 hnode::Array* x1 = Alloc<hnode::Array>(Alloc<List<hnode_t*>>());
305 for (ListIter<syntax_asdl::Token*> it(this->convert_toks); !it.Done();
306 it.Next()) {
307 syntax_asdl::Token* i1 = it.Value();
308 hnode_t* h = (i1 == nullptr) ? Alloc<hnode::Leaf>(StrFromC("_"),
309 color_e::OtherConst) : i1->PrettyTree(seen);
310 x1->children->append(h);
311 }
312 L->append(Alloc<Field>(StrFromC("convert_toks"), x1));
313 }
314
315 if (this->capture_names != nullptr) { // List
316 hnode::Array* x2 = Alloc<hnode::Array>(Alloc<List<hnode_t*>>());
317 for (ListIter<BigStr*> it(this->capture_names); !it.Done(); it.Next()) {
318 BigStr* i2 = it.Value();
319 x2->children->append(runtime::NewLeaf(i2, color_e::StringConst));
320 }
321 L->append(Alloc<Field>(StrFromC("capture_names"), x2));
322 }
323
324 return out_node;
325}
326
327
328hnode_t* eggex_ops_t::PrettyTree(Dict<int, bool>* seen) {
329 switch (this->tag()) {
330 case eggex_ops_e::No: {
331 eggex_ops__No* obj = static_cast<eggex_ops__No*>(this);
332 return obj->PrettyTree(seen);
333 }
334 case eggex_ops_e::Yes: {
335 eggex_ops__Yes* obj = static_cast<eggex_ops__Yes*>(this);
336 return obj->PrettyTree(seen);
337 }
338 default:
339 assert(0);
340 }
341}
342
343hnode_t* RegexMatch::PrettyTree(Dict<int, bool>* seen) {
344 seen = seen ? seen : Alloc<Dict<int, bool>>();
345 int heap_id = ObjectId(this);
346 if (dict_contains(seen, heap_id)) {
347 return Alloc<hnode::AlreadySeen>(heap_id);
348 }
349 seen->set(heap_id, true);
350 hnode::Record* out_node = runtime::NewRecord(StrFromC("RegexMatch"));
351 List<Field*>* L = out_node->fields;
352
353 hnode_t* x0 = runtime::NewLeaf(this->s, color_e::StringConst);
354 L->append(Alloc<Field>(StrFromC("s"), x0));
355
356 if (this->indices != nullptr) { // List
357 hnode::Array* x1 = Alloc<hnode::Array>(Alloc<List<hnode_t*>>());
358 for (ListIter<int> it(this->indices); !it.Done(); it.Next()) {
359 int i1 = it.Value();
360 x1->children->append(Alloc<hnode::Leaf>(str(i1), color_e::OtherConst));
361 }
362 L->append(Alloc<Field>(StrFromC("indices"), x1));
363 }
364
365 hnode_t* x2 = this->ops->PrettyTree(seen);
366 L->append(Alloc<Field>(StrFromC("ops"), x2));
367
368 return out_node;
369}
370
371BigStr* regex_match_str(int tag, bool dot) {
372 char buf[32];
373 const char* v = nullptr;
374 switch (tag) {
375 case regex_match_e::No:
376 v = "No"; break;
377 case regex_match_e::Yes:
378 v = "Yes"; break;
379 default:
380 assert(0);
381 }
382 if (dot) {
383 snprintf(buf, 32, "regex_match.%s", v);
384 return StrFromC(buf);
385 } else {
386 return StrFromC(v);
387 }
388}
389
390regex_match__No* regex_match::No = &gregex_match__No.obj;
391
392GcGlobal<regex_match__No> gregex_match__No =
393 { ObjHeader::Global(regex_match_e::No) };
394
395hnode_t* regex_match__No::PrettyTree(Dict<int, bool>* seen) {
396 seen = seen ? seen : Alloc<Dict<int, bool>>();
397 int heap_id = ObjectId(this);
398 if (dict_contains(seen, heap_id)) {
399 return Alloc<hnode::AlreadySeen>(heap_id);
400 }
401 seen->set(heap_id, true);
402 hnode::Record* out_node = runtime::NewRecord(regex_match_str(this->tag()));
403 return out_node;
404}
405
406
407hnode_t* regex_match_t::PrettyTree(Dict<int, bool>* seen) {
408 switch (this->tag()) {
409 case regex_match_e::No: {
410 regex_match__No* obj = static_cast<regex_match__No*>(this);
411 return obj->PrettyTree(seen);
412 }
413 case regex_match_e::Yes: {
414 RegexMatch* obj = static_cast<RegexMatch*>(this);
415 return obj->PrettyTree(seen);
416 }
417 default:
418 assert(0);
419 }
420}
421BigStr* value_str(int tag, bool dot) {
422 char buf[32];
423 const char* v = nullptr;
424 switch (tag) {
425 case value_e::Undef:
426 v = "Undef"; break;
427 case value_e::Str:
428 v = "Str"; break;
429 case value_e::BashArray:
430 v = "BashArray"; break;
431 case value_e::BashAssoc:
432 v = "BashAssoc"; break;
433 case value_e::Null:
434 v = "Null"; break;
435 case value_e::Bool:
436 v = "Bool"; break;
437 case value_e::Int:
438 v = "Int"; break;
439 case value_e::Float:
440 v = "Float"; break;
441 case value_e::List:
442 v = "List"; break;
443 case value_e::Dict:
444 v = "Dict"; break;
445 case value_e::Eggex:
446 v = "Eggex"; break;
447 case value_e::Match:
448 v = "Match"; break;
449 case value_e::Expr:
450 v = "Expr"; break;
451 case value_e::Template:
452 v = "Template"; break;
453 case value_e::Command:
454 v = "Command"; break;
455 case value_e::Block:
456 v = "Block"; break;
457 case value_e::Place:
458 v = "Place"; break;
459 case value_e::Module:
460 v = "Module"; break;
461 case value_e::IO:
462 v = "IO"; break;
463 case value_e::Guts:
464 v = "Guts"; break;
465 case value_e::BuiltinFunc:
466 v = "BuiltinFunc"; break;
467 case value_e::BoundFunc:
468 v = "BoundFunc"; break;
469 case value_e::Proc:
470 v = "Proc"; break;
471 case value_e::Func:
472 v = "Func"; break;
473 case value_e::Slice:
474 v = "Slice"; break;
475 case value_e::Range:
476 v = "Range"; break;
477 default:
478 assert(0);
479 }
480 if (dot) {
481 snprintf(buf, 32, "value.%s", v);
482 return StrFromC(buf);
483 } else {
484 return StrFromC(v);
485 }
486}
487
488value__Undef* value::Undef = &gvalue__Undef.obj;
489
490GcGlobal<value__Undef> gvalue__Undef =
491 { ObjHeader::Global(value_e::Undef) };
492
493value__Null* value::Null = &gvalue__Null.obj;
494
495GcGlobal<value__Null> gvalue__Null =
496 { ObjHeader::Global(value_e::Null) };
497
498hnode_t* value__Undef::PrettyTree(Dict<int, bool>* seen) {
499 seen = seen ? seen : Alloc<Dict<int, bool>>();
500 int heap_id = ObjectId(this);
501 if (dict_contains(seen, heap_id)) {
502 return Alloc<hnode::AlreadySeen>(heap_id);
503 }
504 seen->set(heap_id, true);
505 hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
506 return out_node;
507}
508
509
510hnode_t* value__Str::PrettyTree(Dict<int, bool>* seen) {
511 seen = seen ? seen : Alloc<Dict<int, bool>>();
512 int heap_id = ObjectId(this);
513 if (dict_contains(seen, heap_id)) {
514 return Alloc<hnode::AlreadySeen>(heap_id);
515 }
516 seen->set(heap_id, true);
517 hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
518 List<Field*>* L = out_node->fields;
519
520 hnode_t* x0 = runtime::NewLeaf(this->s, color_e::StringConst);
521 L->append(Alloc<Field>(StrFromC("s"), x0));
522
523 return out_node;
524}
525
526
527hnode_t* value__BashArray::PrettyTree(Dict<int, bool>* seen) {
528 seen = seen ? seen : Alloc<Dict<int, bool>>();
529 int heap_id = ObjectId(this);
530 if (dict_contains(seen, heap_id)) {
531 return Alloc<hnode::AlreadySeen>(heap_id);
532 }
533 seen->set(heap_id, true);
534 hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
535 List<Field*>* L = out_node->fields;
536
537 if (this->strs != nullptr) { // List
538 hnode::Array* x0 = Alloc<hnode::Array>(Alloc<List<hnode_t*>>());
539 for (ListIter<BigStr*> it(this->strs); !it.Done(); it.Next()) {
540 BigStr* i0 = it.Value();
541 x0->children->append(runtime::NewLeaf(i0, color_e::StringConst));
542 }
543 L->append(Alloc<Field>(StrFromC("strs"), x0));
544 }
545
546 return out_node;
547}
548
549
550hnode_t* value__BashAssoc::PrettyTree(Dict<int, bool>* seen) {
551 seen = seen ? seen : Alloc<Dict<int, bool>>();
552 int heap_id = ObjectId(this);
553 if (dict_contains(seen, heap_id)) {
554 return Alloc<hnode::AlreadySeen>(heap_id);
555 }
556 seen->set(heap_id, true);
557 hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
558 List<Field*>* L = out_node->fields;
559
560 if (this->d) { // Dict
561 auto m = Alloc<hnode::Leaf>(StrFromC("Dict"), color_e::OtherConst);
562 hnode::Array* x0 = Alloc<hnode::Array>(NewList<hnode_t*>({m}));
563 for (DictIter<BigStr*, BigStr*> it(this->d); !it.Done(); it.Next()) {
564 auto k0 = it.Key();
565 auto v0 = it.Value();
566 x0->children->append(runtime::NewLeaf(k0, color_e::StringConst));
567 x0->children->append(runtime::NewLeaf(v0, color_e::StringConst));
568 }
569 L->append(Alloc<Field>(StrFromC ("d"), x0));
570 }
571
572 return out_node;
573}
574
575
576hnode_t* value__Null::PrettyTree(Dict<int, bool>* seen) {
577 seen = seen ? seen : Alloc<Dict<int, bool>>();
578 int heap_id = ObjectId(this);
579 if (dict_contains(seen, heap_id)) {
580 return Alloc<hnode::AlreadySeen>(heap_id);
581 }
582 seen->set(heap_id, true);
583 hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
584 return out_node;
585}
586
587
588hnode_t* value__Bool::PrettyTree(Dict<int, bool>* seen) {
589 seen = seen ? seen : Alloc<Dict<int, bool>>();
590 int heap_id = ObjectId(this);
591 if (dict_contains(seen, heap_id)) {
592 return Alloc<hnode::AlreadySeen>(heap_id);
593 }
594 seen->set(heap_id, true);
595 hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
596 List<Field*>* L = out_node->fields;
597
598 hnode_t* x0 = Alloc<hnode::Leaf>(this->b ? runtime::TRUE_STR :
599 runtime::FALSE_STR, color_e::OtherConst);
600 L->append(Alloc<Field>(StrFromC("b"), x0));
601
602 return out_node;
603}
604
605
606hnode_t* value__Int::PrettyTree(Dict<int, bool>* seen) {
607 seen = seen ? seen : Alloc<Dict<int, bool>>();
608 int heap_id = ObjectId(this);
609 if (dict_contains(seen, heap_id)) {
610 return Alloc<hnode::AlreadySeen>(heap_id);
611 }
612 seen->set(heap_id, true);
613 hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
614 List<Field*>* L = out_node->fields;
615
616 hnode_t* x0 = Alloc<hnode::Leaf>(mops::ToStr(this->i), color_e::OtherConst);
617 L->append(Alloc<Field>(StrFromC("i"), x0));
618
619 return out_node;
620}
621
622
623hnode_t* value__Float::PrettyTree(Dict<int, bool>* seen) {
624 seen = seen ? seen : Alloc<Dict<int, bool>>();
625 int heap_id = ObjectId(this);
626 if (dict_contains(seen, heap_id)) {
627 return Alloc<hnode::AlreadySeen>(heap_id);
628 }
629 seen->set(heap_id, true);
630 hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
631 List<Field*>* L = out_node->fields;
632
633 hnode_t* x0 = Alloc<hnode::Leaf>(str(this->f), color_e::OtherConst);
634 L->append(Alloc<Field>(StrFromC("f"), x0));
635
636 return out_node;
637}
638
639
640hnode_t* value__List::PrettyTree(Dict<int, bool>* seen) {
641 seen = seen ? seen : Alloc<Dict<int, bool>>();
642 int heap_id = ObjectId(this);
643 if (dict_contains(seen, heap_id)) {
644 return Alloc<hnode::AlreadySeen>(heap_id);
645 }
646 seen->set(heap_id, true);
647 hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
648 List<Field*>* L = out_node->fields;
649
650 if (this->items != nullptr) { // List
651 hnode::Array* x0 = Alloc<hnode::Array>(Alloc<List<hnode_t*>>());
652 for (ListIter<value_t*> it(this->items); !it.Done(); it.Next()) {
653 value_t* i0 = it.Value();
654 hnode_t* h = (i0 == nullptr) ? Alloc<hnode::Leaf>(StrFromC("_"),
655 color_e::OtherConst) : i0->PrettyTree(seen);
656 x0->children->append(h);
657 }
658 L->append(Alloc<Field>(StrFromC("items"), x0));
659 }
660
661 return out_node;
662}
663
664
665hnode_t* value__Dict::PrettyTree(Dict<int, bool>* seen) {
666 seen = seen ? seen : Alloc<Dict<int, bool>>();
667 int heap_id = ObjectId(this);
668 if (dict_contains(seen, heap_id)) {
669 return Alloc<hnode::AlreadySeen>(heap_id);
670 }
671 seen->set(heap_id, true);
672 hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
673 List<Field*>* L = out_node->fields;
674
675 if (this->d) { // Dict
676 auto m = Alloc<hnode::Leaf>(StrFromC("Dict"), color_e::OtherConst);
677 hnode::Array* x0 = Alloc<hnode::Array>(NewList<hnode_t*>({m}));
678 for (DictIter<BigStr*, value_t*> it(this->d); !it.Done(); it.Next()) {
679 auto k0 = it.Key();
680 auto v0 = it.Value();
681 x0->children->append(runtime::NewLeaf(k0, color_e::StringConst));
682 x0->children->append(v0->PrettyTree(seen));
683 }
684 L->append(Alloc<Field>(StrFromC ("d"), x0));
685 }
686
687 return out_node;
688}
689
690
691hnode_t* value__Eggex::PrettyTree(Dict<int, bool>* seen) {
692 seen = seen ? seen : Alloc<Dict<int, bool>>();
693 int heap_id = ObjectId(this);
694 if (dict_contains(seen, heap_id)) {
695 return Alloc<hnode::AlreadySeen>(heap_id);
696 }
697 seen->set(heap_id, true);
698 hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
699 List<Field*>* L = out_node->fields;
700
701 hnode_t* x0 = this->spliced->PrettyTree(seen);
702 L->append(Alloc<Field>(StrFromC("spliced"), x0));
703
704 hnode_t* x1 = runtime::NewLeaf(this->canonical_flags, color_e::StringConst);
705 L->append(Alloc<Field>(StrFromC("canonical_flags"), x1));
706
707 if (this->convert_funcs != nullptr) { // List
708 hnode::Array* x2 = Alloc<hnode::Array>(Alloc<List<hnode_t*>>());
709 for (ListIter<value_t*> it(this->convert_funcs); !it.Done(); it.Next()) {
710 value_t* i2 = it.Value();
711 hnode_t* h = (i2 == nullptr) ? Alloc<hnode::Leaf>(StrFromC("_"),
712 color_e::OtherConst) : i2->PrettyTree(seen);
713 x2->children->append(h);
714 }
715 L->append(Alloc<Field>(StrFromC("convert_funcs"), x2));
716 }
717
718 if (this->convert_toks != nullptr) { // List
719 hnode::Array* x3 = Alloc<hnode::Array>(Alloc<List<hnode_t*>>());
720 for (ListIter<syntax_asdl::Token*> it(this->convert_toks); !it.Done();
721 it.Next()) {
722 syntax_asdl::Token* i3 = it.Value();
723 hnode_t* h = (i3 == nullptr) ? Alloc<hnode::Leaf>(StrFromC("_"),
724 color_e::OtherConst) : i3->PrettyTree(seen);
725 x3->children->append(h);
726 }
727 L->append(Alloc<Field>(StrFromC("convert_toks"), x3));
728 }
729
730 if (this->as_ere) { // Optional
731 hnode_t* x4 = runtime::NewLeaf(this->as_ere, color_e::StringConst);
732 L->append(Alloc<Field>(StrFromC("as_ere"), x4));
733 }
734
735 if (this->capture_names != nullptr) { // List
736 hnode::Array* x5 = Alloc<hnode::Array>(Alloc<List<hnode_t*>>());
737 for (ListIter<BigStr*> it(this->capture_names); !it.Done(); it.Next()) {
738 BigStr* i5 = it.Value();
739 x5->children->append(runtime::NewLeaf(i5, color_e::StringConst));
740 }
741 L->append(Alloc<Field>(StrFromC("capture_names"), x5));
742 }
743
744 return out_node;
745}
746
747
748hnode_t* value__Expr::PrettyTree(Dict<int, bool>* seen) {
749 seen = seen ? seen : Alloc<Dict<int, bool>>();
750 int heap_id = ObjectId(this);
751 if (dict_contains(seen, heap_id)) {
752 return Alloc<hnode::AlreadySeen>(heap_id);
753 }
754 seen->set(heap_id, true);
755 hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
756 List<Field*>* L = out_node->fields;
757
758 hnode_t* x0 = this->e->PrettyTree(seen);
759 L->append(Alloc<Field>(StrFromC("e"), x0));
760
761 return out_node;
762}
763
764
765hnode_t* value__Template::PrettyTree(Dict<int, bool>* seen) {
766 seen = seen ? seen : Alloc<Dict<int, bool>>();
767 int heap_id = ObjectId(this);
768 if (dict_contains(seen, heap_id)) {
769 return Alloc<hnode::AlreadySeen>(heap_id);
770 }
771 seen->set(heap_id, true);
772 hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
773 List<Field*>* L = out_node->fields;
774
775 hnode_t* x0 = this->dq->PrettyTree(seen);
776 L->append(Alloc<Field>(StrFromC("dq"), x0));
777
778 return out_node;
779}
780
781
782hnode_t* value__Command::PrettyTree(Dict<int, bool>* seen) {
783 seen = seen ? seen : Alloc<Dict<int, bool>>();
784 int heap_id = ObjectId(this);
785 if (dict_contains(seen, heap_id)) {
786 return Alloc<hnode::AlreadySeen>(heap_id);
787 }
788 seen->set(heap_id, true);
789 hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
790 List<Field*>* L = out_node->fields;
791
792 hnode_t* x0 = this->c->PrettyTree(seen);
793 L->append(Alloc<Field>(StrFromC("c"), x0));
794
795 return out_node;
796}
797
798
799hnode_t* value__Block::PrettyTree(Dict<int, bool>* seen) {
800 seen = seen ? seen : Alloc<Dict<int, bool>>();
801 int heap_id = ObjectId(this);
802 if (dict_contains(seen, heap_id)) {
803 return Alloc<hnode::AlreadySeen>(heap_id);
804 }
805 seen->set(heap_id, true);
806 hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
807 List<Field*>* L = out_node->fields;
808
809 hnode_t* x0 = this->block->PrettyTree(seen);
810 L->append(Alloc<Field>(StrFromC("block"), x0));
811
812 return out_node;
813}
814
815
816hnode_t* value__Place::PrettyTree(Dict<int, bool>* seen) {
817 seen = seen ? seen : Alloc<Dict<int, bool>>();
818 int heap_id = ObjectId(this);
819 if (dict_contains(seen, heap_id)) {
820 return Alloc<hnode::AlreadySeen>(heap_id);
821 }
822 seen->set(heap_id, true);
823 hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
824 List<Field*>* L = out_node->fields;
825
826 hnode_t* x0 = this->lval->PrettyTree(seen);
827 L->append(Alloc<Field>(StrFromC("lval"), x0));
828
829 if (this->frame) { // Dict
830 auto m = Alloc<hnode::Leaf>(StrFromC("Dict"), color_e::OtherConst);
831 hnode::Array* x1 = Alloc<hnode::Array>(NewList<hnode_t*>({m}));
832 for (DictIter<BigStr*, runtime_asdl::Cell*> it(this->frame); !it.Done();
833 it.Next()) {
834 auto k1 = it.Key();
835 auto v1 = it.Value();
836 x1->children->append(runtime::NewLeaf(k1, color_e::StringConst));
837 x1->children->append(v1->PrettyTree(seen));
838 }
839 L->append(Alloc<Field>(StrFromC ("frame"), x1));
840 }
841
842 return out_node;
843}
844
845
846hnode_t* value__Module::PrettyTree(Dict<int, bool>* seen) {
847 seen = seen ? seen : Alloc<Dict<int, bool>>();
848 int heap_id = ObjectId(this);
849 if (dict_contains(seen, heap_id)) {
850 return Alloc<hnode::AlreadySeen>(heap_id);
851 }
852 seen->set(heap_id, true);
853 hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
854 List<Field*>* L = out_node->fields;
855
856 if (this->defs) { // Dict
857 auto m = Alloc<hnode::Leaf>(StrFromC("Dict"), color_e::OtherConst);
858 hnode::Array* x0 = Alloc<hnode::Array>(NewList<hnode_t*>({m}));
859 for (DictIter<BigStr*, value_t*> it(this->defs); !it.Done(); it.Next()) {
860 auto k0 = it.Key();
861 auto v0 = it.Value();
862 x0->children->append(runtime::NewLeaf(k0, color_e::StringConst));
863 x0->children->append(v0->PrettyTree(seen));
864 }
865 L->append(Alloc<Field>(StrFromC ("defs"), x0));
866 }
867
868 return out_node;
869}
870
871
872hnode_t* value__IO::PrettyTree(Dict<int, bool>* seen) {
873 seen = seen ? seen : Alloc<Dict<int, bool>>();
874 int heap_id = ObjectId(this);
875 if (dict_contains(seen, heap_id)) {
876 return Alloc<hnode::AlreadySeen>(heap_id);
877 }
878 seen->set(heap_id, true);
879 hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
880 List<Field*>* L = out_node->fields;
881
882 hnode_t* x0 = Alloc<hnode::External>(this->cmd_ev);
883 L->append(Alloc<Field>(StrFromC("cmd_ev"), x0));
884
885 hnode_t* x1 = Alloc<hnode::External>(this->prompt_ev);
886 L->append(Alloc<Field>(StrFromC("prompt_ev"), x1));
887
888 return out_node;
889}
890
891
892hnode_t* value__Guts::PrettyTree(Dict<int, bool>* seen) {
893 seen = seen ? seen : Alloc<Dict<int, bool>>();
894 int heap_id = ObjectId(this);
895 if (dict_contains(seen, heap_id)) {
896 return Alloc<hnode::AlreadySeen>(heap_id);
897 }
898 seen->set(heap_id, true);
899 hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
900 List<Field*>* L = out_node->fields;
901
902 hnode_t* x0 = Alloc<hnode::External>(this->vm);
903 L->append(Alloc<Field>(StrFromC("vm"), x0));
904
905 return out_node;
906}
907
908
909hnode_t* value__BuiltinFunc::PrettyTree(Dict<int, bool>* seen) {
910 seen = seen ? seen : Alloc<Dict<int, bool>>();
911 int heap_id = ObjectId(this);
912 if (dict_contains(seen, heap_id)) {
913 return Alloc<hnode::AlreadySeen>(heap_id);
914 }
915 seen->set(heap_id, true);
916 hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
917 List<Field*>* L = out_node->fields;
918
919 hnode_t* x0 = Alloc<hnode::External>(this->callable);
920 L->append(Alloc<Field>(StrFromC("callable"), x0));
921
922 return out_node;
923}
924
925
926hnode_t* value__BoundFunc::PrettyTree(Dict<int, bool>* seen) {
927 seen = seen ? seen : Alloc<Dict<int, bool>>();
928 int heap_id = ObjectId(this);
929 if (dict_contains(seen, heap_id)) {
930 return Alloc<hnode::AlreadySeen>(heap_id);
931 }
932 seen->set(heap_id, true);
933 hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
934 List<Field*>* L = out_node->fields;
935
936 hnode_t* x0 = this->me->PrettyTree(seen);
937 L->append(Alloc<Field>(StrFromC("me"), x0));
938
939 hnode_t* x1 = this->func->PrettyTree(seen);
940 L->append(Alloc<Field>(StrFromC("func"), x1));
941
942 return out_node;
943}
944
945
946hnode_t* value__Proc::PrettyTree(Dict<int, bool>* seen) {
947 seen = seen ? seen : Alloc<Dict<int, bool>>();
948 int heap_id = ObjectId(this);
949 if (dict_contains(seen, heap_id)) {
950 return Alloc<hnode::AlreadySeen>(heap_id);
951 }
952 seen->set(heap_id, true);
953 hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
954 List<Field*>* L = out_node->fields;
955
956 hnode_t* x0 = runtime::NewLeaf(this->name, color_e::StringConst);
957 L->append(Alloc<Field>(StrFromC("name"), x0));
958
959 hnode_t* x1 = this->name_tok->PrettyTree(seen);
960 L->append(Alloc<Field>(StrFromC("name_tok"), x1));
961
962 hnode_t* x2 = this->sig->PrettyTree(seen);
963 L->append(Alloc<Field>(StrFromC("sig"), x2));
964
965 hnode_t* x3 = this->body->PrettyTree(seen);
966 L->append(Alloc<Field>(StrFromC("body"), x3));
967
968 if (this->defaults) { // Optional
969 hnode_t* x4 = this->defaults->PrettyTree(seen);
970 L->append(Alloc<Field>(StrFromC("defaults"), x4));
971 }
972
973 hnode_t* x5 = Alloc<hnode::Leaf>(this->sh_compat ? runtime::TRUE_STR :
974 runtime::FALSE_STR, color_e::OtherConst);
975 L->append(Alloc<Field>(StrFromC("sh_compat"), x5));
976
977 return out_node;
978}
979
980
981hnode_t* value__Func::PrettyTree(Dict<int, bool>* seen) {
982 seen = seen ? seen : Alloc<Dict<int, bool>>();
983 int heap_id = ObjectId(this);
984 if (dict_contains(seen, heap_id)) {
985 return Alloc<hnode::AlreadySeen>(heap_id);
986 }
987 seen->set(heap_id, true);
988 hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
989 List<Field*>* L = out_node->fields;
990
991 hnode_t* x0 = runtime::NewLeaf(this->name, color_e::StringConst);
992 L->append(Alloc<Field>(StrFromC("name"), x0));
993
994 hnode_t* x1 = this->parsed->PrettyTree(seen);
995 L->append(Alloc<Field>(StrFromC("parsed"), x1));
996
997 if (this->pos_defaults != nullptr) { // List
998 hnode::Array* x2 = Alloc<hnode::Array>(Alloc<List<hnode_t*>>());
999 for (ListIter<value_t*> it(this->pos_defaults); !it.Done(); it.Next()) {
1000 value_t* i2 = it.Value();
1001 hnode_t* h = (i2 == nullptr) ? Alloc<hnode::Leaf>(StrFromC("_"),
1002 color_e::OtherConst) : i2->PrettyTree(seen);
1003 x2->children->append(h);
1004 }
1005 L->append(Alloc<Field>(StrFromC("pos_defaults"), x2));
1006 }
1007
1008 if (this->named_defaults) { // Dict
1009 auto m = Alloc<hnode::Leaf>(StrFromC("Dict"), color_e::OtherConst);
1010 hnode::Array* x3 = Alloc<hnode::Array>(NewList<hnode_t*>({m}));
1011 for (DictIter<BigStr*, value_t*> it(this->named_defaults); !it.Done();
1012 it.Next()) {
1013 auto k3 = it.Key();
1014 auto v3 = it.Value();
1015 x3->children->append(runtime::NewLeaf(k3, color_e::StringConst));
1016 x3->children->append(v3->PrettyTree(seen));
1017 }
1018 L->append(Alloc<Field>(StrFromC ("named_defaults"), x3));
1019 }
1020
1021 if (this->module_) { // Dict
1022 auto m = Alloc<hnode::Leaf>(StrFromC("Dict"), color_e::OtherConst);
1023 hnode::Array* x4 = Alloc<hnode::Array>(NewList<hnode_t*>({m}));
1024 for (DictIter<BigStr*, runtime_asdl::Cell*> it(this->module_); !it.Done();
1025 it.Next()) {
1026 auto k4 = it.Key();
1027 auto v4 = it.Value();
1028 x4->children->append(runtime::NewLeaf(k4, color_e::StringConst));
1029 x4->children->append(v4->PrettyTree(seen));
1030 }
1031 L->append(Alloc<Field>(StrFromC ("module_"), x4));
1032 }
1033
1034 return out_node;
1035}
1036
1037
1038hnode_t* value__Slice::PrettyTree(Dict<int, bool>* seen) {
1039 seen = seen ? seen : Alloc<Dict<int, bool>>();
1040 int heap_id = ObjectId(this);
1041 if (dict_contains(seen, heap_id)) {
1042 return Alloc<hnode::AlreadySeen>(heap_id);
1043 }
1044 seen->set(heap_id, true);
1045 hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
1046 List<Field*>* L = out_node->fields;
1047
1048 if (this->lower) { // Optional
1049 hnode_t* x0 = this->lower->PrettyTree(seen);
1050 L->append(Alloc<Field>(StrFromC("lower"), x0));
1051 }
1052
1053 if (this->upper) { // Optional
1054 hnode_t* x1 = this->upper->PrettyTree(seen);
1055 L->append(Alloc<Field>(StrFromC("upper"), x1));
1056 }
1057
1058 return out_node;
1059}
1060
1061
1062hnode_t* value__Range::PrettyTree(Dict<int, bool>* seen) {
1063 seen = seen ? seen : Alloc<Dict<int, bool>>();
1064 int heap_id = ObjectId(this);
1065 if (dict_contains(seen, heap_id)) {
1066 return Alloc<hnode::AlreadySeen>(heap_id);
1067 }
1068 seen->set(heap_id, true);
1069 hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
1070 List<Field*>* L = out_node->fields;
1071
1072 hnode_t* x0 = Alloc<hnode::Leaf>(str(this->lower), color_e::OtherConst);
1073 L->append(Alloc<Field>(StrFromC("lower"), x0));
1074
1075 hnode_t* x1 = Alloc<hnode::Leaf>(str(this->upper), color_e::OtherConst);
1076 L->append(Alloc<Field>(StrFromC("upper"), x1));
1077
1078 return out_node;
1079}
1080
1081
1082hnode_t* value_t::PrettyTree(Dict<int, bool>* seen) {
1083 switch (this->tag()) {
1084 case value_e::Undef: {
1085 value__Undef* obj = static_cast<value__Undef*>(this);
1086 return obj->PrettyTree(seen);
1087 }
1088 case value_e::Str: {
1089 value__Str* obj = static_cast<value__Str*>(this);
1090 return obj->PrettyTree(seen);
1091 }
1092 case value_e::BashArray: {
1093 value__BashArray* obj = static_cast<value__BashArray*>(this);
1094 return obj->PrettyTree(seen);
1095 }
1096 case value_e::BashAssoc: {
1097 value__BashAssoc* obj = static_cast<value__BashAssoc*>(this);
1098 return obj->PrettyTree(seen);
1099 }
1100 case value_e::Null: {
1101 value__Null* obj = static_cast<value__Null*>(this);
1102 return obj->PrettyTree(seen);
1103 }
1104 case value_e::Bool: {
1105 value__Bool* obj = static_cast<value__Bool*>(this);
1106 return obj->PrettyTree(seen);
1107 }
1108 case value_e::Int: {
1109 value__Int* obj = static_cast<value__Int*>(this);
1110 return obj->PrettyTree(seen);
1111 }
1112 case value_e::Float: {
1113 value__Float* obj = static_cast<value__Float*>(this);
1114 return obj->PrettyTree(seen);
1115 }
1116 case value_e::List: {
1117 value__List* obj = static_cast<value__List*>(this);
1118 return obj->PrettyTree(seen);
1119 }
1120 case value_e::Dict: {
1121 value__Dict* obj = static_cast<value__Dict*>(this);
1122 return obj->PrettyTree(seen);
1123 }
1124 case value_e::Eggex: {
1125 value__Eggex* obj = static_cast<value__Eggex*>(this);
1126 return obj->PrettyTree(seen);
1127 }
1128 case value_e::Match: {
1129 RegexMatch* obj = static_cast<RegexMatch*>(this);
1130 return obj->PrettyTree(seen);
1131 }
1132 case value_e::Expr: {
1133 value__Expr* obj = static_cast<value__Expr*>(this);
1134 return obj->PrettyTree(seen);
1135 }
1136 case value_e::Template: {
1137 value__Template* obj = static_cast<value__Template*>(this);
1138 return obj->PrettyTree(seen);
1139 }
1140 case value_e::Command: {
1141 value__Command* obj = static_cast<value__Command*>(this);
1142 return obj->PrettyTree(seen);
1143 }
1144 case value_e::Block: {
1145 value__Block* obj = static_cast<value__Block*>(this);
1146 return obj->PrettyTree(seen);
1147 }
1148 case value_e::Place: {
1149 value__Place* obj = static_cast<value__Place*>(this);
1150 return obj->PrettyTree(seen);
1151 }
1152 case value_e::Module: {
1153 value__Module* obj = static_cast<value__Module*>(this);
1154 return obj->PrettyTree(seen);
1155 }
1156 case value_e::IO: {
1157 value__IO* obj = static_cast<value__IO*>(this);
1158 return obj->PrettyTree(seen);
1159 }
1160 case value_e::Guts: {
1161 value__Guts* obj = static_cast<value__Guts*>(this);
1162 return obj->PrettyTree(seen);
1163 }
1164 case value_e::BuiltinFunc: {
1165 value__BuiltinFunc* obj = static_cast<value__BuiltinFunc*>(this);
1166 return obj->PrettyTree(seen);
1167 }
1168 case value_e::BoundFunc: {
1169 value__BoundFunc* obj = static_cast<value__BoundFunc*>(this);
1170 return obj->PrettyTree(seen);
1171 }
1172 case value_e::Proc: {
1173 value__Proc* obj = static_cast<value__Proc*>(this);
1174 return obj->PrettyTree(seen);
1175 }
1176 case value_e::Func: {
1177 value__Func* obj = static_cast<value__Func*>(this);
1178 return obj->PrettyTree(seen);
1179 }
1180 case value_e::Slice: {
1181 value__Slice* obj = static_cast<value__Slice*>(this);
1182 return obj->PrettyTree(seen);
1183 }
1184 case value_e::Range: {
1185 value__Range* obj = static_cast<value__Range*>(this);
1186 return obj->PrettyTree(seen);
1187 }
1188 default:
1189 assert(0);
1190 }
1191}
1192
1193} // namespace value_asdl