OILS / _gen / core / value.asdl.cc View on Github | oils.pub

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