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

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