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