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

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