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

1413 lines, 996 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 hnode_t* h = runtime::NewLeaf(i2, color_e::StringConst);
320 x2->children->append(h);
321 }
322 L->append(Alloc<Field>(StrFromC("capture_names"), x2));
323 }
324
325 return out_node;
326}
327
328
329hnode_t* eggex_ops_t::PrettyTree(Dict<int, bool>* seen) {
330 switch (this->tag()) {
331 case eggex_ops_e::No: {
332 eggex_ops__No* obj = static_cast<eggex_ops__No*>(this);
333 return obj->PrettyTree(seen);
334 }
335 case eggex_ops_e::Yes: {
336 eggex_ops__Yes* obj = static_cast<eggex_ops__Yes*>(this);
337 return obj->PrettyTree(seen);
338 }
339 default:
340 assert(0);
341 }
342}
343
344hnode_t* RegexMatch::PrettyTree(Dict<int, bool>* seen) {
345 seen = seen ? seen : Alloc<Dict<int, bool>>();
346 int heap_id = ObjectId(this);
347 if (dict_contains(seen, heap_id)) {
348 return Alloc<hnode::AlreadySeen>(heap_id);
349 }
350 seen->set(heap_id, true);
351 hnode::Record* out_node = runtime::NewRecord(StrFromC("RegexMatch"));
352 List<Field*>* L = out_node->fields;
353
354 hnode_t* x0 = runtime::NewLeaf(this->s, color_e::StringConst);
355 L->append(Alloc<Field>(StrFromC("s"), x0));
356
357 if (this->indices != nullptr) { // List
358 hnode::Array* x1 = Alloc<hnode::Array>(Alloc<List<hnode_t*>>());
359 for (ListIter<int> it(this->indices); !it.Done(); it.Next()) {
360 int i1 = it.Value();
361 hnode_t* h = Alloc<hnode::Leaf>(str(i1), color_e::OtherConst);
362 x1->children->append(h);
363 }
364 L->append(Alloc<Field>(StrFromC("indices"), x1));
365 }
366
367 hnode_t* x2 = this->ops->PrettyTree(seen);
368 L->append(Alloc<Field>(StrFromC("ops"), x2));
369
370 return out_node;
371}
372
373BigStr* regex_match_str(int tag, bool dot) {
374 char buf[32];
375 const char* v = nullptr;
376 switch (tag) {
377 case regex_match_e::No:
378 v = "No"; break;
379 case regex_match_e::Yes:
380 v = "Yes"; break;
381 default:
382 assert(0);
383 }
384 if (dot) {
385 snprintf(buf, 32, "regex_match.%s", v);
386 return StrFromC(buf);
387 } else {
388 return StrFromC(v);
389 }
390}
391
392regex_match__No* regex_match::No = &gregex_match__No.obj;
393
394GcGlobal<regex_match__No> gregex_match__No =
395 { ObjHeader::Global(regex_match_e::No) };
396
397hnode_t* regex_match__No::PrettyTree(Dict<int, bool>* seen) {
398 seen = seen ? seen : Alloc<Dict<int, bool>>();
399 int heap_id = ObjectId(this);
400 if (dict_contains(seen, heap_id)) {
401 return Alloc<hnode::AlreadySeen>(heap_id);
402 }
403 seen->set(heap_id, true);
404 hnode::Record* out_node = runtime::NewRecord(regex_match_str(this->tag()));
405 return out_node;
406}
407
408
409hnode_t* regex_match_t::PrettyTree(Dict<int, bool>* seen) {
410 switch (this->tag()) {
411 case regex_match_e::No: {
412 regex_match__No* obj = static_cast<regex_match__No*>(this);
413 return obj->PrettyTree(seen);
414 }
415 case regex_match_e::Yes: {
416 RegexMatch* obj = static_cast<RegexMatch*>(this);
417 return obj->PrettyTree(seen);
418 }
419 default:
420 assert(0);
421 }
422}
423
424hnode_t* LiteralBlock::PrettyTree(Dict<int, bool>* seen) {
425 seen = seen ? seen : Alloc<Dict<int, bool>>();
426 int heap_id = ObjectId(this);
427 if (dict_contains(seen, heap_id)) {
428 return Alloc<hnode::AlreadySeen>(heap_id);
429 }
430 seen->set(heap_id, true);
431 hnode::Record* out_node = runtime::NewRecord(StrFromC("LiteralBlock"));
432 List<Field*>* L = out_node->fields;
433
434 hnode_t* x0 = this->brace_group->PrettyTree(seen);
435 L->append(Alloc<Field>(StrFromC("brace_group"), x0));
436
437 if (this->lines != nullptr) { // List
438 hnode::Array* x1 = Alloc<hnode::Array>(Alloc<List<hnode_t*>>());
439 for (ListIter<syntax_asdl::SourceLine*> it(this->lines); !it.Done();
440 it.Next()) {
441 syntax_asdl::SourceLine* i1 = it.Value();
442 hnode_t* h = (i1 == nullptr) ? Alloc<hnode::Leaf>(StrFromC("_"),
443 color_e::OtherConst) : i1->PrettyTree(seen);
444 x1->children->append(h);
445 }
446 L->append(Alloc<Field>(StrFromC("lines"), x1));
447 }
448
449 return out_node;
450}
451
452BigStr* cmd_frag_str(int tag, bool dot) {
453 char buf[32];
454 const char* v = nullptr;
455 switch (tag) {
456 case cmd_frag_e::LiteralBlock:
457 v = "LiteralBlock"; break;
458 case cmd_frag_e::Expr:
459 v = "Expr"; break;
460 default:
461 assert(0);
462 }
463 if (dot) {
464 snprintf(buf, 32, "cmd_frag.%s", v);
465 return StrFromC(buf);
466 } else {
467 return StrFromC(v);
468 }
469}
470
471hnode_t* cmd_frag__Expr::PrettyTree(Dict<int, bool>* seen) {
472 seen = seen ? seen : Alloc<Dict<int, bool>>();
473 int heap_id = ObjectId(this);
474 if (dict_contains(seen, heap_id)) {
475 return Alloc<hnode::AlreadySeen>(heap_id);
476 }
477 seen->set(heap_id, true);
478 hnode::Record* out_node = runtime::NewRecord(cmd_frag_str(this->tag()));
479 List<Field*>* L = out_node->fields;
480
481 hnode_t* x0 = this->c->PrettyTree(seen);
482 L->append(Alloc<Field>(StrFromC("c"), x0));
483
484 return out_node;
485}
486
487
488hnode_t* cmd_frag_t::PrettyTree(Dict<int, bool>* seen) {
489 switch (this->tag()) {
490 case cmd_frag_e::LiteralBlock: {
491 LiteralBlock* obj = static_cast<LiteralBlock*>(this);
492 return obj->PrettyTree(seen);
493 }
494 case cmd_frag_e::Expr: {
495 cmd_frag__Expr* obj = static_cast<cmd_frag__Expr*>(this);
496 return obj->PrettyTree(seen);
497 }
498 default:
499 assert(0);
500 }
501}
502
503hnode_t* Obj::PrettyTree(Dict<int, bool>* seen) {
504 seen = seen ? seen : Alloc<Dict<int, bool>>();
505 int heap_id = ObjectId(this);
506 if (dict_contains(seen, heap_id)) {
507 return Alloc<hnode::AlreadySeen>(heap_id);
508 }
509 seen->set(heap_id, true);
510 hnode::Record* out_node = runtime::NewRecord(StrFromC("Obj"));
511 List<Field*>* L = out_node->fields;
512
513 if (this->prototype) { // Optional
514 hnode_t* x0 = this->prototype->PrettyTree(seen);
515 L->append(Alloc<Field>(StrFromC("prototype"), x0));
516 }
517
518 if (this->d) { // Dict
519 auto m = Alloc<hnode::Leaf>(StrFromC("Dict"), color_e::OtherConst);
520 hnode::Array* x1 = Alloc<hnode::Array>(NewList<hnode_t*>({m}));
521 for (DictIter<BigStr*, value_t*> it(this->d); !it.Done(); it.Next()) {
522 auto k1 = it.Key();
523 auto v1 = it.Value();
524 x1->children->append(runtime::NewLeaf(k1, color_e::StringConst));
525 x1->children->append(v1->PrettyTree(seen));
526 }
527 L->append(Alloc<Field>(StrFromC ("d"), x1));
528 }
529
530 return out_node;
531}
532
533BigStr* value_str(int tag, bool dot) {
534 char buf[32];
535 const char* v = nullptr;
536 switch (tag) {
537 case value_e::Interrupted:
538 v = "Interrupted"; break;
539 case value_e::Stdin:
540 v = "Stdin"; break;
541 case value_e::Slice:
542 v = "Slice"; break;
543 case value_e::Undef:
544 v = "Undef"; break;
545 case value_e::Str:
546 v = "Str"; break;
547 case value_e::BashArray:
548 v = "BashArray"; break;
549 case value_e::SparseArray:
550 v = "SparseArray"; break;
551 case value_e::BashAssoc:
552 v = "BashAssoc"; break;
553 case value_e::Null:
554 v = "Null"; break;
555 case value_e::Bool:
556 v = "Bool"; break;
557 case value_e::Int:
558 v = "Int"; break;
559 case value_e::Float:
560 v = "Float"; break;
561 case value_e::List:
562 v = "List"; break;
563 case value_e::Dict:
564 v = "Dict"; break;
565 case value_e::Obj:
566 v = "Obj"; break;
567 case value_e::Range:
568 v = "Range"; break;
569 case value_e::Eggex:
570 v = "Eggex"; break;
571 case value_e::Match:
572 v = "Match"; break;
573 case value_e::Place:
574 v = "Place"; break;
575 case value_e::Frame:
576 v = "Frame"; break;
577 case value_e::BoundFunc:
578 v = "BoundFunc"; break;
579 case value_e::BuiltinFunc:
580 v = "BuiltinFunc"; break;
581 case value_e::Func:
582 v = "Func"; break;
583 case value_e::BuiltinProc:
584 v = "BuiltinProc"; break;
585 case value_e::Proc:
586 v = "Proc"; break;
587 case value_e::Expr:
588 v = "Expr"; break;
589 case value_e::CommandFrag:
590 v = "CommandFrag"; break;
591 case value_e::Command:
592 v = "Command"; break;
593 default:
594 assert(0);
595 }
596 if (dot) {
597 snprintf(buf, 32, "value.%s", v);
598 return StrFromC(buf);
599 } else {
600 return StrFromC(v);
601 }
602}
603
604value__Interrupted* value::Interrupted = &gvalue__Interrupted.obj;
605
606GcGlobal<value__Interrupted> gvalue__Interrupted =
607 { ObjHeader::Global(value_e::Interrupted) };
608
609value__Stdin* value::Stdin = &gvalue__Stdin.obj;
610
611GcGlobal<value__Stdin> gvalue__Stdin =
612 { ObjHeader::Global(value_e::Stdin) };
613
614value__Undef* value::Undef = &gvalue__Undef.obj;
615
616GcGlobal<value__Undef> gvalue__Undef =
617 { ObjHeader::Global(value_e::Undef) };
618
619value__Null* value::Null = &gvalue__Null.obj;
620
621GcGlobal<value__Null> gvalue__Null =
622 { ObjHeader::Global(value_e::Null) };
623
624hnode_t* value__Interrupted::PrettyTree(Dict<int, bool>* seen) {
625 seen = seen ? seen : Alloc<Dict<int, bool>>();
626 int heap_id = ObjectId(this);
627 if (dict_contains(seen, heap_id)) {
628 return Alloc<hnode::AlreadySeen>(heap_id);
629 }
630 seen->set(heap_id, true);
631 hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
632 return out_node;
633}
634
635
636hnode_t* value__Stdin::PrettyTree(Dict<int, bool>* seen) {
637 seen = seen ? seen : Alloc<Dict<int, bool>>();
638 int heap_id = ObjectId(this);
639 if (dict_contains(seen, heap_id)) {
640 return Alloc<hnode::AlreadySeen>(heap_id);
641 }
642 seen->set(heap_id, true);
643 hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
644 return out_node;
645}
646
647
648hnode_t* value__Slice::PrettyTree(Dict<int, bool>* seen) {
649 seen = seen ? seen : Alloc<Dict<int, bool>>();
650 int heap_id = ObjectId(this);
651 if (dict_contains(seen, heap_id)) {
652 return Alloc<hnode::AlreadySeen>(heap_id);
653 }
654 seen->set(heap_id, true);
655 hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
656 List<Field*>* L = out_node->fields;
657
658 if (this->lower) { // Optional
659 hnode_t* x0 = this->lower->PrettyTree(seen);
660 L->append(Alloc<Field>(StrFromC("lower"), x0));
661 }
662
663 if (this->upper) { // Optional
664 hnode_t* x1 = this->upper->PrettyTree(seen);
665 L->append(Alloc<Field>(StrFromC("upper"), x1));
666 }
667
668 return out_node;
669}
670
671
672hnode_t* value__Undef::PrettyTree(Dict<int, bool>* seen) {
673 seen = seen ? seen : Alloc<Dict<int, bool>>();
674 int heap_id = ObjectId(this);
675 if (dict_contains(seen, heap_id)) {
676 return Alloc<hnode::AlreadySeen>(heap_id);
677 }
678 seen->set(heap_id, true);
679 hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
680 return out_node;
681}
682
683
684hnode_t* value__Str::PrettyTree(Dict<int, bool>* seen) {
685 seen = seen ? seen : Alloc<Dict<int, bool>>();
686 int heap_id = ObjectId(this);
687 if (dict_contains(seen, heap_id)) {
688 return Alloc<hnode::AlreadySeen>(heap_id);
689 }
690 seen->set(heap_id, true);
691 hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
692 List<Field*>* L = out_node->fields;
693
694 hnode_t* x0 = runtime::NewLeaf(this->s, color_e::StringConst);
695 L->append(Alloc<Field>(StrFromC("s"), x0));
696
697 return out_node;
698}
699
700
701hnode_t* value__BashArray::PrettyTree(Dict<int, bool>* seen) {
702 seen = seen ? seen : Alloc<Dict<int, bool>>();
703 int heap_id = ObjectId(this);
704 if (dict_contains(seen, heap_id)) {
705 return Alloc<hnode::AlreadySeen>(heap_id);
706 }
707 seen->set(heap_id, true);
708 hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
709 List<Field*>* L = out_node->fields;
710
711 if (this->strs != nullptr) { // List
712 hnode::Array* x0 = Alloc<hnode::Array>(Alloc<List<hnode_t*>>());
713 for (ListIter<BigStr*> it(this->strs); !it.Done(); it.Next()) {
714 BigStr* i0 = it.Value();
715 hnode_t* h = runtime::NewLeaf(i0, color_e::StringConst);
716 x0->children->append(h);
717 }
718 L->append(Alloc<Field>(StrFromC("strs"), x0));
719 }
720
721 return out_node;
722}
723
724
725hnode_t* value__SparseArray::PrettyTree(Dict<int, bool>* seen) {
726 seen = seen ? seen : Alloc<Dict<int, bool>>();
727 int heap_id = ObjectId(this);
728 if (dict_contains(seen, heap_id)) {
729 return Alloc<hnode::AlreadySeen>(heap_id);
730 }
731 seen->set(heap_id, true);
732 hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
733 List<Field*>* L = out_node->fields;
734
735 if (this->d) { // Dict
736 auto m = Alloc<hnode::Leaf>(StrFromC("Dict"), color_e::OtherConst);
737 hnode::Array* x0 = Alloc<hnode::Array>(NewList<hnode_t*>({m}));
738 for (DictIter<mops::BigInt, BigStr*> it(this->d); !it.Done(); it.Next()) {
739 auto k0 = it.Key();
740 auto v0 = it.Value();
741 x0->children->append(Alloc<hnode::Leaf>(mops::ToStr(k0),
742 color_e::OtherConst));
743 x0->children->append(runtime::NewLeaf(v0, color_e::StringConst));
744 }
745 L->append(Alloc<Field>(StrFromC ("d"), x0));
746 }
747
748 hnode_t* x1 = Alloc<hnode::Leaf>(mops::ToStr(this->max_index),
749 color_e::OtherConst);
750 L->append(Alloc<Field>(StrFromC("max_index"), x1));
751
752 return out_node;
753}
754
755
756hnode_t* value__BashAssoc::PrettyTree(Dict<int, bool>* seen) {
757 seen = seen ? seen : Alloc<Dict<int, bool>>();
758 int heap_id = ObjectId(this);
759 if (dict_contains(seen, heap_id)) {
760 return Alloc<hnode::AlreadySeen>(heap_id);
761 }
762 seen->set(heap_id, true);
763 hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
764 List<Field*>* L = out_node->fields;
765
766 if (this->d) { // Dict
767 auto m = Alloc<hnode::Leaf>(StrFromC("Dict"), color_e::OtherConst);
768 hnode::Array* x0 = Alloc<hnode::Array>(NewList<hnode_t*>({m}));
769 for (DictIter<BigStr*, BigStr*> it(this->d); !it.Done(); it.Next()) {
770 auto k0 = it.Key();
771 auto v0 = it.Value();
772 x0->children->append(runtime::NewLeaf(k0, color_e::StringConst));
773 x0->children->append(runtime::NewLeaf(v0, color_e::StringConst));
774 }
775 L->append(Alloc<Field>(StrFromC ("d"), x0));
776 }
777
778 return out_node;
779}
780
781
782hnode_t* value__Null::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 return out_node;
791}
792
793
794hnode_t* value__Bool::PrettyTree(Dict<int, bool>* seen) {
795 seen = seen ? seen : Alloc<Dict<int, bool>>();
796 int heap_id = ObjectId(this);
797 if (dict_contains(seen, heap_id)) {
798 return Alloc<hnode::AlreadySeen>(heap_id);
799 }
800 seen->set(heap_id, true);
801 hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
802 List<Field*>* L = out_node->fields;
803
804 hnode_t* x0 = Alloc<hnode::Leaf>(this->b ? runtime::TRUE_STR :
805 runtime::FALSE_STR, color_e::OtherConst);
806 L->append(Alloc<Field>(StrFromC("b"), x0));
807
808 return out_node;
809}
810
811
812hnode_t* value__Int::PrettyTree(Dict<int, bool>* seen) {
813 seen = seen ? seen : Alloc<Dict<int, bool>>();
814 int heap_id = ObjectId(this);
815 if (dict_contains(seen, heap_id)) {
816 return Alloc<hnode::AlreadySeen>(heap_id);
817 }
818 seen->set(heap_id, true);
819 hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
820 List<Field*>* L = out_node->fields;
821
822 hnode_t* x0 = Alloc<hnode::Leaf>(mops::ToStr(this->i), color_e::OtherConst);
823 L->append(Alloc<Field>(StrFromC("i"), x0));
824
825 return out_node;
826}
827
828
829hnode_t* value__Float::PrettyTree(Dict<int, bool>* seen) {
830 seen = seen ? seen : Alloc<Dict<int, bool>>();
831 int heap_id = ObjectId(this);
832 if (dict_contains(seen, heap_id)) {
833 return Alloc<hnode::AlreadySeen>(heap_id);
834 }
835 seen->set(heap_id, true);
836 hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
837 List<Field*>* L = out_node->fields;
838
839 hnode_t* x0 = Alloc<hnode::Leaf>(str(this->f), color_e::OtherConst);
840 L->append(Alloc<Field>(StrFromC("f"), x0));
841
842 return out_node;
843}
844
845
846hnode_t* value__List::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->items != nullptr) { // List
857 hnode::Array* x0 = Alloc<hnode::Array>(Alloc<List<hnode_t*>>());
858 for (ListIter<value_t*> it(this->items); !it.Done(); it.Next()) {
859 value_t* i0 = it.Value();
860 hnode_t* h = (i0 == nullptr) ? Alloc<hnode::Leaf>(StrFromC("_"),
861 color_e::OtherConst) : i0->PrettyTree(seen);
862 x0->children->append(h);
863 }
864 L->append(Alloc<Field>(StrFromC("items"), x0));
865 }
866
867 return out_node;
868}
869
870
871hnode_t* value__Dict::PrettyTree(Dict<int, bool>* seen) {
872 seen = seen ? seen : Alloc<Dict<int, bool>>();
873 int heap_id = ObjectId(this);
874 if (dict_contains(seen, heap_id)) {
875 return Alloc<hnode::AlreadySeen>(heap_id);
876 }
877 seen->set(heap_id, true);
878 hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
879 List<Field*>* L = out_node->fields;
880
881 if (this->d) { // Dict
882 auto m = Alloc<hnode::Leaf>(StrFromC("Dict"), color_e::OtherConst);
883 hnode::Array* x0 = Alloc<hnode::Array>(NewList<hnode_t*>({m}));
884 for (DictIter<BigStr*, value_t*> it(this->d); !it.Done(); it.Next()) {
885 auto k0 = it.Key();
886 auto v0 = it.Value();
887 x0->children->append(runtime::NewLeaf(k0, color_e::StringConst));
888 x0->children->append(v0->PrettyTree(seen));
889 }
890 L->append(Alloc<Field>(StrFromC ("d"), x0));
891 }
892
893 return out_node;
894}
895
896
897hnode_t* value__Range::PrettyTree(Dict<int, bool>* seen) {
898 seen = seen ? seen : Alloc<Dict<int, bool>>();
899 int heap_id = ObjectId(this);
900 if (dict_contains(seen, heap_id)) {
901 return Alloc<hnode::AlreadySeen>(heap_id);
902 }
903 seen->set(heap_id, true);
904 hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
905 List<Field*>* L = out_node->fields;
906
907 hnode_t* x0 = Alloc<hnode::Leaf>(str(this->lower), color_e::OtherConst);
908 L->append(Alloc<Field>(StrFromC("lower"), x0));
909
910 hnode_t* x1 = Alloc<hnode::Leaf>(str(this->upper), color_e::OtherConst);
911 L->append(Alloc<Field>(StrFromC("upper"), x1));
912
913 return out_node;
914}
915
916
917hnode_t* value__Eggex::PrettyTree(Dict<int, bool>* seen) {
918 seen = seen ? seen : Alloc<Dict<int, bool>>();
919 int heap_id = ObjectId(this);
920 if (dict_contains(seen, heap_id)) {
921 return Alloc<hnode::AlreadySeen>(heap_id);
922 }
923 seen->set(heap_id, true);
924 hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
925 List<Field*>* L = out_node->fields;
926
927 hnode_t* x0 = this->spliced->PrettyTree(seen);
928 L->append(Alloc<Field>(StrFromC("spliced"), x0));
929
930 hnode_t* x1 = runtime::NewLeaf(this->canonical_flags, color_e::StringConst);
931 L->append(Alloc<Field>(StrFromC("canonical_flags"), x1));
932
933 if (this->convert_funcs != nullptr) { // List
934 hnode::Array* x2 = Alloc<hnode::Array>(Alloc<List<hnode_t*>>());
935 for (ListIter<value_t*> it(this->convert_funcs); !it.Done(); it.Next()) {
936 value_t* i2 = it.Value();
937 hnode_t* h = (i2 == nullptr) ? Alloc<hnode::Leaf>(StrFromC("_"),
938 color_e::OtherConst) : i2->PrettyTree(seen);
939 x2->children->append(h);
940 }
941 L->append(Alloc<Field>(StrFromC("convert_funcs"), x2));
942 }
943
944 if (this->convert_toks != nullptr) { // List
945 hnode::Array* x3 = Alloc<hnode::Array>(Alloc<List<hnode_t*>>());
946 for (ListIter<syntax_asdl::Token*> it(this->convert_toks); !it.Done();
947 it.Next()) {
948 syntax_asdl::Token* i3 = it.Value();
949 hnode_t* h = (i3 == nullptr) ? Alloc<hnode::Leaf>(StrFromC("_"),
950 color_e::OtherConst) : i3->PrettyTree(seen);
951 x3->children->append(h);
952 }
953 L->append(Alloc<Field>(StrFromC("convert_toks"), x3));
954 }
955
956 if (this->as_ere) { // Optional
957 hnode_t* x4 = runtime::NewLeaf(this->as_ere, color_e::StringConst);
958 L->append(Alloc<Field>(StrFromC("as_ere"), x4));
959 }
960
961 if (this->capture_names != nullptr) { // List
962 hnode::Array* x5 = Alloc<hnode::Array>(Alloc<List<hnode_t*>>());
963 for (ListIter<BigStr*> it(this->capture_names); !it.Done(); it.Next()) {
964 BigStr* i5 = it.Value();
965 hnode_t* h = runtime::NewLeaf(i5, color_e::StringConst);
966 x5->children->append(h);
967 }
968 L->append(Alloc<Field>(StrFromC("capture_names"), x5));
969 }
970
971 return out_node;
972}
973
974
975hnode_t* value__Place::PrettyTree(Dict<int, bool>* seen) {
976 seen = seen ? seen : Alloc<Dict<int, bool>>();
977 int heap_id = ObjectId(this);
978 if (dict_contains(seen, heap_id)) {
979 return Alloc<hnode::AlreadySeen>(heap_id);
980 }
981 seen->set(heap_id, true);
982 hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
983 List<Field*>* L = out_node->fields;
984
985 hnode_t* x0 = this->lval->PrettyTree(seen);
986 L->append(Alloc<Field>(StrFromC("lval"), x0));
987
988 if (this->frame) { // Dict
989 auto m = Alloc<hnode::Leaf>(StrFromC("Dict"), color_e::OtherConst);
990 hnode::Array* x1 = Alloc<hnode::Array>(NewList<hnode_t*>({m}));
991 for (DictIter<BigStr*, runtime_asdl::Cell*> it(this->frame); !it.Done();
992 it.Next()) {
993 auto k1 = it.Key();
994 auto v1 = it.Value();
995 x1->children->append(runtime::NewLeaf(k1, color_e::StringConst));
996 x1->children->append(v1->PrettyTree(seen));
997 }
998 L->append(Alloc<Field>(StrFromC ("frame"), x1));
999 }
1000
1001 return out_node;
1002}
1003
1004
1005hnode_t* value__Frame::PrettyTree(Dict<int, bool>* seen) {
1006 seen = seen ? seen : Alloc<Dict<int, bool>>();
1007 int heap_id = ObjectId(this);
1008 if (dict_contains(seen, heap_id)) {
1009 return Alloc<hnode::AlreadySeen>(heap_id);
1010 }
1011 seen->set(heap_id, true);
1012 hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
1013 List<Field*>* L = out_node->fields;
1014
1015 if (this->frame) { // Dict
1016 auto m = Alloc<hnode::Leaf>(StrFromC("Dict"), color_e::OtherConst);
1017 hnode::Array* x0 = Alloc<hnode::Array>(NewList<hnode_t*>({m}));
1018 for (DictIter<BigStr*, runtime_asdl::Cell*> it(this->frame); !it.Done();
1019 it.Next()) {
1020 auto k0 = it.Key();
1021 auto v0 = it.Value();
1022 x0->children->append(runtime::NewLeaf(k0, color_e::StringConst));
1023 x0->children->append(v0->PrettyTree(seen));
1024 }
1025 L->append(Alloc<Field>(StrFromC ("frame"), x0));
1026 }
1027
1028 return out_node;
1029}
1030
1031
1032hnode_t* value__BoundFunc::PrettyTree(Dict<int, bool>* seen) {
1033 seen = seen ? seen : Alloc<Dict<int, bool>>();
1034 int heap_id = ObjectId(this);
1035 if (dict_contains(seen, heap_id)) {
1036 return Alloc<hnode::AlreadySeen>(heap_id);
1037 }
1038 seen->set(heap_id, true);
1039 hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
1040 List<Field*>* L = out_node->fields;
1041
1042 hnode_t* x0 = this->me->PrettyTree(seen);
1043 L->append(Alloc<Field>(StrFromC("me"), x0));
1044
1045 hnode_t* x1 = this->func->PrettyTree(seen);
1046 L->append(Alloc<Field>(StrFromC("func"), x1));
1047
1048 return out_node;
1049}
1050
1051
1052hnode_t* value__BuiltinFunc::PrettyTree(Dict<int, bool>* seen) {
1053 seen = seen ? seen : Alloc<Dict<int, bool>>();
1054 int heap_id = ObjectId(this);
1055 if (dict_contains(seen, heap_id)) {
1056 return Alloc<hnode::AlreadySeen>(heap_id);
1057 }
1058 seen->set(heap_id, true);
1059 hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
1060 List<Field*>* L = out_node->fields;
1061
1062 hnode_t* x0 = Alloc<hnode::External>(this->callable);
1063 L->append(Alloc<Field>(StrFromC("callable"), x0));
1064
1065 return out_node;
1066}
1067
1068
1069hnode_t* value__Func::PrettyTree(Dict<int, bool>* seen) {
1070 seen = seen ? seen : Alloc<Dict<int, bool>>();
1071 int heap_id = ObjectId(this);
1072 if (dict_contains(seen, heap_id)) {
1073 return Alloc<hnode::AlreadySeen>(heap_id);
1074 }
1075 seen->set(heap_id, true);
1076 hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
1077 List<Field*>* L = out_node->fields;
1078
1079 hnode_t* x0 = runtime::NewLeaf(this->name, color_e::StringConst);
1080 L->append(Alloc<Field>(StrFromC("name"), x0));
1081
1082 hnode_t* x1 = this->parsed->PrettyTree(seen);
1083 L->append(Alloc<Field>(StrFromC("parsed"), x1));
1084
1085 if (this->pos_defaults != nullptr) { // List
1086 hnode::Array* x2 = Alloc<hnode::Array>(Alloc<List<hnode_t*>>());
1087 for (ListIter<value_t*> it(this->pos_defaults); !it.Done(); it.Next()) {
1088 value_t* i2 = it.Value();
1089 hnode_t* h = (i2 == nullptr) ? Alloc<hnode::Leaf>(StrFromC("_"),
1090 color_e::OtherConst) : i2->PrettyTree(seen);
1091 x2->children->append(h);
1092 }
1093 L->append(Alloc<Field>(StrFromC("pos_defaults"), x2));
1094 }
1095
1096 if (this->named_defaults) { // Dict
1097 auto m = Alloc<hnode::Leaf>(StrFromC("Dict"), color_e::OtherConst);
1098 hnode::Array* x3 = Alloc<hnode::Array>(NewList<hnode_t*>({m}));
1099 for (DictIter<BigStr*, value_t*> it(this->named_defaults); !it.Done();
1100 it.Next()) {
1101 auto k3 = it.Key();
1102 auto v3 = it.Value();
1103 x3->children->append(runtime::NewLeaf(k3, color_e::StringConst));
1104 x3->children->append(v3->PrettyTree(seen));
1105 }
1106 L->append(Alloc<Field>(StrFromC ("named_defaults"), x3));
1107 }
1108
1109 if (this->module_frame) { // Dict
1110 auto m = Alloc<hnode::Leaf>(StrFromC("Dict"), color_e::OtherConst);
1111 hnode::Array* x4 = Alloc<hnode::Array>(NewList<hnode_t*>({m}));
1112 for (DictIter<BigStr*, runtime_asdl::Cell*> it(this->module_frame);
1113 !it.Done(); it.Next()) {
1114 auto k4 = it.Key();
1115 auto v4 = it.Value();
1116 x4->children->append(runtime::NewLeaf(k4, color_e::StringConst));
1117 x4->children->append(v4->PrettyTree(seen));
1118 }
1119 L->append(Alloc<Field>(StrFromC ("module_frame"), x4));
1120 }
1121
1122 return out_node;
1123}
1124
1125
1126hnode_t* value__BuiltinProc::PrettyTree(Dict<int, bool>* seen) {
1127 seen = seen ? seen : Alloc<Dict<int, bool>>();
1128 int heap_id = ObjectId(this);
1129 if (dict_contains(seen, heap_id)) {
1130 return Alloc<hnode::AlreadySeen>(heap_id);
1131 }
1132 seen->set(heap_id, true);
1133 hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
1134 List<Field*>* L = out_node->fields;
1135
1136 hnode_t* x0 = Alloc<hnode::External>(this->builtin);
1137 L->append(Alloc<Field>(StrFromC("builtin"), x0));
1138
1139 return out_node;
1140}
1141
1142
1143hnode_t* value__Proc::PrettyTree(Dict<int, bool>* seen) {
1144 seen = seen ? seen : Alloc<Dict<int, bool>>();
1145 int heap_id = ObjectId(this);
1146 if (dict_contains(seen, heap_id)) {
1147 return Alloc<hnode::AlreadySeen>(heap_id);
1148 }
1149 seen->set(heap_id, true);
1150 hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
1151 List<Field*>* L = out_node->fields;
1152
1153 hnode_t* x0 = runtime::NewLeaf(this->name, color_e::StringConst);
1154 L->append(Alloc<Field>(StrFromC("name"), x0));
1155
1156 hnode_t* x1 = this->name_tok->PrettyTree(seen);
1157 L->append(Alloc<Field>(StrFromC("name_tok"), x1));
1158
1159 hnode_t* x2 = this->sig->PrettyTree(seen);
1160 L->append(Alloc<Field>(StrFromC("sig"), x2));
1161
1162 hnode_t* x3 = this->body->PrettyTree(seen);
1163 L->append(Alloc<Field>(StrFromC("body"), x3));
1164
1165 if (this->defaults) { // Optional
1166 hnode_t* x4 = this->defaults->PrettyTree(seen);
1167 L->append(Alloc<Field>(StrFromC("defaults"), x4));
1168 }
1169
1170 hnode_t* x5 = Alloc<hnode::Leaf>(this->sh_compat ? runtime::TRUE_STR :
1171 runtime::FALSE_STR, color_e::OtherConst);
1172 L->append(Alloc<Field>(StrFromC("sh_compat"), x5));
1173
1174 if (this->module_frame) { // Dict
1175 auto m = Alloc<hnode::Leaf>(StrFromC("Dict"), color_e::OtherConst);
1176 hnode::Array* x6 = Alloc<hnode::Array>(NewList<hnode_t*>({m}));
1177 for (DictIter<BigStr*, runtime_asdl::Cell*> it(this->module_frame);
1178 !it.Done(); it.Next()) {
1179 auto k6 = it.Key();
1180 auto v6 = it.Value();
1181 x6->children->append(runtime::NewLeaf(k6, color_e::StringConst));
1182 x6->children->append(v6->PrettyTree(seen));
1183 }
1184 L->append(Alloc<Field>(StrFromC ("module_frame"), x6));
1185 }
1186
1187 return out_node;
1188}
1189
1190
1191hnode_t* value__Expr::PrettyTree(Dict<int, bool>* seen) {
1192 seen = seen ? seen : Alloc<Dict<int, bool>>();
1193 int heap_id = ObjectId(this);
1194 if (dict_contains(seen, heap_id)) {
1195 return Alloc<hnode::AlreadySeen>(heap_id);
1196 }
1197 seen->set(heap_id, true);
1198 hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
1199 List<Field*>* L = out_node->fields;
1200
1201 hnode_t* x0 = this->e->PrettyTree(seen);
1202 L->append(Alloc<Field>(StrFromC("e"), x0));
1203
1204 if (this->captured_frame) { // Dict
1205 auto m = Alloc<hnode::Leaf>(StrFromC("Dict"), color_e::OtherConst);
1206 hnode::Array* x1 = Alloc<hnode::Array>(NewList<hnode_t*>({m}));
1207 for (DictIter<BigStr*, runtime_asdl::Cell*> it(this->captured_frame);
1208 !it.Done(); it.Next()) {
1209 auto k1 = it.Key();
1210 auto v1 = it.Value();
1211 x1->children->append(runtime::NewLeaf(k1, color_e::StringConst));
1212 x1->children->append(v1->PrettyTree(seen));
1213 }
1214 L->append(Alloc<Field>(StrFromC ("captured_frame"), x1));
1215 }
1216
1217 if (this->module_frame) { // Dict
1218 auto m = Alloc<hnode::Leaf>(StrFromC("Dict"), color_e::OtherConst);
1219 hnode::Array* x2 = Alloc<hnode::Array>(NewList<hnode_t*>({m}));
1220 for (DictIter<BigStr*, runtime_asdl::Cell*> it(this->module_frame);
1221 !it.Done(); it.Next()) {
1222 auto k2 = it.Key();
1223 auto v2 = it.Value();
1224 x2->children->append(runtime::NewLeaf(k2, color_e::StringConst));
1225 x2->children->append(v2->PrettyTree(seen));
1226 }
1227 L->append(Alloc<Field>(StrFromC ("module_frame"), x2));
1228 }
1229
1230 return out_node;
1231}
1232
1233
1234hnode_t* value__CommandFrag::PrettyTree(Dict<int, bool>* seen) {
1235 seen = seen ? seen : Alloc<Dict<int, bool>>();
1236 int heap_id = ObjectId(this);
1237 if (dict_contains(seen, heap_id)) {
1238 return Alloc<hnode::AlreadySeen>(heap_id);
1239 }
1240 seen->set(heap_id, true);
1241 hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
1242 List<Field*>* L = out_node->fields;
1243
1244 hnode_t* x0 = this->c->PrettyTree(seen);
1245 L->append(Alloc<Field>(StrFromC("c"), x0));
1246
1247 return out_node;
1248}
1249
1250
1251hnode_t* value__Command::PrettyTree(Dict<int, bool>* seen) {
1252 seen = seen ? seen : Alloc<Dict<int, bool>>();
1253 int heap_id = ObjectId(this);
1254 if (dict_contains(seen, heap_id)) {
1255 return Alloc<hnode::AlreadySeen>(heap_id);
1256 }
1257 seen->set(heap_id, true);
1258 hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
1259 List<Field*>* L = out_node->fields;
1260
1261 hnode_t* x0 = this->frag->PrettyTree(seen);
1262 L->append(Alloc<Field>(StrFromC("frag"), x0));
1263
1264 if (this->captured_frame) { // Dict
1265 auto m = Alloc<hnode::Leaf>(StrFromC("Dict"), color_e::OtherConst);
1266 hnode::Array* x1 = Alloc<hnode::Array>(NewList<hnode_t*>({m}));
1267 for (DictIter<BigStr*, runtime_asdl::Cell*> it(this->captured_frame);
1268 !it.Done(); it.Next()) {
1269 auto k1 = it.Key();
1270 auto v1 = it.Value();
1271 x1->children->append(runtime::NewLeaf(k1, color_e::StringConst));
1272 x1->children->append(v1->PrettyTree(seen));
1273 }
1274 L->append(Alloc<Field>(StrFromC ("captured_frame"), x1));
1275 }
1276
1277 if (this->module_frame) { // Dict
1278 auto m = Alloc<hnode::Leaf>(StrFromC("Dict"), color_e::OtherConst);
1279 hnode::Array* x2 = Alloc<hnode::Array>(NewList<hnode_t*>({m}));
1280 for (DictIter<BigStr*, runtime_asdl::Cell*> it(this->module_frame);
1281 !it.Done(); it.Next()) {
1282 auto k2 = it.Key();
1283 auto v2 = it.Value();
1284 x2->children->append(runtime::NewLeaf(k2, color_e::StringConst));
1285 x2->children->append(v2->PrettyTree(seen));
1286 }
1287 L->append(Alloc<Field>(StrFromC ("module_frame"), x2));
1288 }
1289
1290 return out_node;
1291}
1292
1293
1294hnode_t* value_t::PrettyTree(Dict<int, bool>* seen) {
1295 switch (this->tag()) {
1296 case value_e::Interrupted: {
1297 value__Interrupted* obj = static_cast<value__Interrupted*>(this);
1298 return obj->PrettyTree(seen);
1299 }
1300 case value_e::Stdin: {
1301 value__Stdin* obj = static_cast<value__Stdin*>(this);
1302 return obj->PrettyTree(seen);
1303 }
1304 case value_e::Slice: {
1305 value__Slice* obj = static_cast<value__Slice*>(this);
1306 return obj->PrettyTree(seen);
1307 }
1308 case value_e::Undef: {
1309 value__Undef* obj = static_cast<value__Undef*>(this);
1310 return obj->PrettyTree(seen);
1311 }
1312 case value_e::Str: {
1313 value__Str* obj = static_cast<value__Str*>(this);
1314 return obj->PrettyTree(seen);
1315 }
1316 case value_e::BashArray: {
1317 value__BashArray* obj = static_cast<value__BashArray*>(this);
1318 return obj->PrettyTree(seen);
1319 }
1320 case value_e::SparseArray: {
1321 value__SparseArray* obj = static_cast<value__SparseArray*>(this);
1322 return obj->PrettyTree(seen);
1323 }
1324 case value_e::BashAssoc: {
1325 value__BashAssoc* obj = static_cast<value__BashAssoc*>(this);
1326 return obj->PrettyTree(seen);
1327 }
1328 case value_e::Null: {
1329 value__Null* obj = static_cast<value__Null*>(this);
1330 return obj->PrettyTree(seen);
1331 }
1332 case value_e::Bool: {
1333 value__Bool* obj = static_cast<value__Bool*>(this);
1334 return obj->PrettyTree(seen);
1335 }
1336 case value_e::Int: {
1337 value__Int* obj = static_cast<value__Int*>(this);
1338 return obj->PrettyTree(seen);
1339 }
1340 case value_e::Float: {
1341 value__Float* obj = static_cast<value__Float*>(this);
1342 return obj->PrettyTree(seen);
1343 }
1344 case value_e::List: {
1345 value__List* obj = static_cast<value__List*>(this);
1346 return obj->PrettyTree(seen);
1347 }
1348 case value_e::Dict: {
1349 value__Dict* obj = static_cast<value__Dict*>(this);
1350 return obj->PrettyTree(seen);
1351 }
1352 case value_e::Obj: {
1353 Obj* obj = static_cast<Obj*>(this);
1354 return obj->PrettyTree(seen);
1355 }
1356 case value_e::Range: {
1357 value__Range* obj = static_cast<value__Range*>(this);
1358 return obj->PrettyTree(seen);
1359 }
1360 case value_e::Eggex: {
1361 value__Eggex* obj = static_cast<value__Eggex*>(this);
1362 return obj->PrettyTree(seen);
1363 }
1364 case value_e::Match: {
1365 RegexMatch* obj = static_cast<RegexMatch*>(this);
1366 return obj->PrettyTree(seen);
1367 }
1368 case value_e::Place: {
1369 value__Place* obj = static_cast<value__Place*>(this);
1370 return obj->PrettyTree(seen);
1371 }
1372 case value_e::Frame: {
1373 value__Frame* obj = static_cast<value__Frame*>(this);
1374 return obj->PrettyTree(seen);
1375 }
1376 case value_e::BoundFunc: {
1377 value__BoundFunc* obj = static_cast<value__BoundFunc*>(this);
1378 return obj->PrettyTree(seen);
1379 }
1380 case value_e::BuiltinFunc: {
1381 value__BuiltinFunc* obj = static_cast<value__BuiltinFunc*>(this);
1382 return obj->PrettyTree(seen);
1383 }
1384 case value_e::Func: {
1385 value__Func* obj = static_cast<value__Func*>(this);
1386 return obj->PrettyTree(seen);
1387 }
1388 case value_e::BuiltinProc: {
1389 value__BuiltinProc* obj = static_cast<value__BuiltinProc*>(this);
1390 return obj->PrettyTree(seen);
1391 }
1392 case value_e::Proc: {
1393 value__Proc* obj = static_cast<value__Proc*>(this);
1394 return obj->PrettyTree(seen);
1395 }
1396 case value_e::Expr: {
1397 value__Expr* obj = static_cast<value__Expr*>(this);
1398 return obj->PrettyTree(seen);
1399 }
1400 case value_e::CommandFrag: {
1401 value__CommandFrag* obj = static_cast<value__CommandFrag*>(this);
1402 return obj->PrettyTree(seen);
1403 }
1404 case value_e::Command: {
1405 value__Command* obj = static_cast<value__Command*>(this);
1406 return obj->PrettyTree(seen);
1407 }
1408 default:
1409 assert(0);
1410 }
1411}
1412
1413} // namespace value_asdl