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

1452 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
26 hnode::Record* out_node = runtime::NewRecord(StrFromC("IntBox"));
27 List<Field*>* L = out_node->fields;
28
29 hnode_t* x0 = Alloc<hnode::Leaf>(str(this->i), color_e::OtherConst);
30 L->append(Alloc<Field>(StrFromC("i"), x0));
31
32 return out_node;
33}
34
35
36hnode_t* ProcDefaults::PrettyTree(Dict<int, bool>* seen) {
37 seen = seen ? seen : Alloc<Dict<int, bool>>();
38 int heap_id = ObjectId(this);
39 if (dict_contains(seen, heap_id)) {
40 return Alloc<hnode::AlreadySeen>(heap_id);
41 }
42 seen->set(heap_id, true);
43
44 hnode::Record* out_node = runtime::NewRecord(StrFromC("ProcDefaults"));
45 List<Field*>* L = out_node->fields;
46
47 if (this->for_word != nullptr) { // List
48 hnode::Array* x0 = Alloc<hnode::Array>(Alloc<List<hnode_t*>>());
49 for (ListIter<value_t*> it(this->for_word); !it.Done(); it.Next()) {
50 value_t* v_ = it.Value();
51 hnode_t* h = (v_ == nullptr) ? Alloc<hnode::Leaf>(StrFromC("_"),
52 color_e::OtherConst) : v_->PrettyTree(seen);
53 x0->children->append(h);
54 }
55 L->append(Alloc<Field>(StrFromC("for_word"), x0));
56 }
57
58 if (this->for_typed != nullptr) { // List
59 hnode::Array* x1 = Alloc<hnode::Array>(Alloc<List<hnode_t*>>());
60 for (ListIter<value_t*> it(this->for_typed); !it.Done(); it.Next()) {
61 value_t* v_ = it.Value();
62 hnode_t* h = (v_ == nullptr) ? Alloc<hnode::Leaf>(StrFromC("_"),
63 color_e::OtherConst) : v_->PrettyTree(seen);
64 x1->children->append(h);
65 }
66 L->append(Alloc<Field>(StrFromC("for_typed"), x1));
67 }
68
69 if (this->for_named) { // Dict
70 auto m = Alloc<hnode::Leaf>(StrFromC("Dict"), color_e::OtherConst);
71 hnode::Array* x2 = Alloc<hnode::Array>(NewList<hnode_t*>({m}));
72 for (DictIter<BigStr*, value_t*> it(this->for_named); !it.Done();
73 it.Next()) {
74 auto k2 = it.Key();
75 auto v2 = it.Value();
76 x2->children->append(runtime::NewLeaf(k2, color_e::StringConst));
77 x2->children->append(v2->PrettyTree(seen));
78 }
79 L->append(Alloc<Field>(StrFromC ("for_named"), x2));
80 }
81
82 if (this->for_block) { // Optional
83 hnode_t* x3 = this->for_block->PrettyTree(seen);
84 L->append(Alloc<Field>(StrFromC("for_block"), x3));
85 }
86
87 return out_node;
88}
89
90
91hnode_t* LeftName::PrettyTree(Dict<int, bool>* seen) {
92 seen = seen ? seen : Alloc<Dict<int, bool>>();
93 int heap_id = ObjectId(this);
94 if (dict_contains(seen, heap_id)) {
95 return Alloc<hnode::AlreadySeen>(heap_id);
96 }
97 seen->set(heap_id, true);
98
99 hnode::Record* out_node = runtime::NewRecord(StrFromC("LeftName"));
100 List<Field*>* L = out_node->fields;
101
102 hnode_t* x0 = runtime::NewLeaf(this->name, color_e::StringConst);
103 L->append(Alloc<Field>(StrFromC("name"), x0));
104
105 hnode_t* x1 = this->blame_loc->PrettyTree(seen);
106 L->append(Alloc<Field>(StrFromC("blame_loc"), x1));
107
108 return out_node;
109}
110
111BigStr* y_lvalue_str(int tag, bool dot) {
112 char buf[32];
113 const char* v = nullptr;
114 switch (tag) {
115 case y_lvalue_e::Local:
116 v = "Local"; break;
117 case y_lvalue_e::Container:
118 v = "Container"; break;
119 default:
120 assert(0);
121 }
122 if (dot) {
123 snprintf(buf, 32, "y_lvalue.%s", v);
124 return StrFromC(buf);
125 } else {
126 return StrFromC(v);
127 }
128}
129
130hnode_t* y_lvalue__Container::PrettyTree(Dict<int, bool>* seen) {
131 seen = seen ? seen : Alloc<Dict<int, bool>>();
132 int heap_id = ObjectId(this);
133 if (dict_contains(seen, heap_id)) {
134 return Alloc<hnode::AlreadySeen>(heap_id);
135 }
136 seen->set(heap_id, true);
137
138 hnode::Record* out_node = runtime::NewRecord(y_lvalue_str(this->tag()));
139 List<Field*>* L = out_node->fields;
140
141 hnode_t* x0 = this->obj->PrettyTree(seen);
142 L->append(Alloc<Field>(StrFromC("obj"), x0));
143
144 hnode_t* x1 = this->index->PrettyTree(seen);
145 L->append(Alloc<Field>(StrFromC("index"), x1));
146
147 return out_node;
148}
149
150
151hnode_t* y_lvalue_t::PrettyTree(Dict<int, bool>* seen) {
152 switch (this->tag()) {
153 case y_lvalue_e::Local: {
154 LeftName* obj = static_cast<LeftName*>(this);
155 return obj->PrettyTree(seen);
156 }
157 case y_lvalue_e::Container: {
158 y_lvalue__Container* obj = static_cast<y_lvalue__Container*>(this);
159 return obj->PrettyTree(seen);
160 }
161 default:
162 assert(0);
163 }
164}
165BigStr* sh_lvalue_str(int tag, bool dot) {
166 char buf[32];
167 const char* v = nullptr;
168 switch (tag) {
169 case sh_lvalue_e::Var:
170 v = "Var"; break;
171 case sh_lvalue_e::Indexed:
172 v = "Indexed"; break;
173 case sh_lvalue_e::Keyed:
174 v = "Keyed"; break;
175 default:
176 assert(0);
177 }
178 if (dot) {
179 snprintf(buf, 32, "sh_lvalue.%s", v);
180 return StrFromC(buf);
181 } else {
182 return StrFromC(v);
183 }
184}
185
186hnode_t* sh_lvalue__Indexed::PrettyTree(Dict<int, bool>* seen) {
187 seen = seen ? seen : Alloc<Dict<int, bool>>();
188 int heap_id = ObjectId(this);
189 if (dict_contains(seen, heap_id)) {
190 return Alloc<hnode::AlreadySeen>(heap_id);
191 }
192 seen->set(heap_id, true);
193
194 hnode::Record* out_node = runtime::NewRecord(sh_lvalue_str(this->tag()));
195 List<Field*>* L = out_node->fields;
196
197 hnode_t* x0 = runtime::NewLeaf(this->name, color_e::StringConst);
198 L->append(Alloc<Field>(StrFromC("name"), x0));
199
200 hnode_t* x1 = Alloc<hnode::Leaf>(str(this->index), color_e::OtherConst);
201 L->append(Alloc<Field>(StrFromC("index"), x1));
202
203 hnode_t* x2 = this->blame_loc->PrettyTree(seen);
204 L->append(Alloc<Field>(StrFromC("blame_loc"), x2));
205
206 return out_node;
207}
208
209
210hnode_t* sh_lvalue__Keyed::PrettyTree(Dict<int, bool>* seen) {
211 seen = seen ? seen : Alloc<Dict<int, bool>>();
212 int heap_id = ObjectId(this);
213 if (dict_contains(seen, heap_id)) {
214 return Alloc<hnode::AlreadySeen>(heap_id);
215 }
216 seen->set(heap_id, true);
217
218 hnode::Record* out_node = runtime::NewRecord(sh_lvalue_str(this->tag()));
219 List<Field*>* L = out_node->fields;
220
221 hnode_t* x0 = runtime::NewLeaf(this->name, color_e::StringConst);
222 L->append(Alloc<Field>(StrFromC("name"), x0));
223
224 hnode_t* x1 = runtime::NewLeaf(this->key, color_e::StringConst);
225 L->append(Alloc<Field>(StrFromC("key"), x1));
226
227 hnode_t* x2 = this->blame_loc->PrettyTree(seen);
228 L->append(Alloc<Field>(StrFromC("blame_loc"), x2));
229
230 return out_node;
231}
232
233
234hnode_t* sh_lvalue_t::PrettyTree(Dict<int, bool>* seen) {
235 switch (this->tag()) {
236 case sh_lvalue_e::Var: {
237 LeftName* obj = static_cast<LeftName*>(this);
238 return obj->PrettyTree(seen);
239 }
240 case sh_lvalue_e::Indexed: {
241 sh_lvalue__Indexed* obj = static_cast<sh_lvalue__Indexed*>(this);
242 return obj->PrettyTree(seen);
243 }
244 case sh_lvalue_e::Keyed: {
245 sh_lvalue__Keyed* obj = static_cast<sh_lvalue__Keyed*>(this);
246 return obj->PrettyTree(seen);
247 }
248 default:
249 assert(0);
250 }
251}
252BigStr* eggex_ops_str(int tag, bool dot) {
253 char buf[32];
254 const char* v = nullptr;
255 switch (tag) {
256 case eggex_ops_e::No:
257 v = "No"; break;
258 case eggex_ops_e::Yes:
259 v = "Yes"; break;
260 default:
261 assert(0);
262 }
263 if (dot) {
264 snprintf(buf, 32, "eggex_ops.%s", v);
265 return StrFromC(buf);
266 } else {
267 return StrFromC(v);
268 }
269}
270
271eggex_ops__No* eggex_ops::No = &geggex_ops__No.obj;
272
273GcGlobal<eggex_ops__No> geggex_ops__No =
274 { ObjHeader::Global(eggex_ops_e::No) };
275
276hnode_t* eggex_ops__No::PrettyTree(Dict<int, bool>* seen) {
277 seen = seen ? seen : Alloc<Dict<int, bool>>();
278 int heap_id = ObjectId(this);
279 if (dict_contains(seen, heap_id)) {
280 return Alloc<hnode::AlreadySeen>(heap_id);
281 }
282 seen->set(heap_id, true);
283
284 hnode::Record* out_node = runtime::NewRecord(eggex_ops_str(this->tag()));
285 return out_node;
286}
287
288
289hnode_t* eggex_ops__Yes::PrettyTree(Dict<int, bool>* seen) {
290 seen = seen ? seen : Alloc<Dict<int, bool>>();
291 int heap_id = ObjectId(this);
292 if (dict_contains(seen, heap_id)) {
293 return Alloc<hnode::AlreadySeen>(heap_id);
294 }
295 seen->set(heap_id, true);
296
297 hnode::Record* out_node = runtime::NewRecord(eggex_ops_str(this->tag()));
298 List<Field*>* L = out_node->fields;
299
300 if (this->convert_funcs != nullptr) { // List
301 hnode::Array* x0 = Alloc<hnode::Array>(Alloc<List<hnode_t*>>());
302 for (ListIter<value_t*> it(this->convert_funcs); !it.Done(); it.Next()) {
303 value_t* v_ = it.Value();
304 hnode_t* h = (v_ == nullptr) ? Alloc<hnode::Leaf>(StrFromC("_"),
305 color_e::OtherConst) : v_->PrettyTree(seen);
306 x0->children->append(h);
307 }
308 L->append(Alloc<Field>(StrFromC("convert_funcs"), x0));
309 }
310
311 if (this->convert_toks != nullptr) { // List
312 hnode::Array* x1 = Alloc<hnode::Array>(Alloc<List<hnode_t*>>());
313 for (ListIter<syntax_asdl::Token*> it(this->convert_toks); !it.Done();
314 it.Next()) {
315 syntax_asdl::Token* v_ = it.Value();
316 hnode_t* h = (v_ == nullptr) ? Alloc<hnode::Leaf>(StrFromC("_"),
317 color_e::OtherConst) : v_->PrettyTree(seen);
318 x1->children->append(h);
319 }
320 L->append(Alloc<Field>(StrFromC("convert_toks"), x1));
321 }
322
323 if (this->capture_names != nullptr) { // List
324 hnode::Array* x2 = Alloc<hnode::Array>(Alloc<List<hnode_t*>>());
325 for (ListIter<BigStr*> it(this->capture_names); !it.Done(); it.Next()) {
326 BigStr* v_ = it.Value();
327 hnode_t* h = runtime::NewLeaf(v_, color_e::StringConst);
328 x2->children->append(h);
329 }
330 L->append(Alloc<Field>(StrFromC("capture_names"), x2));
331 }
332
333 return out_node;
334}
335
336
337hnode_t* eggex_ops_t::PrettyTree(Dict<int, bool>* seen) {
338 switch (this->tag()) {
339 case eggex_ops_e::No: {
340 eggex_ops__No* obj = static_cast<eggex_ops__No*>(this);
341 return obj->PrettyTree(seen);
342 }
343 case eggex_ops_e::Yes: {
344 eggex_ops__Yes* obj = static_cast<eggex_ops__Yes*>(this);
345 return obj->PrettyTree(seen);
346 }
347 default:
348 assert(0);
349 }
350}
351
352hnode_t* RegexMatch::PrettyTree(Dict<int, bool>* seen) {
353 seen = seen ? seen : Alloc<Dict<int, bool>>();
354 int heap_id = ObjectId(this);
355 if (dict_contains(seen, heap_id)) {
356 return Alloc<hnode::AlreadySeen>(heap_id);
357 }
358 seen->set(heap_id, true);
359
360 hnode::Record* out_node = runtime::NewRecord(StrFromC("RegexMatch"));
361 List<Field*>* L = out_node->fields;
362
363 hnode_t* x0 = runtime::NewLeaf(this->s, color_e::StringConst);
364 L->append(Alloc<Field>(StrFromC("s"), x0));
365
366 if (this->indices != nullptr) { // List
367 hnode::Array* x1 = Alloc<hnode::Array>(Alloc<List<hnode_t*>>());
368 for (ListIter<int> it(this->indices); !it.Done(); it.Next()) {
369 int v_ = it.Value();
370 hnode_t* h = Alloc<hnode::Leaf>(str(v_), color_e::OtherConst);
371 x1->children->append(h);
372 }
373 L->append(Alloc<Field>(StrFromC("indices"), x1));
374 }
375
376 hnode_t* x2 = this->ops->PrettyTree(seen);
377 L->append(Alloc<Field>(StrFromC("ops"), x2));
378
379 return out_node;
380}
381
382BigStr* regex_match_str(int tag, bool dot) {
383 char buf[32];
384 const char* v = nullptr;
385 switch (tag) {
386 case regex_match_e::No:
387 v = "No"; break;
388 case regex_match_e::Yes:
389 v = "Yes"; break;
390 default:
391 assert(0);
392 }
393 if (dot) {
394 snprintf(buf, 32, "regex_match.%s", v);
395 return StrFromC(buf);
396 } else {
397 return StrFromC(v);
398 }
399}
400
401regex_match__No* regex_match::No = &gregex_match__No.obj;
402
403GcGlobal<regex_match__No> gregex_match__No =
404 { ObjHeader::Global(regex_match_e::No) };
405
406hnode_t* regex_match__No::PrettyTree(Dict<int, bool>* seen) {
407 seen = seen ? seen : Alloc<Dict<int, bool>>();
408 int heap_id = ObjectId(this);
409 if (dict_contains(seen, heap_id)) {
410 return Alloc<hnode::AlreadySeen>(heap_id);
411 }
412 seen->set(heap_id, true);
413
414 hnode::Record* out_node = runtime::NewRecord(regex_match_str(this->tag()));
415 return out_node;
416}
417
418
419hnode_t* regex_match_t::PrettyTree(Dict<int, bool>* seen) {
420 switch (this->tag()) {
421 case regex_match_e::No: {
422 regex_match__No* obj = static_cast<regex_match__No*>(this);
423 return obj->PrettyTree(seen);
424 }
425 case regex_match_e::Yes: {
426 RegexMatch* obj = static_cast<RegexMatch*>(this);
427 return obj->PrettyTree(seen);
428 }
429 default:
430 assert(0);
431 }
432}
433
434hnode_t* LiteralBlock::PrettyTree(Dict<int, bool>* seen) {
435 seen = seen ? seen : Alloc<Dict<int, bool>>();
436 int heap_id = ObjectId(this);
437 if (dict_contains(seen, heap_id)) {
438 return Alloc<hnode::AlreadySeen>(heap_id);
439 }
440 seen->set(heap_id, true);
441
442 hnode::Record* out_node = runtime::NewRecord(StrFromC("LiteralBlock"));
443 List<Field*>* L = out_node->fields;
444
445 hnode_t* x0 = this->brace_group->PrettyTree(seen);
446 L->append(Alloc<Field>(StrFromC("brace_group"), x0));
447
448 if (this->lines != nullptr) { // List
449 hnode::Array* x1 = Alloc<hnode::Array>(Alloc<List<hnode_t*>>());
450 for (ListIter<syntax_asdl::SourceLine*> it(this->lines); !it.Done();
451 it.Next()) {
452 syntax_asdl::SourceLine* v_ = it.Value();
453 hnode_t* h = (v_ == nullptr) ? Alloc<hnode::Leaf>(StrFromC("_"),
454 color_e::OtherConst) : v_->PrettyTree(seen);
455 x1->children->append(h);
456 }
457 L->append(Alloc<Field>(StrFromC("lines"), x1));
458 }
459
460 return out_node;
461}
462
463BigStr* cmd_frag_str(int tag, bool dot) {
464 char buf[32];
465 const char* v = nullptr;
466 switch (tag) {
467 case cmd_frag_e::LiteralBlock:
468 v = "LiteralBlock"; break;
469 case cmd_frag_e::Expr:
470 v = "Expr"; break;
471 default:
472 assert(0);
473 }
474 if (dot) {
475 snprintf(buf, 32, "cmd_frag.%s", v);
476 return StrFromC(buf);
477 } else {
478 return StrFromC(v);
479 }
480}
481
482hnode_t* cmd_frag__Expr::PrettyTree(Dict<int, bool>* seen) {
483 seen = seen ? seen : Alloc<Dict<int, bool>>();
484 int heap_id = ObjectId(this);
485 if (dict_contains(seen, heap_id)) {
486 return Alloc<hnode::AlreadySeen>(heap_id);
487 }
488 seen->set(heap_id, true);
489
490 hnode::Record* out_node = runtime::NewRecord(cmd_frag_str(this->tag()));
491 List<Field*>* L = out_node->fields;
492
493 hnode_t* x0 = this->c->PrettyTree(seen);
494 L->append(Alloc<Field>(StrFromC("c"), x0));
495
496 return out_node;
497}
498
499
500hnode_t* cmd_frag_t::PrettyTree(Dict<int, bool>* seen) {
501 switch (this->tag()) {
502 case cmd_frag_e::LiteralBlock: {
503 LiteralBlock* obj = static_cast<LiteralBlock*>(this);
504 return obj->PrettyTree(seen);
505 }
506 case cmd_frag_e::Expr: {
507 cmd_frag__Expr* obj = static_cast<cmd_frag__Expr*>(this);
508 return obj->PrettyTree(seen);
509 }
510 default:
511 assert(0);
512 }
513}
514
515hnode_t* Obj::PrettyTree(Dict<int, bool>* seen) {
516 seen = seen ? seen : Alloc<Dict<int, bool>>();
517 int heap_id = ObjectId(this);
518 if (dict_contains(seen, heap_id)) {
519 return Alloc<hnode::AlreadySeen>(heap_id);
520 }
521 seen->set(heap_id, true);
522
523 hnode::Record* out_node = runtime::NewRecord(StrFromC("Obj"));
524 List<Field*>* L = out_node->fields;
525
526 if (this->prototype) { // Optional
527 hnode_t* x0 = this->prototype->PrettyTree(seen);
528 L->append(Alloc<Field>(StrFromC("prototype"), x0));
529 }
530
531 if (this->d) { // Dict
532 auto m = Alloc<hnode::Leaf>(StrFromC("Dict"), color_e::OtherConst);
533 hnode::Array* x1 = Alloc<hnode::Array>(NewList<hnode_t*>({m}));
534 for (DictIter<BigStr*, value_t*> it(this->d); !it.Done(); it.Next()) {
535 auto k1 = it.Key();
536 auto v1 = it.Value();
537 x1->children->append(runtime::NewLeaf(k1, color_e::StringConst));
538 x1->children->append(v1->PrettyTree(seen));
539 }
540 L->append(Alloc<Field>(StrFromC ("d"), x1));
541 }
542
543 return out_node;
544}
545
546BigStr* value_str(int tag, bool dot) {
547 char buf[32];
548 const char* v = nullptr;
549 switch (tag) {
550 case value_e::Interrupted:
551 v = "Interrupted"; break;
552 case value_e::Stdin:
553 v = "Stdin"; break;
554 case value_e::Slice:
555 v = "Slice"; break;
556 case value_e::Undef:
557 v = "Undef"; break;
558 case value_e::Str:
559 v = "Str"; break;
560 case value_e::BashArray:
561 v = "BashArray"; break;
562 case value_e::SparseArray:
563 v = "SparseArray"; break;
564 case value_e::BashAssoc:
565 v = "BashAssoc"; break;
566 case value_e::Null:
567 v = "Null"; break;
568 case value_e::Bool:
569 v = "Bool"; break;
570 case value_e::Int:
571 v = "Int"; break;
572 case value_e::Float:
573 v = "Float"; break;
574 case value_e::List:
575 v = "List"; break;
576 case value_e::Dict:
577 v = "Dict"; break;
578 case value_e::Obj:
579 v = "Obj"; break;
580 case value_e::Range:
581 v = "Range"; break;
582 case value_e::Eggex:
583 v = "Eggex"; break;
584 case value_e::Match:
585 v = "Match"; break;
586 case value_e::Place:
587 v = "Place"; break;
588 case value_e::Frame:
589 v = "Frame"; break;
590 case value_e::BoundFunc:
591 v = "BoundFunc"; break;
592 case value_e::BuiltinFunc:
593 v = "BuiltinFunc"; break;
594 case value_e::Func:
595 v = "Func"; break;
596 case value_e::BuiltinProc:
597 v = "BuiltinProc"; break;
598 case value_e::Proc:
599 v = "Proc"; break;
600 case value_e::Expr:
601 v = "Expr"; break;
602 case value_e::CommandFrag:
603 v = "CommandFrag"; break;
604 case value_e::Command:
605 v = "Command"; break;
606 default:
607 assert(0);
608 }
609 if (dot) {
610 snprintf(buf, 32, "value.%s", v);
611 return StrFromC(buf);
612 } else {
613 return StrFromC(v);
614 }
615}
616
617value__Interrupted* value::Interrupted = &gvalue__Interrupted.obj;
618
619GcGlobal<value__Interrupted> gvalue__Interrupted =
620 { ObjHeader::Global(value_e::Interrupted) };
621
622value__Stdin* value::Stdin = &gvalue__Stdin.obj;
623
624GcGlobal<value__Stdin> gvalue__Stdin =
625 { ObjHeader::Global(value_e::Stdin) };
626
627value__Undef* value::Undef = &gvalue__Undef.obj;
628
629GcGlobal<value__Undef> gvalue__Undef =
630 { ObjHeader::Global(value_e::Undef) };
631
632value__Null* value::Null = &gvalue__Null.obj;
633
634GcGlobal<value__Null> gvalue__Null =
635 { ObjHeader::Global(value_e::Null) };
636
637hnode_t* value__Interrupted::PrettyTree(Dict<int, bool>* seen) {
638 seen = seen ? seen : Alloc<Dict<int, bool>>();
639 int heap_id = ObjectId(this);
640 if (dict_contains(seen, heap_id)) {
641 return Alloc<hnode::AlreadySeen>(heap_id);
642 }
643 seen->set(heap_id, true);
644
645 hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
646 return out_node;
647}
648
649
650hnode_t* value__Stdin::PrettyTree(Dict<int, bool>* seen) {
651 seen = seen ? seen : Alloc<Dict<int, bool>>();
652 int heap_id = ObjectId(this);
653 if (dict_contains(seen, heap_id)) {
654 return Alloc<hnode::AlreadySeen>(heap_id);
655 }
656 seen->set(heap_id, true);
657
658 hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
659 return out_node;
660}
661
662
663hnode_t* value__Slice::PrettyTree(Dict<int, bool>* seen) {
664 seen = seen ? seen : Alloc<Dict<int, bool>>();
665 int heap_id = ObjectId(this);
666 if (dict_contains(seen, heap_id)) {
667 return Alloc<hnode::AlreadySeen>(heap_id);
668 }
669 seen->set(heap_id, true);
670
671 hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
672 List<Field*>* L = out_node->fields;
673
674 if (this->lower) { // Optional
675 hnode_t* x0 = this->lower->PrettyTree(seen);
676 L->append(Alloc<Field>(StrFromC("lower"), x0));
677 }
678
679 if (this->upper) { // Optional
680 hnode_t* x1 = this->upper->PrettyTree(seen);
681 L->append(Alloc<Field>(StrFromC("upper"), x1));
682 }
683
684 return out_node;
685}
686
687
688hnode_t* value__Undef::PrettyTree(Dict<int, bool>* seen) {
689 seen = seen ? seen : Alloc<Dict<int, bool>>();
690 int heap_id = ObjectId(this);
691 if (dict_contains(seen, heap_id)) {
692 return Alloc<hnode::AlreadySeen>(heap_id);
693 }
694 seen->set(heap_id, true);
695
696 hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
697 return out_node;
698}
699
700
701hnode_t* value__Str::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
709 hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
710 List<Field*>* L = out_node->fields;
711
712 hnode_t* x0 = runtime::NewLeaf(this->s, color_e::StringConst);
713 L->append(Alloc<Field>(StrFromC("s"), x0));
714
715 return out_node;
716}
717
718
719hnode_t* value__BashArray::PrettyTree(Dict<int, bool>* seen) {
720 seen = seen ? seen : Alloc<Dict<int, bool>>();
721 int heap_id = ObjectId(this);
722 if (dict_contains(seen, heap_id)) {
723 return Alloc<hnode::AlreadySeen>(heap_id);
724 }
725 seen->set(heap_id, true);
726
727 hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
728 List<Field*>* L = out_node->fields;
729
730 if (this->strs != nullptr) { // List
731 hnode::Array* x0 = Alloc<hnode::Array>(Alloc<List<hnode_t*>>());
732 for (ListIter<BigStr*> it(this->strs); !it.Done(); it.Next()) {
733 BigStr* v_ = it.Value();
734 hnode_t* h = runtime::NewLeaf(v_, color_e::StringConst);
735 x0->children->append(h);
736 }
737 L->append(Alloc<Field>(StrFromC("strs"), x0));
738 }
739
740 return out_node;
741}
742
743
744hnode_t* value__SparseArray::PrettyTree(Dict<int, bool>* seen) {
745 seen = seen ? seen : Alloc<Dict<int, bool>>();
746 int heap_id = ObjectId(this);
747 if (dict_contains(seen, heap_id)) {
748 return Alloc<hnode::AlreadySeen>(heap_id);
749 }
750 seen->set(heap_id, true);
751
752 hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
753 List<Field*>* L = out_node->fields;
754
755 if (this->d) { // Dict
756 auto m = Alloc<hnode::Leaf>(StrFromC("Dict"), color_e::OtherConst);
757 hnode::Array* x0 = Alloc<hnode::Array>(NewList<hnode_t*>({m}));
758 for (DictIter<mops::BigInt, BigStr*> it(this->d); !it.Done(); it.Next()) {
759 auto k0 = it.Key();
760 auto v0 = it.Value();
761 x0->children->append(Alloc<hnode::Leaf>(mops::ToStr(k0),
762 color_e::OtherConst));
763 x0->children->append(runtime::NewLeaf(v0, color_e::StringConst));
764 }
765 L->append(Alloc<Field>(StrFromC ("d"), x0));
766 }
767
768 hnode_t* x1 = Alloc<hnode::Leaf>(mops::ToStr(this->max_index),
769 color_e::OtherConst);
770 L->append(Alloc<Field>(StrFromC("max_index"), x1));
771
772 return out_node;
773}
774
775
776hnode_t* value__BashAssoc::PrettyTree(Dict<int, bool>* seen) {
777 seen = seen ? seen : Alloc<Dict<int, bool>>();
778 int heap_id = ObjectId(this);
779 if (dict_contains(seen, heap_id)) {
780 return Alloc<hnode::AlreadySeen>(heap_id);
781 }
782 seen->set(heap_id, true);
783
784 hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
785 List<Field*>* L = out_node->fields;
786
787 if (this->d) { // Dict
788 auto m = Alloc<hnode::Leaf>(StrFromC("Dict"), color_e::OtherConst);
789 hnode::Array* x0 = Alloc<hnode::Array>(NewList<hnode_t*>({m}));
790 for (DictIter<BigStr*, BigStr*> it(this->d); !it.Done(); it.Next()) {
791 auto k0 = it.Key();
792 auto v0 = it.Value();
793 x0->children->append(runtime::NewLeaf(k0, color_e::StringConst));
794 x0->children->append(runtime::NewLeaf(v0, color_e::StringConst));
795 }
796 L->append(Alloc<Field>(StrFromC ("d"), x0));
797 }
798
799 return out_node;
800}
801
802
803hnode_t* value__Null::PrettyTree(Dict<int, bool>* seen) {
804 seen = seen ? seen : Alloc<Dict<int, bool>>();
805 int heap_id = ObjectId(this);
806 if (dict_contains(seen, heap_id)) {
807 return Alloc<hnode::AlreadySeen>(heap_id);
808 }
809 seen->set(heap_id, true);
810
811 hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
812 return out_node;
813}
814
815
816hnode_t* value__Bool::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
824 hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
825 List<Field*>* L = out_node->fields;
826
827 hnode_t* x0 = Alloc<hnode::Leaf>(this->b ? runtime::TRUE_STR :
828 runtime::FALSE_STR, color_e::OtherConst);
829 L->append(Alloc<Field>(StrFromC("b"), x0));
830
831 return out_node;
832}
833
834
835hnode_t* value__Int::PrettyTree(Dict<int, bool>* seen) {
836 seen = seen ? seen : Alloc<Dict<int, bool>>();
837 int heap_id = ObjectId(this);
838 if (dict_contains(seen, heap_id)) {
839 return Alloc<hnode::AlreadySeen>(heap_id);
840 }
841 seen->set(heap_id, true);
842
843 hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
844 List<Field*>* L = out_node->fields;
845
846 hnode_t* x0 = Alloc<hnode::Leaf>(mops::ToStr(this->i), color_e::OtherConst);
847 L->append(Alloc<Field>(StrFromC("i"), x0));
848
849 return out_node;
850}
851
852
853hnode_t* value__Float::PrettyTree(Dict<int, bool>* seen) {
854 seen = seen ? seen : Alloc<Dict<int, bool>>();
855 int heap_id = ObjectId(this);
856 if (dict_contains(seen, heap_id)) {
857 return Alloc<hnode::AlreadySeen>(heap_id);
858 }
859 seen->set(heap_id, true);
860
861 hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
862 List<Field*>* L = out_node->fields;
863
864 hnode_t* x0 = Alloc<hnode::Leaf>(str(this->f), color_e::OtherConst);
865 L->append(Alloc<Field>(StrFromC("f"), x0));
866
867 return out_node;
868}
869
870
871hnode_t* value__List::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
879 hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
880 List<Field*>* L = out_node->fields;
881
882 if (this->items != nullptr) { // List
883 hnode::Array* x0 = Alloc<hnode::Array>(Alloc<List<hnode_t*>>());
884 for (ListIter<value_t*> it(this->items); !it.Done(); it.Next()) {
885 value_t* v_ = it.Value();
886 hnode_t* h = (v_ == nullptr) ? Alloc<hnode::Leaf>(StrFromC("_"),
887 color_e::OtherConst) : v_->PrettyTree(seen);
888 x0->children->append(h);
889 }
890 L->append(Alloc<Field>(StrFromC("items"), x0));
891 }
892
893 return out_node;
894}
895
896
897hnode_t* value__Dict::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
905 hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
906 List<Field*>* L = out_node->fields;
907
908 if (this->d) { // Dict
909 auto m = Alloc<hnode::Leaf>(StrFromC("Dict"), color_e::OtherConst);
910 hnode::Array* x0 = Alloc<hnode::Array>(NewList<hnode_t*>({m}));
911 for (DictIter<BigStr*, value_t*> it(this->d); !it.Done(); it.Next()) {
912 auto k0 = it.Key();
913 auto v0 = it.Value();
914 x0->children->append(runtime::NewLeaf(k0, color_e::StringConst));
915 x0->children->append(v0->PrettyTree(seen));
916 }
917 L->append(Alloc<Field>(StrFromC ("d"), x0));
918 }
919
920 return out_node;
921}
922
923
924hnode_t* value__Range::PrettyTree(Dict<int, bool>* seen) {
925 seen = seen ? seen : Alloc<Dict<int, bool>>();
926 int heap_id = ObjectId(this);
927 if (dict_contains(seen, heap_id)) {
928 return Alloc<hnode::AlreadySeen>(heap_id);
929 }
930 seen->set(heap_id, true);
931
932 hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
933 List<Field*>* L = out_node->fields;
934
935 hnode_t* x0 = Alloc<hnode::Leaf>(str(this->lower), color_e::OtherConst);
936 L->append(Alloc<Field>(StrFromC("lower"), x0));
937
938 hnode_t* x1 = Alloc<hnode::Leaf>(str(this->upper), color_e::OtherConst);
939 L->append(Alloc<Field>(StrFromC("upper"), x1));
940
941 return out_node;
942}
943
944
945hnode_t* value__Eggex::PrettyTree(Dict<int, bool>* seen) {
946 seen = seen ? seen : Alloc<Dict<int, bool>>();
947 int heap_id = ObjectId(this);
948 if (dict_contains(seen, heap_id)) {
949 return Alloc<hnode::AlreadySeen>(heap_id);
950 }
951 seen->set(heap_id, true);
952
953 hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
954 List<Field*>* L = out_node->fields;
955
956 hnode_t* x0 = this->spliced->PrettyTree(seen);
957 L->append(Alloc<Field>(StrFromC("spliced"), x0));
958
959 hnode_t* x1 = runtime::NewLeaf(this->canonical_flags, color_e::StringConst);
960 L->append(Alloc<Field>(StrFromC("canonical_flags"), x1));
961
962 if (this->convert_funcs != nullptr) { // List
963 hnode::Array* x2 = Alloc<hnode::Array>(Alloc<List<hnode_t*>>());
964 for (ListIter<value_t*> it(this->convert_funcs); !it.Done(); it.Next()) {
965 value_t* v_ = it.Value();
966 hnode_t* h = (v_ == nullptr) ? Alloc<hnode::Leaf>(StrFromC("_"),
967 color_e::OtherConst) : v_->PrettyTree(seen);
968 x2->children->append(h);
969 }
970 L->append(Alloc<Field>(StrFromC("convert_funcs"), x2));
971 }
972
973 if (this->convert_toks != nullptr) { // List
974 hnode::Array* x3 = Alloc<hnode::Array>(Alloc<List<hnode_t*>>());
975 for (ListIter<syntax_asdl::Token*> it(this->convert_toks); !it.Done();
976 it.Next()) {
977 syntax_asdl::Token* v_ = it.Value();
978 hnode_t* h = (v_ == nullptr) ? Alloc<hnode::Leaf>(StrFromC("_"),
979 color_e::OtherConst) : v_->PrettyTree(seen);
980 x3->children->append(h);
981 }
982 L->append(Alloc<Field>(StrFromC("convert_toks"), x3));
983 }
984
985 if (this->as_ere) { // Optional
986 hnode_t* x4 = runtime::NewLeaf(this->as_ere, color_e::StringConst);
987 L->append(Alloc<Field>(StrFromC("as_ere"), x4));
988 }
989
990 if (this->capture_names != nullptr) { // List
991 hnode::Array* x5 = Alloc<hnode::Array>(Alloc<List<hnode_t*>>());
992 for (ListIter<BigStr*> it(this->capture_names); !it.Done(); it.Next()) {
993 BigStr* v_ = it.Value();
994 hnode_t* h = runtime::NewLeaf(v_, color_e::StringConst);
995 x5->children->append(h);
996 }
997 L->append(Alloc<Field>(StrFromC("capture_names"), x5));
998 }
999
1000 return out_node;
1001}
1002
1003
1004hnode_t* value__Place::PrettyTree(Dict<int, bool>* seen) {
1005 seen = seen ? seen : Alloc<Dict<int, bool>>();
1006 int heap_id = ObjectId(this);
1007 if (dict_contains(seen, heap_id)) {
1008 return Alloc<hnode::AlreadySeen>(heap_id);
1009 }
1010 seen->set(heap_id, true);
1011
1012 hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
1013 List<Field*>* L = out_node->fields;
1014
1015 hnode_t* x0 = this->lval->PrettyTree(seen);
1016 L->append(Alloc<Field>(StrFromC("lval"), x0));
1017
1018 if (this->frame) { // Dict
1019 auto m = Alloc<hnode::Leaf>(StrFromC("Dict"), color_e::OtherConst);
1020 hnode::Array* x1 = Alloc<hnode::Array>(NewList<hnode_t*>({m}));
1021 for (DictIter<BigStr*, runtime_asdl::Cell*> it(this->frame); !it.Done();
1022 it.Next()) {
1023 auto k1 = it.Key();
1024 auto v1 = it.Value();
1025 x1->children->append(runtime::NewLeaf(k1, color_e::StringConst));
1026 x1->children->append(v1->PrettyTree(seen));
1027 }
1028 L->append(Alloc<Field>(StrFromC ("frame"), x1));
1029 }
1030
1031 return out_node;
1032}
1033
1034
1035hnode_t* value__Frame::PrettyTree(Dict<int, bool>* seen) {
1036 seen = seen ? seen : Alloc<Dict<int, bool>>();
1037 int heap_id = ObjectId(this);
1038 if (dict_contains(seen, heap_id)) {
1039 return Alloc<hnode::AlreadySeen>(heap_id);
1040 }
1041 seen->set(heap_id, true);
1042
1043 hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
1044 List<Field*>* L = out_node->fields;
1045
1046 if (this->frame) { // Dict
1047 auto m = Alloc<hnode::Leaf>(StrFromC("Dict"), color_e::OtherConst);
1048 hnode::Array* x0 = Alloc<hnode::Array>(NewList<hnode_t*>({m}));
1049 for (DictIter<BigStr*, runtime_asdl::Cell*> it(this->frame); !it.Done();
1050 it.Next()) {
1051 auto k0 = it.Key();
1052 auto v0 = it.Value();
1053 x0->children->append(runtime::NewLeaf(k0, color_e::StringConst));
1054 x0->children->append(v0->PrettyTree(seen));
1055 }
1056 L->append(Alloc<Field>(StrFromC ("frame"), x0));
1057 }
1058
1059 return out_node;
1060}
1061
1062
1063hnode_t* value__BoundFunc::PrettyTree(Dict<int, bool>* seen) {
1064 seen = seen ? seen : Alloc<Dict<int, bool>>();
1065 int heap_id = ObjectId(this);
1066 if (dict_contains(seen, heap_id)) {
1067 return Alloc<hnode::AlreadySeen>(heap_id);
1068 }
1069 seen->set(heap_id, true);
1070
1071 hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
1072 List<Field*>* L = out_node->fields;
1073
1074 hnode_t* x0 = this->me->PrettyTree(seen);
1075 L->append(Alloc<Field>(StrFromC("me"), x0));
1076
1077 hnode_t* x1 = this->func->PrettyTree(seen);
1078 L->append(Alloc<Field>(StrFromC("func"), x1));
1079
1080 return out_node;
1081}
1082
1083
1084hnode_t* value__BuiltinFunc::PrettyTree(Dict<int, bool>* seen) {
1085 seen = seen ? seen : Alloc<Dict<int, bool>>();
1086 int heap_id = ObjectId(this);
1087 if (dict_contains(seen, heap_id)) {
1088 return Alloc<hnode::AlreadySeen>(heap_id);
1089 }
1090 seen->set(heap_id, true);
1091
1092 hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
1093 List<Field*>* L = out_node->fields;
1094
1095 hnode_t* x0 = Alloc<hnode::External>(this->callable);
1096 L->append(Alloc<Field>(StrFromC("callable"), x0));
1097
1098 return out_node;
1099}
1100
1101
1102hnode_t* value__Func::PrettyTree(Dict<int, bool>* seen) {
1103 seen = seen ? seen : Alloc<Dict<int, bool>>();
1104 int heap_id = ObjectId(this);
1105 if (dict_contains(seen, heap_id)) {
1106 return Alloc<hnode::AlreadySeen>(heap_id);
1107 }
1108 seen->set(heap_id, true);
1109
1110 hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
1111 List<Field*>* L = out_node->fields;
1112
1113 hnode_t* x0 = runtime::NewLeaf(this->name, color_e::StringConst);
1114 L->append(Alloc<Field>(StrFromC("name"), x0));
1115
1116 hnode_t* x1 = this->parsed->PrettyTree(seen);
1117 L->append(Alloc<Field>(StrFromC("parsed"), x1));
1118
1119 if (this->pos_defaults != nullptr) { // List
1120 hnode::Array* x2 = Alloc<hnode::Array>(Alloc<List<hnode_t*>>());
1121 for (ListIter<value_t*> it(this->pos_defaults); !it.Done(); it.Next()) {
1122 value_t* v_ = it.Value();
1123 hnode_t* h = (v_ == nullptr) ? Alloc<hnode::Leaf>(StrFromC("_"),
1124 color_e::OtherConst) : v_->PrettyTree(seen);
1125 x2->children->append(h);
1126 }
1127 L->append(Alloc<Field>(StrFromC("pos_defaults"), x2));
1128 }
1129
1130 if (this->named_defaults) { // Dict
1131 auto m = Alloc<hnode::Leaf>(StrFromC("Dict"), color_e::OtherConst);
1132 hnode::Array* x3 = Alloc<hnode::Array>(NewList<hnode_t*>({m}));
1133 for (DictIter<BigStr*, value_t*> it(this->named_defaults); !it.Done();
1134 it.Next()) {
1135 auto k3 = it.Key();
1136 auto v3 = it.Value();
1137 x3->children->append(runtime::NewLeaf(k3, color_e::StringConst));
1138 x3->children->append(v3->PrettyTree(seen));
1139 }
1140 L->append(Alloc<Field>(StrFromC ("named_defaults"), x3));
1141 }
1142
1143 if (this->module_frame) { // Dict
1144 auto m = Alloc<hnode::Leaf>(StrFromC("Dict"), color_e::OtherConst);
1145 hnode::Array* x4 = Alloc<hnode::Array>(NewList<hnode_t*>({m}));
1146 for (DictIter<BigStr*, runtime_asdl::Cell*> it(this->module_frame);
1147 !it.Done(); it.Next()) {
1148 auto k4 = it.Key();
1149 auto v4 = it.Value();
1150 x4->children->append(runtime::NewLeaf(k4, color_e::StringConst));
1151 x4->children->append(v4->PrettyTree(seen));
1152 }
1153 L->append(Alloc<Field>(StrFromC ("module_frame"), x4));
1154 }
1155
1156 return out_node;
1157}
1158
1159
1160hnode_t* value__BuiltinProc::PrettyTree(Dict<int, bool>* seen) {
1161 seen = seen ? seen : Alloc<Dict<int, bool>>();
1162 int heap_id = ObjectId(this);
1163 if (dict_contains(seen, heap_id)) {
1164 return Alloc<hnode::AlreadySeen>(heap_id);
1165 }
1166 seen->set(heap_id, true);
1167
1168 hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
1169 List<Field*>* L = out_node->fields;
1170
1171 hnode_t* x0 = Alloc<hnode::External>(this->builtin);
1172 L->append(Alloc<Field>(StrFromC("builtin"), x0));
1173
1174 return out_node;
1175}
1176
1177
1178hnode_t* value__Proc::PrettyTree(Dict<int, bool>* seen) {
1179 seen = seen ? seen : Alloc<Dict<int, bool>>();
1180 int heap_id = ObjectId(this);
1181 if (dict_contains(seen, heap_id)) {
1182 return Alloc<hnode::AlreadySeen>(heap_id);
1183 }
1184 seen->set(heap_id, true);
1185
1186 hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
1187 List<Field*>* L = out_node->fields;
1188
1189 hnode_t* x0 = runtime::NewLeaf(this->name, color_e::StringConst);
1190 L->append(Alloc<Field>(StrFromC("name"), x0));
1191
1192 hnode_t* x1 = this->name_tok->PrettyTree(seen);
1193 L->append(Alloc<Field>(StrFromC("name_tok"), x1));
1194
1195 hnode_t* x2 = this->sig->PrettyTree(seen);
1196 L->append(Alloc<Field>(StrFromC("sig"), x2));
1197
1198 hnode_t* x3 = this->body->PrettyTree(seen);
1199 L->append(Alloc<Field>(StrFromC("body"), x3));
1200
1201 if (this->defaults) { // Optional
1202 hnode_t* x4 = this->defaults->PrettyTree(seen);
1203 L->append(Alloc<Field>(StrFromC("defaults"), x4));
1204 }
1205
1206 hnode_t* x5 = Alloc<hnode::Leaf>(this->sh_compat ? runtime::TRUE_STR :
1207 runtime::FALSE_STR, color_e::OtherConst);
1208 L->append(Alloc<Field>(StrFromC("sh_compat"), x5));
1209
1210 if (this->module_frame) { // Dict
1211 auto m = Alloc<hnode::Leaf>(StrFromC("Dict"), color_e::OtherConst);
1212 hnode::Array* x6 = Alloc<hnode::Array>(NewList<hnode_t*>({m}));
1213 for (DictIter<BigStr*, runtime_asdl::Cell*> it(this->module_frame);
1214 !it.Done(); it.Next()) {
1215 auto k6 = it.Key();
1216 auto v6 = it.Value();
1217 x6->children->append(runtime::NewLeaf(k6, color_e::StringConst));
1218 x6->children->append(v6->PrettyTree(seen));
1219 }
1220 L->append(Alloc<Field>(StrFromC ("module_frame"), x6));
1221 }
1222
1223 return out_node;
1224}
1225
1226
1227hnode_t* value__Expr::PrettyTree(Dict<int, bool>* seen) {
1228 seen = seen ? seen : Alloc<Dict<int, bool>>();
1229 int heap_id = ObjectId(this);
1230 if (dict_contains(seen, heap_id)) {
1231 return Alloc<hnode::AlreadySeen>(heap_id);
1232 }
1233 seen->set(heap_id, true);
1234
1235 hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
1236 List<Field*>* L = out_node->fields;
1237
1238 hnode_t* x0 = this->e->PrettyTree(seen);
1239 L->append(Alloc<Field>(StrFromC("e"), x0));
1240
1241 if (this->captured_frame) { // Dict
1242 auto m = Alloc<hnode::Leaf>(StrFromC("Dict"), color_e::OtherConst);
1243 hnode::Array* x1 = Alloc<hnode::Array>(NewList<hnode_t*>({m}));
1244 for (DictIter<BigStr*, runtime_asdl::Cell*> it(this->captured_frame);
1245 !it.Done(); it.Next()) {
1246 auto k1 = it.Key();
1247 auto v1 = it.Value();
1248 x1->children->append(runtime::NewLeaf(k1, color_e::StringConst));
1249 x1->children->append(v1->PrettyTree(seen));
1250 }
1251 L->append(Alloc<Field>(StrFromC ("captured_frame"), x1));
1252 }
1253
1254 if (this->module_frame) { // Dict
1255 auto m = Alloc<hnode::Leaf>(StrFromC("Dict"), color_e::OtherConst);
1256 hnode::Array* x2 = Alloc<hnode::Array>(NewList<hnode_t*>({m}));
1257 for (DictIter<BigStr*, runtime_asdl::Cell*> it(this->module_frame);
1258 !it.Done(); it.Next()) {
1259 auto k2 = it.Key();
1260 auto v2 = it.Value();
1261 x2->children->append(runtime::NewLeaf(k2, color_e::StringConst));
1262 x2->children->append(v2->PrettyTree(seen));
1263 }
1264 L->append(Alloc<Field>(StrFromC ("module_frame"), x2));
1265 }
1266
1267 return out_node;
1268}
1269
1270
1271hnode_t* value__CommandFrag::PrettyTree(Dict<int, bool>* seen) {
1272 seen = seen ? seen : Alloc<Dict<int, bool>>();
1273 int heap_id = ObjectId(this);
1274 if (dict_contains(seen, heap_id)) {
1275 return Alloc<hnode::AlreadySeen>(heap_id);
1276 }
1277 seen->set(heap_id, true);
1278
1279 hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
1280 List<Field*>* L = out_node->fields;
1281
1282 hnode_t* x0 = this->c->PrettyTree(seen);
1283 L->append(Alloc<Field>(StrFromC("c"), x0));
1284
1285 return out_node;
1286}
1287
1288
1289hnode_t* value__Command::PrettyTree(Dict<int, bool>* seen) {
1290 seen = seen ? seen : Alloc<Dict<int, bool>>();
1291 int heap_id = ObjectId(this);
1292 if (dict_contains(seen, heap_id)) {
1293 return Alloc<hnode::AlreadySeen>(heap_id);
1294 }
1295 seen->set(heap_id, true);
1296
1297 hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
1298 List<Field*>* L = out_node->fields;
1299
1300 hnode_t* x0 = this->frag->PrettyTree(seen);
1301 L->append(Alloc<Field>(StrFromC("frag"), x0));
1302
1303 if (this->captured_frame) { // Dict
1304 auto m = Alloc<hnode::Leaf>(StrFromC("Dict"), color_e::OtherConst);
1305 hnode::Array* x1 = Alloc<hnode::Array>(NewList<hnode_t*>({m}));
1306 for (DictIter<BigStr*, runtime_asdl::Cell*> it(this->captured_frame);
1307 !it.Done(); it.Next()) {
1308 auto k1 = it.Key();
1309 auto v1 = it.Value();
1310 x1->children->append(runtime::NewLeaf(k1, color_e::StringConst));
1311 x1->children->append(v1->PrettyTree(seen));
1312 }
1313 L->append(Alloc<Field>(StrFromC ("captured_frame"), x1));
1314 }
1315
1316 if (this->module_frame) { // Dict
1317 auto m = Alloc<hnode::Leaf>(StrFromC("Dict"), color_e::OtherConst);
1318 hnode::Array* x2 = Alloc<hnode::Array>(NewList<hnode_t*>({m}));
1319 for (DictIter<BigStr*, runtime_asdl::Cell*> it(this->module_frame);
1320 !it.Done(); it.Next()) {
1321 auto k2 = it.Key();
1322 auto v2 = it.Value();
1323 x2->children->append(runtime::NewLeaf(k2, color_e::StringConst));
1324 x2->children->append(v2->PrettyTree(seen));
1325 }
1326 L->append(Alloc<Field>(StrFromC ("module_frame"), x2));
1327 }
1328
1329 return out_node;
1330}
1331
1332
1333hnode_t* value_t::PrettyTree(Dict<int, bool>* seen) {
1334 switch (this->tag()) {
1335 case value_e::Interrupted: {
1336 value__Interrupted* obj = static_cast<value__Interrupted*>(this);
1337 return obj->PrettyTree(seen);
1338 }
1339 case value_e::Stdin: {
1340 value__Stdin* obj = static_cast<value__Stdin*>(this);
1341 return obj->PrettyTree(seen);
1342 }
1343 case value_e::Slice: {
1344 value__Slice* obj = static_cast<value__Slice*>(this);
1345 return obj->PrettyTree(seen);
1346 }
1347 case value_e::Undef: {
1348 value__Undef* obj = static_cast<value__Undef*>(this);
1349 return obj->PrettyTree(seen);
1350 }
1351 case value_e::Str: {
1352 value__Str* obj = static_cast<value__Str*>(this);
1353 return obj->PrettyTree(seen);
1354 }
1355 case value_e::BashArray: {
1356 value__BashArray* obj = static_cast<value__BashArray*>(this);
1357 return obj->PrettyTree(seen);
1358 }
1359 case value_e::SparseArray: {
1360 value__SparseArray* obj = static_cast<value__SparseArray*>(this);
1361 return obj->PrettyTree(seen);
1362 }
1363 case value_e::BashAssoc: {
1364 value__BashAssoc* obj = static_cast<value__BashAssoc*>(this);
1365 return obj->PrettyTree(seen);
1366 }
1367 case value_e::Null: {
1368 value__Null* obj = static_cast<value__Null*>(this);
1369 return obj->PrettyTree(seen);
1370 }
1371 case value_e::Bool: {
1372 value__Bool* obj = static_cast<value__Bool*>(this);
1373 return obj->PrettyTree(seen);
1374 }
1375 case value_e::Int: {
1376 value__Int* obj = static_cast<value__Int*>(this);
1377 return obj->PrettyTree(seen);
1378 }
1379 case value_e::Float: {
1380 value__Float* obj = static_cast<value__Float*>(this);
1381 return obj->PrettyTree(seen);
1382 }
1383 case value_e::List: {
1384 value__List* obj = static_cast<value__List*>(this);
1385 return obj->PrettyTree(seen);
1386 }
1387 case value_e::Dict: {
1388 value__Dict* obj = static_cast<value__Dict*>(this);
1389 return obj->PrettyTree(seen);
1390 }
1391 case value_e::Obj: {
1392 Obj* obj = static_cast<Obj*>(this);
1393 return obj->PrettyTree(seen);
1394 }
1395 case value_e::Range: {
1396 value__Range* obj = static_cast<value__Range*>(this);
1397 return obj->PrettyTree(seen);
1398 }
1399 case value_e::Eggex: {
1400 value__Eggex* obj = static_cast<value__Eggex*>(this);
1401 return obj->PrettyTree(seen);
1402 }
1403 case value_e::Match: {
1404 RegexMatch* obj = static_cast<RegexMatch*>(this);
1405 return obj->PrettyTree(seen);
1406 }
1407 case value_e::Place: {
1408 value__Place* obj = static_cast<value__Place*>(this);
1409 return obj->PrettyTree(seen);
1410 }
1411 case value_e::Frame: {
1412 value__Frame* obj = static_cast<value__Frame*>(this);
1413 return obj->PrettyTree(seen);
1414 }
1415 case value_e::BoundFunc: {
1416 value__BoundFunc* obj = static_cast<value__BoundFunc*>(this);
1417 return obj->PrettyTree(seen);
1418 }
1419 case value_e::BuiltinFunc: {
1420 value__BuiltinFunc* obj = static_cast<value__BuiltinFunc*>(this);
1421 return obj->PrettyTree(seen);
1422 }
1423 case value_e::Func: {
1424 value__Func* obj = static_cast<value__Func*>(this);
1425 return obj->PrettyTree(seen);
1426 }
1427 case value_e::BuiltinProc: {
1428 value__BuiltinProc* obj = static_cast<value__BuiltinProc*>(this);
1429 return obj->PrettyTree(seen);
1430 }
1431 case value_e::Proc: {
1432 value__Proc* obj = static_cast<value__Proc*>(this);
1433 return obj->PrettyTree(seen);
1434 }
1435 case value_e::Expr: {
1436 value__Expr* obj = static_cast<value__Expr*>(this);
1437 return obj->PrettyTree(seen);
1438 }
1439 case value_e::CommandFrag: {
1440 value__CommandFrag* obj = static_cast<value__CommandFrag*>(this);
1441 return obj->PrettyTree(seen);
1442 }
1443 case value_e::Command: {
1444 value__Command* obj = static_cast<value__Command*>(this);
1445 return obj->PrettyTree(seen);
1446 }
1447 default:
1448 assert(0);
1449 }
1450}
1451
1452} // namespace value_asdl