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

1279 lines, 927 significant
1// _gen/core/runtime.asdl.cc is generated by asdl_main.py
2
3#include "_gen/core/runtime.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/value.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
14using id_kind_asdl::Id_str;
15
16namespace runtime_asdl {
17
18
19hnode_t* AssignArg::PrettyTree(Dict<int, bool>* seen) {
20 seen = seen ? seen : Alloc<Dict<int, bool>>();
21 int heap_id = ObjectId(this);
22 if (dict_contains(seen, heap_id)) {
23 return Alloc<hnode::AlreadySeen>(heap_id);
24 }
25 seen->set(heap_id, true);
26 hnode::Record* out_node = runtime::NewRecord(StrFromC("AssignArg"));
27 List<Field*>* L = out_node->fields;
28
29 hnode_t* x0 = runtime::NewLeaf(this->var_name, color_e::StringConst);
30 L->append(Alloc<Field>(StrFromC("var_name"), x0));
31
32 if (this->rval) { // Optional
33 hnode_t* x1 = this->rval->PrettyTree(seen);
34 L->append(Alloc<Field>(StrFromC("rval"), x1));
35 }
36
37 hnode_t* x2 = Alloc<hnode::Leaf>(this->plus_eq ? runtime::TRUE_STR :
38 runtime::FALSE_STR, color_e::OtherConst);
39 L->append(Alloc<Field>(StrFromC("plus_eq"), x2));
40
41 hnode_t* x3 = this->blame_word->PrettyTree(seen);
42 L->append(Alloc<Field>(StrFromC("blame_word"), x3));
43
44 return out_node;
45}
46
47
48hnode_t* ProcArgs::PrettyTree(Dict<int, bool>* seen) {
49 seen = seen ? seen : Alloc<Dict<int, bool>>();
50 int heap_id = ObjectId(this);
51 if (dict_contains(seen, heap_id)) {
52 return Alloc<hnode::AlreadySeen>(heap_id);
53 }
54 seen->set(heap_id, true);
55 hnode::Record* out_node = runtime::NewRecord(StrFromC("ProcArgs"));
56 List<Field*>* L = out_node->fields;
57
58 hnode_t* x0 = this->typed_args->PrettyTree(seen);
59 L->append(Alloc<Field>(StrFromC("typed_args"), x0));
60
61 if (this->pos_args != nullptr) { // List
62 hnode::Array* x1 = Alloc<hnode::Array>(Alloc<List<hnode_t*>>());
63 for (ListIter<value_asdl::value_t*> it(this->pos_args); !it.Done();
64 it.Next()) {
65 value_asdl::value_t* i1 = it.Value();
66 hnode_t* h = (i1 == nullptr) ? Alloc<hnode::Leaf>(StrFromC("_"),
67 color_e::OtherConst) : i1->PrettyTree(seen);
68 x1->children->append(h);
69 }
70 L->append(Alloc<Field>(StrFromC("pos_args"), x1));
71 }
72
73 if (this->named_args) { // Dict
74 auto m = Alloc<hnode::Leaf>(StrFromC("Dict"), color_e::OtherConst);
75 hnode::Array* x2 = Alloc<hnode::Array>(NewList<hnode_t*>({m}));
76 for (DictIter<BigStr*, value_asdl::value_t*> it(this->named_args);
77 !it.Done(); it.Next()) {
78 auto k2 = it.Key();
79 auto v2 = it.Value();
80 x2->children->append(runtime::NewLeaf(k2, color_e::StringConst));
81 x2->children->append(v2->PrettyTree(seen));
82 }
83 L->append(Alloc<Field>(StrFromC ("named_args"), x2));
84 }
85
86 if (this->block_arg) { // Optional
87 hnode_t* x3 = this->block_arg->PrettyTree(seen);
88 L->append(Alloc<Field>(StrFromC("block_arg"), x3));
89 }
90
91 return out_node;
92}
93
94BigStr* cmd_value_str(int tag, bool dot) {
95 char buf[32];
96 const char* v = nullptr;
97 switch (tag) {
98 case cmd_value_e::Argv:
99 v = "Argv"; break;
100 case cmd_value_e::Assign:
101 v = "Assign"; break;
102 default:
103 assert(0);
104 }
105 if (dot) {
106 snprintf(buf, 32, "cmd_value.%s", v);
107 return StrFromC(buf);
108 } else {
109 return StrFromC(v);
110 }
111}
112
113hnode_t* cmd_value__Argv::PrettyTree(Dict<int, bool>* seen) {
114 seen = seen ? seen : Alloc<Dict<int, bool>>();
115 int heap_id = ObjectId(this);
116 if (dict_contains(seen, heap_id)) {
117 return Alloc<hnode::AlreadySeen>(heap_id);
118 }
119 seen->set(heap_id, true);
120 hnode::Record* out_node = runtime::NewRecord(cmd_value_str(this->tag()));
121 List<Field*>* L = out_node->fields;
122
123 if (this->argv != nullptr) { // List
124 hnode::Array* x0 = Alloc<hnode::Array>(Alloc<List<hnode_t*>>());
125 for (ListIter<BigStr*> it(this->argv); !it.Done(); it.Next()) {
126 BigStr* i0 = it.Value();
127 x0->children->append(runtime::NewLeaf(i0, color_e::StringConst));
128 }
129 L->append(Alloc<Field>(StrFromC("argv"), x0));
130 }
131
132 if (this->arg_locs != nullptr) { // List
133 hnode::Array* x1 = Alloc<hnode::Array>(Alloc<List<hnode_t*>>());
134 for (ListIter<syntax_asdl::CompoundWord*> it(this->arg_locs); !it.Done();
135 it.Next()) {
136 syntax_asdl::CompoundWord* i1 = it.Value();
137 hnode_t* h = (i1 == nullptr) ? Alloc<hnode::Leaf>(StrFromC("_"),
138 color_e::OtherConst) : i1->PrettyTree(seen);
139 x1->children->append(h);
140 }
141 L->append(Alloc<Field>(StrFromC("arg_locs"), x1));
142 }
143
144 hnode_t* x2 = Alloc<hnode::Leaf>(this->is_last_cmd ? runtime::TRUE_STR :
145 runtime::FALSE_STR, color_e::OtherConst);
146 L->append(Alloc<Field>(StrFromC("is_last_cmd"), x2));
147
148 if (this->proc_args) { // Optional
149 hnode_t* x3 = this->proc_args->PrettyTree(seen);
150 L->append(Alloc<Field>(StrFromC("proc_args"), x3));
151 }
152
153 return out_node;
154}
155
156
157hnode_t* cmd_value__Assign::PrettyTree(Dict<int, bool>* seen) {
158 seen = seen ? seen : Alloc<Dict<int, bool>>();
159 int heap_id = ObjectId(this);
160 if (dict_contains(seen, heap_id)) {
161 return Alloc<hnode::AlreadySeen>(heap_id);
162 }
163 seen->set(heap_id, true);
164 hnode::Record* out_node = runtime::NewRecord(cmd_value_str(this->tag()));
165 List<Field*>* L = out_node->fields;
166
167 hnode_t* x0 = Alloc<hnode::Leaf>(str(this->builtin_id), color_e::OtherConst);
168 L->append(Alloc<Field>(StrFromC("builtin_id"), x0));
169
170 if (this->argv != nullptr) { // List
171 hnode::Array* x1 = Alloc<hnode::Array>(Alloc<List<hnode_t*>>());
172 for (ListIter<BigStr*> it(this->argv); !it.Done(); it.Next()) {
173 BigStr* i1 = it.Value();
174 x1->children->append(runtime::NewLeaf(i1, color_e::StringConst));
175 }
176 L->append(Alloc<Field>(StrFromC("argv"), x1));
177 }
178
179 if (this->arg_locs != nullptr) { // List
180 hnode::Array* x2 = Alloc<hnode::Array>(Alloc<List<hnode_t*>>());
181 for (ListIter<syntax_asdl::CompoundWord*> it(this->arg_locs); !it.Done();
182 it.Next()) {
183 syntax_asdl::CompoundWord* i2 = it.Value();
184 hnode_t* h = (i2 == nullptr) ? Alloc<hnode::Leaf>(StrFromC("_"),
185 color_e::OtherConst) : i2->PrettyTree(seen);
186 x2->children->append(h);
187 }
188 L->append(Alloc<Field>(StrFromC("arg_locs"), x2));
189 }
190
191 if (this->pairs != nullptr) { // List
192 hnode::Array* x3 = Alloc<hnode::Array>(Alloc<List<hnode_t*>>());
193 for (ListIter<AssignArg*> it(this->pairs); !it.Done(); it.Next()) {
194 AssignArg* i3 = it.Value();
195 hnode_t* h = (i3 == nullptr) ? Alloc<hnode::Leaf>(StrFromC("_"),
196 color_e::OtherConst) : i3->PrettyTree(seen);
197 x3->children->append(h);
198 }
199 L->append(Alloc<Field>(StrFromC("pairs"), x3));
200 }
201
202 return out_node;
203}
204
205
206hnode_t* cmd_value_t::PrettyTree(Dict<int, bool>* seen) {
207 switch (this->tag()) {
208 case cmd_value_e::Argv: {
209 cmd_value__Argv* obj = static_cast<cmd_value__Argv*>(this);
210 return obj->PrettyTree(seen);
211 }
212 case cmd_value_e::Assign: {
213 cmd_value__Assign* obj = static_cast<cmd_value__Assign*>(this);
214 return obj->PrettyTree(seen);
215 }
216 default:
217 assert(0);
218 }
219}
220
221hnode_t* Piece::PrettyTree(Dict<int, bool>* seen) {
222 seen = seen ? seen : Alloc<Dict<int, bool>>();
223 int heap_id = ObjectId(this);
224 if (dict_contains(seen, heap_id)) {
225 return Alloc<hnode::AlreadySeen>(heap_id);
226 }
227 seen->set(heap_id, true);
228 hnode::Record* out_node = runtime::NewRecord(StrFromC("Piece"));
229 List<Field*>* L = out_node->fields;
230
231 hnode_t* x0 = runtime::NewLeaf(this->s, color_e::StringConst);
232 L->append(Alloc<Field>(StrFromC("s"), x0));
233
234 hnode_t* x1 = Alloc<hnode::Leaf>(this->quoted ? runtime::TRUE_STR :
235 runtime::FALSE_STR, color_e::OtherConst);
236 L->append(Alloc<Field>(StrFromC("quoted"), x1));
237
238 hnode_t* x2 = Alloc<hnode::Leaf>(this->do_split ? runtime::TRUE_STR :
239 runtime::FALSE_STR, color_e::OtherConst);
240 L->append(Alloc<Field>(StrFromC("do_split"), x2));
241
242 return out_node;
243}
244
245BigStr* part_value_str(int tag, bool dot) {
246 char buf[32];
247 const char* v = nullptr;
248 switch (tag) {
249 case part_value_e::String:
250 v = "String"; break;
251 case part_value_e::Array:
252 v = "Array"; break;
253 case part_value_e::ExtGlob:
254 v = "ExtGlob"; break;
255 default:
256 assert(0);
257 }
258 if (dot) {
259 snprintf(buf, 32, "part_value.%s", v);
260 return StrFromC(buf);
261 } else {
262 return StrFromC(v);
263 }
264}
265
266hnode_t* part_value__Array::PrettyTree(Dict<int, bool>* seen) {
267 seen = seen ? seen : Alloc<Dict<int, bool>>();
268 int heap_id = ObjectId(this);
269 if (dict_contains(seen, heap_id)) {
270 return Alloc<hnode::AlreadySeen>(heap_id);
271 }
272 seen->set(heap_id, true);
273 hnode::Record* out_node = runtime::NewRecord(part_value_str(this->tag()));
274 List<Field*>* L = out_node->fields;
275
276 if (this->strs != nullptr) { // List
277 hnode::Array* x0 = Alloc<hnode::Array>(Alloc<List<hnode_t*>>());
278 for (ListIter<BigStr*> it(this->strs); !it.Done(); it.Next()) {
279 BigStr* i0 = it.Value();
280 x0->children->append(runtime::NewLeaf(i0, color_e::StringConst));
281 }
282 L->append(Alloc<Field>(StrFromC("strs"), x0));
283 }
284
285 return out_node;
286}
287
288
289hnode_t* part_value__ExtGlob::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 hnode::Record* out_node = runtime::NewRecord(part_value_str(this->tag()));
297 List<Field*>* L = out_node->fields;
298
299 if (this->part_vals != nullptr) { // List
300 hnode::Array* x0 = Alloc<hnode::Array>(Alloc<List<hnode_t*>>());
301 for (ListIter<part_value_t*> it(this->part_vals); !it.Done(); it.Next()) {
302 part_value_t* i0 = it.Value();
303 hnode_t* h = (i0 == nullptr) ? Alloc<hnode::Leaf>(StrFromC("_"),
304 color_e::OtherConst) : i0->PrettyTree(seen);
305 x0->children->append(h);
306 }
307 L->append(Alloc<Field>(StrFromC("part_vals"), x0));
308 }
309
310 return out_node;
311}
312
313
314hnode_t* part_value_t::PrettyTree(Dict<int, bool>* seen) {
315 switch (this->tag()) {
316 case part_value_e::String: {
317 Piece* obj = static_cast<Piece*>(this);
318 return obj->PrettyTree(seen);
319 }
320 case part_value_e::Array: {
321 part_value__Array* obj = static_cast<part_value__Array*>(this);
322 return obj->PrettyTree(seen);
323 }
324 case part_value_e::ExtGlob: {
325 part_value__ExtGlob* obj = static_cast<part_value__ExtGlob*>(this);
326 return obj->PrettyTree(seen);
327 }
328 default:
329 assert(0);
330 }
331}
332BigStr* coerced_str(coerced_e tag, bool dot) {
333 char buf[32];
334 const char* v = nullptr;
335 switch (tag) {
336 case coerced_e::Int:
337 v = "Int"; break;
338 case coerced_e::Float:
339 v = "Float"; break;
340 case coerced_e::Neither:
341 v = "Neither"; break;
342 default:
343 assert(0);
344 }
345 if (dot) {
346 snprintf(buf, 32, "coerced.%s", v);
347 return StrFromC(buf);
348 } else {
349 return StrFromC(v);
350 }
351}
352
353hnode_t* VarSubState::PrettyTree(Dict<int, bool>* seen) {
354 seen = seen ? seen : Alloc<Dict<int, bool>>();
355 int heap_id = ObjectId(this);
356 if (dict_contains(seen, heap_id)) {
357 return Alloc<hnode::AlreadySeen>(heap_id);
358 }
359 seen->set(heap_id, true);
360 hnode::Record* out_node = runtime::NewRecord(StrFromC("VarSubState"));
361 List<Field*>* L = out_node->fields;
362
363 hnode_t* x0 = Alloc<hnode::Leaf>(this->join_array ? runtime::TRUE_STR :
364 runtime::FALSE_STR, color_e::OtherConst);
365 L->append(Alloc<Field>(StrFromC("join_array"), x0));
366
367 hnode_t* x1 = Alloc<hnode::Leaf>(this->is_type_query ? runtime::TRUE_STR :
368 runtime::FALSE_STR, color_e::OtherConst);
369 L->append(Alloc<Field>(StrFromC("is_type_query"), x1));
370
371 hnode_t* x2 = Alloc<hnode::Leaf>(this->has_test_op ? runtime::TRUE_STR :
372 runtime::FALSE_STR, color_e::OtherConst);
373 L->append(Alloc<Field>(StrFromC("has_test_op"), x2));
374
375 return out_node;
376}
377
378
379hnode_t* Cell::PrettyTree(Dict<int, bool>* seen) {
380 seen = seen ? seen : Alloc<Dict<int, bool>>();
381 int heap_id = ObjectId(this);
382 if (dict_contains(seen, heap_id)) {
383 return Alloc<hnode::AlreadySeen>(heap_id);
384 }
385 seen->set(heap_id, true);
386 hnode::Record* out_node = runtime::NewRecord(StrFromC("Cell"));
387 List<Field*>* L = out_node->fields;
388
389 hnode_t* x0 = Alloc<hnode::Leaf>(this->exported ? runtime::TRUE_STR :
390 runtime::FALSE_STR, color_e::OtherConst);
391 L->append(Alloc<Field>(StrFromC("exported"), x0));
392
393 hnode_t* x1 = Alloc<hnode::Leaf>(this->readonly ? runtime::TRUE_STR :
394 runtime::FALSE_STR, color_e::OtherConst);
395 L->append(Alloc<Field>(StrFromC("readonly"), x1));
396
397 hnode_t* x2 = Alloc<hnode::Leaf>(this->nameref ? runtime::TRUE_STR :
398 runtime::FALSE_STR, color_e::OtherConst);
399 L->append(Alloc<Field>(StrFromC("nameref"), x2));
400
401 hnode_t* x3 = this->val->PrettyTree(seen);
402 L->append(Alloc<Field>(StrFromC("val"), x3));
403
404 return out_node;
405}
406
407BigStr* scope_str(scope_e tag, bool dot) {
408 char buf[32];
409 const char* v = nullptr;
410 switch (tag) {
411 case scope_e::Shopt:
412 v = "Shopt"; break;
413 case scope_e::Dynamic:
414 v = "Dynamic"; break;
415 case scope_e::LocalOrGlobal:
416 v = "LocalOrGlobal"; break;
417 case scope_e::LocalOnly:
418 v = "LocalOnly"; break;
419 case scope_e::GlobalOnly:
420 v = "GlobalOnly"; break;
421 default:
422 assert(0);
423 }
424 if (dot) {
425 snprintf(buf, 32, "scope.%s", v);
426 return StrFromC(buf);
427 } else {
428 return StrFromC(v);
429 }
430}
431BigStr* a_index_str(int tag, bool dot) {
432 char buf[32];
433 const char* v = nullptr;
434 switch (tag) {
435 case a_index_e::Str:
436 v = "Str"; break;
437 case a_index_e::Int:
438 v = "Int"; break;
439 default:
440 assert(0);
441 }
442 if (dot) {
443 snprintf(buf, 32, "a_index.%s", v);
444 return StrFromC(buf);
445 } else {
446 return StrFromC(v);
447 }
448}
449
450hnode_t* a_index__Str::PrettyTree(Dict<int, bool>* seen) {
451 seen = seen ? seen : Alloc<Dict<int, bool>>();
452 int heap_id = ObjectId(this);
453 if (dict_contains(seen, heap_id)) {
454 return Alloc<hnode::AlreadySeen>(heap_id);
455 }
456 seen->set(heap_id, true);
457 hnode::Record* out_node = runtime::NewRecord(a_index_str(this->tag()));
458 List<Field*>* L = out_node->fields;
459
460 hnode_t* x0 = runtime::NewLeaf(this->s, color_e::StringConst);
461 L->append(Alloc<Field>(StrFromC("s"), x0));
462
463 return out_node;
464}
465
466
467hnode_t* a_index__Int::PrettyTree(Dict<int, bool>* seen) {
468 seen = seen ? seen : Alloc<Dict<int, bool>>();
469 int heap_id = ObjectId(this);
470 if (dict_contains(seen, heap_id)) {
471 return Alloc<hnode::AlreadySeen>(heap_id);
472 }
473 seen->set(heap_id, true);
474 hnode::Record* out_node = runtime::NewRecord(a_index_str(this->tag()));
475 List<Field*>* L = out_node->fields;
476
477 hnode_t* x0 = Alloc<hnode::Leaf>(str(this->i), color_e::OtherConst);
478 L->append(Alloc<Field>(StrFromC("i"), x0));
479
480 return out_node;
481}
482
483
484hnode_t* a_index_t::PrettyTree(Dict<int, bool>* seen) {
485 switch (this->tag()) {
486 case a_index_e::Str: {
487 a_index__Str* obj = static_cast<a_index__Str*>(this);
488 return obj->PrettyTree(seen);
489 }
490 case a_index_e::Int: {
491 a_index__Int* obj = static_cast<a_index__Int*>(this);
492 return obj->PrettyTree(seen);
493 }
494 default:
495 assert(0);
496 }
497}
498
499hnode_t* VTestPlace::PrettyTree(Dict<int, bool>* seen) {
500 seen = seen ? seen : Alloc<Dict<int, bool>>();
501 int heap_id = ObjectId(this);
502 if (dict_contains(seen, heap_id)) {
503 return Alloc<hnode::AlreadySeen>(heap_id);
504 }
505 seen->set(heap_id, true);
506 hnode::Record* out_node = runtime::NewRecord(StrFromC("VTestPlace"));
507 List<Field*>* L = out_node->fields;
508
509 if (this->name) { // Optional
510 hnode_t* x0 = runtime::NewLeaf(this->name, color_e::StringConst);
511 L->append(Alloc<Field>(StrFromC("name"), x0));
512 }
513
514 if (this->index) { // Optional
515 hnode_t* x1 = this->index->PrettyTree(seen);
516 L->append(Alloc<Field>(StrFromC("index"), x1));
517 }
518
519 return out_node;
520}
521
522BigStr* redirect_arg_str(int tag, bool dot) {
523 char buf[32];
524 const char* v = nullptr;
525 switch (tag) {
526 case redirect_arg_e::Path:
527 v = "Path"; break;
528 case redirect_arg_e::CopyFd:
529 v = "CopyFd"; break;
530 case redirect_arg_e::MoveFd:
531 v = "MoveFd"; break;
532 case redirect_arg_e::CloseFd:
533 v = "CloseFd"; break;
534 case redirect_arg_e::HereDoc:
535 v = "HereDoc"; break;
536 default:
537 assert(0);
538 }
539 if (dot) {
540 snprintf(buf, 32, "redirect_arg.%s", v);
541 return StrFromC(buf);
542 } else {
543 return StrFromC(v);
544 }
545}
546
547redirect_arg__CloseFd* redirect_arg::CloseFd = &gredirect_arg__CloseFd.obj;
548
549GcGlobal<redirect_arg__CloseFd> gredirect_arg__CloseFd =
550 { ObjHeader::Global(redirect_arg_e::CloseFd) };
551
552hnode_t* redirect_arg__Path::PrettyTree(Dict<int, bool>* seen) {
553 seen = seen ? seen : Alloc<Dict<int, bool>>();
554 int heap_id = ObjectId(this);
555 if (dict_contains(seen, heap_id)) {
556 return Alloc<hnode::AlreadySeen>(heap_id);
557 }
558 seen->set(heap_id, true);
559 hnode::Record* out_node = runtime::NewRecord(redirect_arg_str(this->tag()));
560 List<Field*>* L = out_node->fields;
561
562 hnode_t* x0 = runtime::NewLeaf(this->filename, color_e::StringConst);
563 L->append(Alloc<Field>(StrFromC("filename"), x0));
564
565 return out_node;
566}
567
568
569hnode_t* redirect_arg__CopyFd::PrettyTree(Dict<int, bool>* seen) {
570 seen = seen ? seen : Alloc<Dict<int, bool>>();
571 int heap_id = ObjectId(this);
572 if (dict_contains(seen, heap_id)) {
573 return Alloc<hnode::AlreadySeen>(heap_id);
574 }
575 seen->set(heap_id, true);
576 hnode::Record* out_node = runtime::NewRecord(redirect_arg_str(this->tag()));
577 List<Field*>* L = out_node->fields;
578
579 hnode_t* x0 = Alloc<hnode::Leaf>(str(this->target_fd), color_e::OtherConst);
580 L->append(Alloc<Field>(StrFromC("target_fd"), x0));
581
582 return out_node;
583}
584
585
586hnode_t* redirect_arg__MoveFd::PrettyTree(Dict<int, bool>* seen) {
587 seen = seen ? seen : Alloc<Dict<int, bool>>();
588 int heap_id = ObjectId(this);
589 if (dict_contains(seen, heap_id)) {
590 return Alloc<hnode::AlreadySeen>(heap_id);
591 }
592 seen->set(heap_id, true);
593 hnode::Record* out_node = runtime::NewRecord(redirect_arg_str(this->tag()));
594 List<Field*>* L = out_node->fields;
595
596 hnode_t* x0 = Alloc<hnode::Leaf>(str(this->target_fd), color_e::OtherConst);
597 L->append(Alloc<Field>(StrFromC("target_fd"), x0));
598
599 return out_node;
600}
601
602
603hnode_t* redirect_arg__CloseFd::PrettyTree(Dict<int, bool>* seen) {
604 seen = seen ? seen : Alloc<Dict<int, bool>>();
605 int heap_id = ObjectId(this);
606 if (dict_contains(seen, heap_id)) {
607 return Alloc<hnode::AlreadySeen>(heap_id);
608 }
609 seen->set(heap_id, true);
610 hnode::Record* out_node = runtime::NewRecord(redirect_arg_str(this->tag()));
611 return out_node;
612}
613
614
615hnode_t* redirect_arg__HereDoc::PrettyTree(Dict<int, bool>* seen) {
616 seen = seen ? seen : Alloc<Dict<int, bool>>();
617 int heap_id = ObjectId(this);
618 if (dict_contains(seen, heap_id)) {
619 return Alloc<hnode::AlreadySeen>(heap_id);
620 }
621 seen->set(heap_id, true);
622 hnode::Record* out_node = runtime::NewRecord(redirect_arg_str(this->tag()));
623 List<Field*>* L = out_node->fields;
624
625 hnode_t* x0 = runtime::NewLeaf(this->body, color_e::StringConst);
626 L->append(Alloc<Field>(StrFromC("body"), x0));
627
628 return out_node;
629}
630
631
632hnode_t* redirect_arg_t::PrettyTree(Dict<int, bool>* seen) {
633 switch (this->tag()) {
634 case redirect_arg_e::Path: {
635 redirect_arg__Path* obj = static_cast<redirect_arg__Path*>(this);
636 return obj->PrettyTree(seen);
637 }
638 case redirect_arg_e::CopyFd: {
639 redirect_arg__CopyFd* obj = static_cast<redirect_arg__CopyFd*>(this);
640 return obj->PrettyTree(seen);
641 }
642 case redirect_arg_e::MoveFd: {
643 redirect_arg__MoveFd* obj = static_cast<redirect_arg__MoveFd*>(this);
644 return obj->PrettyTree(seen);
645 }
646 case redirect_arg_e::CloseFd: {
647 redirect_arg__CloseFd* obj = static_cast<redirect_arg__CloseFd*>(this);
648 return obj->PrettyTree(seen);
649 }
650 case redirect_arg_e::HereDoc: {
651 redirect_arg__HereDoc* obj = static_cast<redirect_arg__HereDoc*>(this);
652 return obj->PrettyTree(seen);
653 }
654 default:
655 assert(0);
656 }
657}
658
659hnode_t* RedirValue::PrettyTree(Dict<int, bool>* seen) {
660 seen = seen ? seen : Alloc<Dict<int, bool>>();
661 int heap_id = ObjectId(this);
662 if (dict_contains(seen, heap_id)) {
663 return Alloc<hnode::AlreadySeen>(heap_id);
664 }
665 seen->set(heap_id, true);
666 hnode::Record* out_node = runtime::NewRecord(StrFromC("RedirValue"));
667 List<Field*>* L = out_node->fields;
668
669 hnode_t* x0 = Alloc<hnode::Leaf>(Id_str(this->op_id), color_e::UserType);
670 L->append(Alloc<Field>(StrFromC("op_id"), x0));
671
672 hnode_t* x1 = this->op_loc->PrettyTree(seen);
673 L->append(Alloc<Field>(StrFromC("op_loc"), x1));
674
675 hnode_t* x2 = this->loc->PrettyTree(seen);
676 L->append(Alloc<Field>(StrFromC("loc"), x2));
677
678 hnode_t* x3 = this->arg->PrettyTree(seen);
679 L->append(Alloc<Field>(StrFromC("arg"), x3));
680
681 return out_node;
682}
683
684
685hnode_t* StatusArray::PrettyTree(Dict<int, bool>* seen) {
686 seen = seen ? seen : Alloc<Dict<int, bool>>();
687 int heap_id = ObjectId(this);
688 if (dict_contains(seen, heap_id)) {
689 return Alloc<hnode::AlreadySeen>(heap_id);
690 }
691 seen->set(heap_id, true);
692 hnode::Record* out_node = runtime::NewRecord(StrFromC("StatusArray"));
693 List<Field*>* L = out_node->fields;
694
695 if (this->codes != nullptr) { // List
696 hnode::Array* x0 = Alloc<hnode::Array>(Alloc<List<hnode_t*>>());
697 for (ListIter<int> it(this->codes); !it.Done(); it.Next()) {
698 int i0 = it.Value();
699 x0->children->append(Alloc<hnode::Leaf>(str(i0), color_e::OtherConst));
700 }
701 L->append(Alloc<Field>(StrFromC("codes"), x0));
702 }
703
704 if (this->locs != nullptr) { // List
705 hnode::Array* x1 = Alloc<hnode::Array>(Alloc<List<hnode_t*>>());
706 for (ListIter<syntax_asdl::loc_t*> it(this->locs); !it.Done(); it.Next()) {
707 syntax_asdl::loc_t* i1 = it.Value();
708 hnode_t* h = (i1 == nullptr) ? Alloc<hnode::Leaf>(StrFromC("_"),
709 color_e::OtherConst) : i1->PrettyTree(seen);
710 x1->children->append(h);
711 }
712 L->append(Alloc<Field>(StrFromC("locs"), x1));
713 }
714
715 return out_node;
716}
717
718
719hnode_t* CommandStatus::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 hnode::Record* out_node = runtime::NewRecord(StrFromC("CommandStatus"));
727 List<Field*>* L = out_node->fields;
728
729 hnode_t* x0 = Alloc<hnode::Leaf>(this->check_errexit ? runtime::TRUE_STR :
730 runtime::FALSE_STR, color_e::OtherConst);
731 L->append(Alloc<Field>(StrFromC("check_errexit"), x0));
732
733 hnode_t* x1 = Alloc<hnode::Leaf>(this->show_code ? runtime::TRUE_STR :
734 runtime::FALSE_STR, color_e::OtherConst);
735 L->append(Alloc<Field>(StrFromC("show_code"), x1));
736
737 hnode_t* x2 = Alloc<hnode::Leaf>(this->pipe_negated ? runtime::TRUE_STR :
738 runtime::FALSE_STR, color_e::OtherConst);
739 L->append(Alloc<Field>(StrFromC("pipe_negated"), x2));
740
741 if (this->pipe_status != nullptr) { // List
742 hnode::Array* x3 = Alloc<hnode::Array>(Alloc<List<hnode_t*>>());
743 for (ListIter<int> it(this->pipe_status); !it.Done(); it.Next()) {
744 int i3 = it.Value();
745 x3->children->append(Alloc<hnode::Leaf>(str(i3), color_e::OtherConst));
746 }
747 L->append(Alloc<Field>(StrFromC("pipe_status"), x3));
748 }
749
750 if (this->pipe_locs != nullptr) { // List
751 hnode::Array* x4 = Alloc<hnode::Array>(Alloc<List<hnode_t*>>());
752 for (ListIter<syntax_asdl::loc_t*> it(this->pipe_locs); !it.Done();
753 it.Next()) {
754 syntax_asdl::loc_t* i4 = it.Value();
755 hnode_t* h = (i4 == nullptr) ? Alloc<hnode::Leaf>(StrFromC("_"),
756 color_e::OtherConst) : i4->PrettyTree(seen);
757 x4->children->append(h);
758 }
759 L->append(Alloc<Field>(StrFromC("pipe_locs"), x4));
760 }
761
762 return out_node;
763}
764
765BigStr* wait_status_str(int tag, bool dot) {
766 char buf[32];
767 const char* v = nullptr;
768 switch (tag) {
769 case wait_status_e::Proc:
770 v = "Proc"; break;
771 case wait_status_e::Pipeline:
772 v = "Pipeline"; break;
773 case wait_status_e::Cancelled:
774 v = "Cancelled"; break;
775 default:
776 assert(0);
777 }
778 if (dot) {
779 snprintf(buf, 32, "wait_status.%s", v);
780 return StrFromC(buf);
781 } else {
782 return StrFromC(v);
783 }
784}
785
786hnode_t* wait_status__Proc::PrettyTree(Dict<int, bool>* seen) {
787 seen = seen ? seen : Alloc<Dict<int, bool>>();
788 int heap_id = ObjectId(this);
789 if (dict_contains(seen, heap_id)) {
790 return Alloc<hnode::AlreadySeen>(heap_id);
791 }
792 seen->set(heap_id, true);
793 hnode::Record* out_node = runtime::NewRecord(wait_status_str(this->tag()));
794 List<Field*>* L = out_node->fields;
795
796 hnode_t* x0 = Alloc<hnode::Leaf>(str(this->code), color_e::OtherConst);
797 L->append(Alloc<Field>(StrFromC("code"), x0));
798
799 return out_node;
800}
801
802
803hnode_t* wait_status__Pipeline::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 hnode::Record* out_node = runtime::NewRecord(wait_status_str(this->tag()));
811 List<Field*>* L = out_node->fields;
812
813 if (this->codes != nullptr) { // List
814 hnode::Array* x0 = Alloc<hnode::Array>(Alloc<List<hnode_t*>>());
815 for (ListIter<int> it(this->codes); !it.Done(); it.Next()) {
816 int i0 = it.Value();
817 x0->children->append(Alloc<hnode::Leaf>(str(i0), color_e::OtherConst));
818 }
819 L->append(Alloc<Field>(StrFromC("codes"), x0));
820 }
821
822 return out_node;
823}
824
825
826hnode_t* wait_status__Cancelled::PrettyTree(Dict<int, bool>* seen) {
827 seen = seen ? seen : Alloc<Dict<int, bool>>();
828 int heap_id = ObjectId(this);
829 if (dict_contains(seen, heap_id)) {
830 return Alloc<hnode::AlreadySeen>(heap_id);
831 }
832 seen->set(heap_id, true);
833 hnode::Record* out_node = runtime::NewRecord(wait_status_str(this->tag()));
834 List<Field*>* L = out_node->fields;
835
836 hnode_t* x0 = Alloc<hnode::Leaf>(str(this->sig_num), color_e::OtherConst);
837 L->append(Alloc<Field>(StrFromC("sig_num"), x0));
838
839 return out_node;
840}
841
842
843hnode_t* wait_status_t::PrettyTree(Dict<int, bool>* seen) {
844 switch (this->tag()) {
845 case wait_status_e::Proc: {
846 wait_status__Proc* obj = static_cast<wait_status__Proc*>(this);
847 return obj->PrettyTree(seen);
848 }
849 case wait_status_e::Pipeline: {
850 wait_status__Pipeline* obj = static_cast<wait_status__Pipeline*>(this);
851 return obj->PrettyTree(seen);
852 }
853 case wait_status_e::Cancelled: {
854 wait_status__Cancelled* obj = static_cast<wait_status__Cancelled*>(this);
855 return obj->PrettyTree(seen);
856 }
857 default:
858 assert(0);
859 }
860}
861BigStr* flow_str(flow_e tag, bool dot) {
862 char buf[32];
863 const char* v = nullptr;
864 switch (tag) {
865 case flow_e::Nothing:
866 v = "Nothing"; break;
867 case flow_e::Break:
868 v = "Break"; break;
869 case flow_e::Raise:
870 v = "Raise"; break;
871 default:
872 assert(0);
873 }
874 if (dot) {
875 snprintf(buf, 32, "flow.%s", v);
876 return StrFromC(buf);
877 } else {
878 return StrFromC(v);
879 }
880}
881BigStr* span_str(span_e tag, bool dot) {
882 char buf[32];
883 const char* v = nullptr;
884 switch (tag) {
885 case span_e::Black:
886 v = "Black"; break;
887 case span_e::Delim:
888 v = "Delim"; break;
889 case span_e::Backslash:
890 v = "Backslash"; break;
891 default:
892 assert(0);
893 }
894 if (dot) {
895 snprintf(buf, 32, "span.%s", v);
896 return StrFromC(buf);
897 } else {
898 return StrFromC(v);
899 }
900}
901BigStr* emit_str(int tag, bool dot) {
902 char buf[32];
903 const char* v = nullptr;
904 switch (tag) {
905 case emit_i::Part:
906 v = "Part"; break;
907 case emit_i::Delim:
908 v = "Delim"; break;
909 case emit_i::Empty:
910 v = "Empty"; break;
911 case emit_i::Escape:
912 v = "Escape"; break;
913 case emit_i::Nothing:
914 v = "Nothing"; break;
915 default:
916 assert(0);
917 }
918 if (dot) {
919 snprintf(buf, 32, "emit.%s", v);
920 return StrFromC(buf);
921 } else {
922 return StrFromC(v);
923 }
924}
925BigStr* state_str(int tag, bool dot) {
926 char buf[32];
927 const char* v = nullptr;
928 switch (tag) {
929 case state_i::Invalid:
930 v = "Invalid"; break;
931 case state_i::Start:
932 v = "Start"; break;
933 case state_i::DE_White1:
934 v = "DE_White1"; break;
935 case state_i::DE_Gray:
936 v = "DE_Gray"; break;
937 case state_i::DE_White2:
938 v = "DE_White2"; break;
939 case state_i::Black:
940 v = "Black"; break;
941 case state_i::Backslash:
942 v = "Backslash"; break;
943 case state_i::Done:
944 v = "Done"; break;
945 default:
946 assert(0);
947 }
948 if (dot) {
949 snprintf(buf, 32, "state.%s", v);
950 return StrFromC(buf);
951 } else {
952 return StrFromC(v);
953 }
954}
955BigStr* char_kind_str(int tag, bool dot) {
956 char buf[32];
957 const char* v = nullptr;
958 switch (tag) {
959 case char_kind_i::DE_White:
960 v = "DE_White"; break;
961 case char_kind_i::DE_Gray:
962 v = "DE_Gray"; break;
963 case char_kind_i::Black:
964 v = "Black"; break;
965 case char_kind_i::Backslash:
966 v = "Backslash"; break;
967 case char_kind_i::Sentinel:
968 v = "Sentinel"; break;
969 default:
970 assert(0);
971 }
972 if (dot) {
973 snprintf(buf, 32, "char_kind.%s", v);
974 return StrFromC(buf);
975 } else {
976 return StrFromC(v);
977 }
978}
979BigStr* job_state_str(job_state_e tag, bool dot) {
980 char buf[32];
981 const char* v = nullptr;
982 switch (tag) {
983 case job_state_e::Running:
984 v = "Running"; break;
985 case job_state_e::Done:
986 v = "Done"; break;
987 case job_state_e::Stopped:
988 v = "Stopped"; break;
989 default:
990 assert(0);
991 }
992 if (dot) {
993 snprintf(buf, 32, "job_state.%s", v);
994 return StrFromC(buf);
995 } else {
996 return StrFromC(v);
997 }
998}
999BigStr* flag_type_str(flag_type_e tag, bool dot) {
1000 char buf[32];
1001 const char* v = nullptr;
1002 switch (tag) {
1003 case flag_type_e::Bool:
1004 v = "Bool"; break;
1005 case flag_type_e::Int:
1006 v = "Int"; break;
1007 case flag_type_e::Float:
1008 v = "Float"; break;
1009 case flag_type_e::Str:
1010 v = "Str"; break;
1011 default:
1012 assert(0);
1013 }
1014 if (dot) {
1015 snprintf(buf, 32, "flag_type.%s", v);
1016 return StrFromC(buf);
1017 } else {
1018 return StrFromC(v);
1019 }
1020}
1021BigStr* trace_str(int tag, bool dot) {
1022 char buf[32];
1023 const char* v = nullptr;
1024 switch (tag) {
1025 case trace_e::External:
1026 v = "External"; break;
1027 case trace_e::CommandSub:
1028 v = "CommandSub"; break;
1029 case trace_e::ForkWait:
1030 v = "ForkWait"; break;
1031 case trace_e::Fork:
1032 v = "Fork"; break;
1033 case trace_e::PipelinePart:
1034 v = "PipelinePart"; break;
1035 case trace_e::ProcessSub:
1036 v = "ProcessSub"; break;
1037 case trace_e::HereDoc:
1038 v = "HereDoc"; break;
1039 default:
1040 assert(0);
1041 }
1042 if (dot) {
1043 snprintf(buf, 32, "trace.%s", v);
1044 return StrFromC(buf);
1045 } else {
1046 return StrFromC(v);
1047 }
1048}
1049
1050trace__CommandSub* trace::CommandSub = &gtrace__CommandSub.obj;
1051
1052GcGlobal<trace__CommandSub> gtrace__CommandSub =
1053 { ObjHeader::Global(trace_e::CommandSub) };
1054
1055trace__ForkWait* trace::ForkWait = &gtrace__ForkWait.obj;
1056
1057GcGlobal<trace__ForkWait> gtrace__ForkWait =
1058 { ObjHeader::Global(trace_e::ForkWait) };
1059
1060trace__Fork* trace::Fork = &gtrace__Fork.obj;
1061
1062GcGlobal<trace__Fork> gtrace__Fork =
1063 { ObjHeader::Global(trace_e::Fork) };
1064
1065trace__PipelinePart* trace::PipelinePart = &gtrace__PipelinePart.obj;
1066
1067GcGlobal<trace__PipelinePart> gtrace__PipelinePart =
1068 { ObjHeader::Global(trace_e::PipelinePart) };
1069
1070trace__ProcessSub* trace::ProcessSub = &gtrace__ProcessSub.obj;
1071
1072GcGlobal<trace__ProcessSub> gtrace__ProcessSub =
1073 { ObjHeader::Global(trace_e::ProcessSub) };
1074
1075trace__HereDoc* trace::HereDoc = &gtrace__HereDoc.obj;
1076
1077GcGlobal<trace__HereDoc> gtrace__HereDoc =
1078 { ObjHeader::Global(trace_e::HereDoc) };
1079
1080hnode_t* trace__External::PrettyTree(Dict<int, bool>* seen) {
1081 seen = seen ? seen : Alloc<Dict<int, bool>>();
1082 int heap_id = ObjectId(this);
1083 if (dict_contains(seen, heap_id)) {
1084 return Alloc<hnode::AlreadySeen>(heap_id);
1085 }
1086 seen->set(heap_id, true);
1087 hnode::Record* out_node = runtime::NewRecord(trace_str(this->tag()));
1088 List<Field*>* L = out_node->fields;
1089
1090 if (this->argv != nullptr) { // List
1091 hnode::Array* x0 = Alloc<hnode::Array>(Alloc<List<hnode_t*>>());
1092 for (ListIter<BigStr*> it(this->argv); !it.Done(); it.Next()) {
1093 BigStr* i0 = it.Value();
1094 x0->children->append(runtime::NewLeaf(i0, color_e::StringConst));
1095 }
1096 L->append(Alloc<Field>(StrFromC("argv"), x0));
1097 }
1098
1099 return out_node;
1100}
1101
1102
1103hnode_t* trace__CommandSub::PrettyTree(Dict<int, bool>* seen) {
1104 seen = seen ? seen : Alloc<Dict<int, bool>>();
1105 int heap_id = ObjectId(this);
1106 if (dict_contains(seen, heap_id)) {
1107 return Alloc<hnode::AlreadySeen>(heap_id);
1108 }
1109 seen->set(heap_id, true);
1110 hnode::Record* out_node = runtime::NewRecord(trace_str(this->tag()));
1111 return out_node;
1112}
1113
1114
1115hnode_t* trace__ForkWait::PrettyTree(Dict<int, bool>* seen) {
1116 seen = seen ? seen : Alloc<Dict<int, bool>>();
1117 int heap_id = ObjectId(this);
1118 if (dict_contains(seen, heap_id)) {
1119 return Alloc<hnode::AlreadySeen>(heap_id);
1120 }
1121 seen->set(heap_id, true);
1122 hnode::Record* out_node = runtime::NewRecord(trace_str(this->tag()));
1123 return out_node;
1124}
1125
1126
1127hnode_t* trace__Fork::PrettyTree(Dict<int, bool>* seen) {
1128 seen = seen ? seen : Alloc<Dict<int, bool>>();
1129 int heap_id = ObjectId(this);
1130 if (dict_contains(seen, heap_id)) {
1131 return Alloc<hnode::AlreadySeen>(heap_id);
1132 }
1133 seen->set(heap_id, true);
1134 hnode::Record* out_node = runtime::NewRecord(trace_str(this->tag()));
1135 return out_node;
1136}
1137
1138
1139hnode_t* trace__PipelinePart::PrettyTree(Dict<int, bool>* seen) {
1140 seen = seen ? seen : Alloc<Dict<int, bool>>();
1141 int heap_id = ObjectId(this);
1142 if (dict_contains(seen, heap_id)) {
1143 return Alloc<hnode::AlreadySeen>(heap_id);
1144 }
1145 seen->set(heap_id, true);
1146 hnode::Record* out_node = runtime::NewRecord(trace_str(this->tag()));
1147 return out_node;
1148}
1149
1150
1151hnode_t* trace__ProcessSub::PrettyTree(Dict<int, bool>* seen) {
1152 seen = seen ? seen : Alloc<Dict<int, bool>>();
1153 int heap_id = ObjectId(this);
1154 if (dict_contains(seen, heap_id)) {
1155 return Alloc<hnode::AlreadySeen>(heap_id);
1156 }
1157 seen->set(heap_id, true);
1158 hnode::Record* out_node = runtime::NewRecord(trace_str(this->tag()));
1159 return out_node;
1160}
1161
1162
1163hnode_t* trace__HereDoc::PrettyTree(Dict<int, bool>* seen) {
1164 seen = seen ? seen : Alloc<Dict<int, bool>>();
1165 int heap_id = ObjectId(this);
1166 if (dict_contains(seen, heap_id)) {
1167 return Alloc<hnode::AlreadySeen>(heap_id);
1168 }
1169 seen->set(heap_id, true);
1170 hnode::Record* out_node = runtime::NewRecord(trace_str(this->tag()));
1171 return out_node;
1172}
1173
1174
1175hnode_t* trace_t::PrettyTree(Dict<int, bool>* seen) {
1176 switch (this->tag()) {
1177 case trace_e::External: {
1178 trace__External* obj = static_cast<trace__External*>(this);
1179 return obj->PrettyTree(seen);
1180 }
1181 case trace_e::CommandSub: {
1182 trace__CommandSub* obj = static_cast<trace__CommandSub*>(this);
1183 return obj->PrettyTree(seen);
1184 }
1185 case trace_e::ForkWait: {
1186 trace__ForkWait* obj = static_cast<trace__ForkWait*>(this);
1187 return obj->PrettyTree(seen);
1188 }
1189 case trace_e::Fork: {
1190 trace__Fork* obj = static_cast<trace__Fork*>(this);
1191 return obj->PrettyTree(seen);
1192 }
1193 case trace_e::PipelinePart: {
1194 trace__PipelinePart* obj = static_cast<trace__PipelinePart*>(this);
1195 return obj->PrettyTree(seen);
1196 }
1197 case trace_e::ProcessSub: {
1198 trace__ProcessSub* obj = static_cast<trace__ProcessSub*>(this);
1199 return obj->PrettyTree(seen);
1200 }
1201 case trace_e::HereDoc: {
1202 trace__HereDoc* obj = static_cast<trace__HereDoc*>(this);
1203 return obj->PrettyTree(seen);
1204 }
1205 default:
1206 assert(0);
1207 }
1208}
1209BigStr* word_style_str(word_style_e tag, bool dot) {
1210 char buf[32];
1211 const char* v = nullptr;
1212 switch (tag) {
1213 case word_style_e::Expr:
1214 v = "Expr"; break;
1215 case word_style_e::Unquoted:
1216 v = "Unquoted"; break;
1217 case word_style_e::DQ:
1218 v = "DQ"; break;
1219 case word_style_e::SQ:
1220 v = "SQ"; break;
1221 default:
1222 assert(0);
1223 }
1224 if (dot) {
1225 snprintf(buf, 32, "word_style.%s", v);
1226 return StrFromC(buf);
1227 } else {
1228 return StrFromC(v);
1229 }
1230}
1231
1232hnode_t* HayNode::PrettyTree(Dict<int, bool>* seen) {
1233 seen = seen ? seen : Alloc<Dict<int, bool>>();
1234 int heap_id = ObjectId(this);
1235 if (dict_contains(seen, heap_id)) {
1236 return Alloc<hnode::AlreadySeen>(heap_id);
1237 }
1238 seen->set(heap_id, true);
1239 hnode::Record* out_node = runtime::NewRecord(StrFromC("HayNode"));
1240 List<Field*>* L = out_node->fields;
1241
1242 if (this->children) { // Dict
1243 auto m = Alloc<hnode::Leaf>(StrFromC("Dict"), color_e::OtherConst);
1244 hnode::Array* x0 = Alloc<hnode::Array>(NewList<hnode_t*>({m}));
1245 for (DictIter<BigStr*, HayNode*> it(this->children); !it.Done(); it.Next())
1246 {
1247 auto k0 = it.Key();
1248 auto v0 = it.Value();
1249 x0->children->append(runtime::NewLeaf(k0, color_e::StringConst));
1250 x0->children->append(v0->PrettyTree(seen));
1251 }
1252 L->append(Alloc<Field>(StrFromC ("children"), x0));
1253 }
1254
1255 return out_node;
1256}
1257
1258BigStr* comp_action_str(comp_action_e tag, bool dot) {
1259 char buf[32];
1260 const char* v = nullptr;
1261 switch (tag) {
1262 case comp_action_e::Other:
1263 v = "Other"; break;
1264 case comp_action_e::FileSystem:
1265 v = "FileSystem"; break;
1266 case comp_action_e::BashFunc:
1267 v = "BashFunc"; break;
1268 default:
1269 assert(0);
1270 }
1271 if (dot) {
1272 snprintf(buf, 32, "comp_action.%s", v);
1273 return StrFromC(buf);
1274 } else {
1275 return StrFromC(v);
1276 }
1277}
1278
1279} // namespace runtime_asdl