1 | // _gen/core/value.asdl.cc is generated by asdl_main.py
|
2 |
|
3 | #include "_gen/core/value.asdl.h"
|
4 | #include <assert.h>
|
5 | #include "prebuilt/asdl/runtime.mycpp.h" // generated code uses wrappers here
|
6 | #include "_gen/frontend/syntax.asdl.h" // "use" in ASDL
|
7 | #include "_gen/core/runtime.asdl.h" // "use" in ASDL
|
8 |
|
9 | // Generated code uses these types
|
10 | using hnode_asdl::hnode;
|
11 | using hnode_asdl::Field;
|
12 | using hnode_asdl::color_e;
|
13 |
|
14 |
|
15 | namespace value_asdl {
|
16 |
|
17 |
|
18 | hnode_t* IntBox::PrettyTree(Dict<int, bool>* seen) {
|
19 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
20 | int heap_id = ObjectId(this);
|
21 | if (dict_contains(seen, heap_id)) {
|
22 | return Alloc<hnode::AlreadySeen>(heap_id);
|
23 | }
|
24 | seen->set(heap_id, true);
|
25 | hnode::Record* out_node = runtime::NewRecord(StrFromC("IntBox"));
|
26 | List<Field*>* L = out_node->fields;
|
27 |
|
28 | hnode_t* x0 = Alloc<hnode::Leaf>(str(this->i), color_e::OtherConst);
|
29 | L->append(Alloc<Field>(StrFromC("i"), x0));
|
30 |
|
31 | return out_node;
|
32 | }
|
33 |
|
34 |
|
35 | hnode_t* ProcDefaults::PrettyTree(Dict<int, bool>* seen) {
|
36 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
37 | int heap_id = ObjectId(this);
|
38 | if (dict_contains(seen, heap_id)) {
|
39 | return Alloc<hnode::AlreadySeen>(heap_id);
|
40 | }
|
41 | seen->set(heap_id, true);
|
42 | hnode::Record* out_node = runtime::NewRecord(StrFromC("ProcDefaults"));
|
43 | List<Field*>* L = out_node->fields;
|
44 |
|
45 | if (this->for_word != nullptr) { // List
|
46 | hnode::Array* x0 = Alloc<hnode::Array>(Alloc<List<hnode_t*>>());
|
47 | for (ListIter<value_t*> it(this->for_word); !it.Done(); it.Next()) {
|
48 | value_t* i0 = it.Value();
|
49 | hnode_t* h = (i0 == nullptr) ? Alloc<hnode::Leaf>(StrFromC("_"),
|
50 | color_e::OtherConst) : i0->PrettyTree(seen);
|
51 | x0->children->append(h);
|
52 | }
|
53 | L->append(Alloc<Field>(StrFromC("for_word"), x0));
|
54 | }
|
55 |
|
56 | if (this->for_typed != nullptr) { // List
|
57 | hnode::Array* x1 = Alloc<hnode::Array>(Alloc<List<hnode_t*>>());
|
58 | for (ListIter<value_t*> it(this->for_typed); !it.Done(); it.Next()) {
|
59 | value_t* i1 = it.Value();
|
60 | hnode_t* h = (i1 == nullptr) ? Alloc<hnode::Leaf>(StrFromC("_"),
|
61 | color_e::OtherConst) : i1->PrettyTree(seen);
|
62 | x1->children->append(h);
|
63 | }
|
64 | L->append(Alloc<Field>(StrFromC("for_typed"), x1));
|
65 | }
|
66 |
|
67 | if (this->for_named) { // Dict
|
68 | auto m = Alloc<hnode::Leaf>(StrFromC("Dict"), color_e::OtherConst);
|
69 | hnode::Array* x2 = Alloc<hnode::Array>(NewList<hnode_t*>({m}));
|
70 | for (DictIter<BigStr*, value_t*> it(this->for_named); !it.Done();
|
71 | it.Next()) {
|
72 | auto k2 = it.Key();
|
73 | auto v2 = it.Value();
|
74 | x2->children->append(runtime::NewLeaf(k2, color_e::StringConst));
|
75 | x2->children->append(v2->PrettyTree(seen));
|
76 | }
|
77 | L->append(Alloc<Field>(StrFromC ("for_named"), x2));
|
78 | }
|
79 |
|
80 | if (this->for_block) { // Optional
|
81 | hnode_t* x3 = this->for_block->PrettyTree(seen);
|
82 | L->append(Alloc<Field>(StrFromC("for_block"), x3));
|
83 | }
|
84 |
|
85 | return out_node;
|
86 | }
|
87 |
|
88 |
|
89 | hnode_t* LeftName::PrettyTree(Dict<int, bool>* seen) {
|
90 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
91 | int heap_id = ObjectId(this);
|
92 | if (dict_contains(seen, heap_id)) {
|
93 | return Alloc<hnode::AlreadySeen>(heap_id);
|
94 | }
|
95 | seen->set(heap_id, true);
|
96 | hnode::Record* out_node = runtime::NewRecord(StrFromC("LeftName"));
|
97 | List<Field*>* L = out_node->fields;
|
98 |
|
99 | hnode_t* x0 = runtime::NewLeaf(this->name, color_e::StringConst);
|
100 | L->append(Alloc<Field>(StrFromC("name"), x0));
|
101 |
|
102 | hnode_t* x1 = this->blame_loc->PrettyTree(seen);
|
103 | L->append(Alloc<Field>(StrFromC("blame_loc"), x1));
|
104 |
|
105 | return out_node;
|
106 | }
|
107 |
|
108 | BigStr* y_lvalue_str(int tag, bool dot) {
|
109 | char buf[32];
|
110 | const char* v = nullptr;
|
111 | switch (tag) {
|
112 | case y_lvalue_e::Local:
|
113 | v = "Local"; break;
|
114 | case y_lvalue_e::Container:
|
115 | v = "Container"; break;
|
116 | default:
|
117 | assert(0);
|
118 | }
|
119 | if (dot) {
|
120 | snprintf(buf, 32, "y_lvalue.%s", v);
|
121 | return StrFromC(buf);
|
122 | } else {
|
123 | return StrFromC(v);
|
124 | }
|
125 | }
|
126 |
|
127 | hnode_t* y_lvalue__Container::PrettyTree(Dict<int, bool>* seen) {
|
128 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
129 | int heap_id = ObjectId(this);
|
130 | if (dict_contains(seen, heap_id)) {
|
131 | return Alloc<hnode::AlreadySeen>(heap_id);
|
132 | }
|
133 | seen->set(heap_id, true);
|
134 | hnode::Record* out_node = runtime::NewRecord(y_lvalue_str(this->tag()));
|
135 | List<Field*>* L = out_node->fields;
|
136 |
|
137 | hnode_t* x0 = this->obj->PrettyTree(seen);
|
138 | L->append(Alloc<Field>(StrFromC("obj"), x0));
|
139 |
|
140 | hnode_t* x1 = this->index->PrettyTree(seen);
|
141 | L->append(Alloc<Field>(StrFromC("index"), x1));
|
142 |
|
143 | return out_node;
|
144 | }
|
145 |
|
146 |
|
147 | hnode_t* y_lvalue_t::PrettyTree(Dict<int, bool>* seen) {
|
148 | switch (this->tag()) {
|
149 | case y_lvalue_e::Local: {
|
150 | LeftName* obj = static_cast<LeftName*>(this);
|
151 | return obj->PrettyTree(seen);
|
152 | }
|
153 | case y_lvalue_e::Container: {
|
154 | y_lvalue__Container* obj = static_cast<y_lvalue__Container*>(this);
|
155 | return obj->PrettyTree(seen);
|
156 | }
|
157 | default:
|
158 | assert(0);
|
159 | }
|
160 | }
|
161 | BigStr* sh_lvalue_str(int tag, bool dot) {
|
162 | char buf[32];
|
163 | const char* v = nullptr;
|
164 | switch (tag) {
|
165 | case sh_lvalue_e::Var:
|
166 | v = "Var"; break;
|
167 | case sh_lvalue_e::Indexed:
|
168 | v = "Indexed"; break;
|
169 | case sh_lvalue_e::Keyed:
|
170 | v = "Keyed"; break;
|
171 | default:
|
172 | assert(0);
|
173 | }
|
174 | if (dot) {
|
175 | snprintf(buf, 32, "sh_lvalue.%s", v);
|
176 | return StrFromC(buf);
|
177 | } else {
|
178 | return StrFromC(v);
|
179 | }
|
180 | }
|
181 |
|
182 | hnode_t* sh_lvalue__Indexed::PrettyTree(Dict<int, bool>* seen) {
|
183 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
184 | int heap_id = ObjectId(this);
|
185 | if (dict_contains(seen, heap_id)) {
|
186 | return Alloc<hnode::AlreadySeen>(heap_id);
|
187 | }
|
188 | seen->set(heap_id, true);
|
189 | hnode::Record* out_node = runtime::NewRecord(sh_lvalue_str(this->tag()));
|
190 | List<Field*>* L = out_node->fields;
|
191 |
|
192 | hnode_t* x0 = runtime::NewLeaf(this->name, color_e::StringConst);
|
193 | L->append(Alloc<Field>(StrFromC("name"), x0));
|
194 |
|
195 | hnode_t* x1 = Alloc<hnode::Leaf>(str(this->index), color_e::OtherConst);
|
196 | L->append(Alloc<Field>(StrFromC("index"), x1));
|
197 |
|
198 | hnode_t* x2 = this->blame_loc->PrettyTree(seen);
|
199 | L->append(Alloc<Field>(StrFromC("blame_loc"), x2));
|
200 |
|
201 | return out_node;
|
202 | }
|
203 |
|
204 |
|
205 | hnode_t* sh_lvalue__Keyed::PrettyTree(Dict<int, bool>* seen) {
|
206 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
207 | int heap_id = ObjectId(this);
|
208 | if (dict_contains(seen, heap_id)) {
|
209 | return Alloc<hnode::AlreadySeen>(heap_id);
|
210 | }
|
211 | seen->set(heap_id, true);
|
212 | hnode::Record* out_node = runtime::NewRecord(sh_lvalue_str(this->tag()));
|
213 | List<Field*>* L = out_node->fields;
|
214 |
|
215 | hnode_t* x0 = runtime::NewLeaf(this->name, color_e::StringConst);
|
216 | L->append(Alloc<Field>(StrFromC("name"), x0));
|
217 |
|
218 | hnode_t* x1 = runtime::NewLeaf(this->key, color_e::StringConst);
|
219 | L->append(Alloc<Field>(StrFromC("key"), x1));
|
220 |
|
221 | hnode_t* x2 = this->blame_loc->PrettyTree(seen);
|
222 | L->append(Alloc<Field>(StrFromC("blame_loc"), x2));
|
223 |
|
224 | return out_node;
|
225 | }
|
226 |
|
227 |
|
228 | hnode_t* sh_lvalue_t::PrettyTree(Dict<int, bool>* seen) {
|
229 | switch (this->tag()) {
|
230 | case sh_lvalue_e::Var: {
|
231 | LeftName* obj = static_cast<LeftName*>(this);
|
232 | return obj->PrettyTree(seen);
|
233 | }
|
234 | case sh_lvalue_e::Indexed: {
|
235 | sh_lvalue__Indexed* obj = static_cast<sh_lvalue__Indexed*>(this);
|
236 | return obj->PrettyTree(seen);
|
237 | }
|
238 | case sh_lvalue_e::Keyed: {
|
239 | sh_lvalue__Keyed* obj = static_cast<sh_lvalue__Keyed*>(this);
|
240 | return obj->PrettyTree(seen);
|
241 | }
|
242 | default:
|
243 | assert(0);
|
244 | }
|
245 | }
|
246 | BigStr* eggex_ops_str(int tag, bool dot) {
|
247 | char buf[32];
|
248 | const char* v = nullptr;
|
249 | switch (tag) {
|
250 | case eggex_ops_e::No:
|
251 | v = "No"; break;
|
252 | case eggex_ops_e::Yes:
|
253 | v = "Yes"; break;
|
254 | default:
|
255 | assert(0);
|
256 | }
|
257 | if (dot) {
|
258 | snprintf(buf, 32, "eggex_ops.%s", v);
|
259 | return StrFromC(buf);
|
260 | } else {
|
261 | return StrFromC(v);
|
262 | }
|
263 | }
|
264 |
|
265 | eggex_ops__No* eggex_ops::No = &geggex_ops__No.obj;
|
266 |
|
267 | GcGlobal<eggex_ops__No> geggex_ops__No =
|
268 | { ObjHeader::Global(eggex_ops_e::No) };
|
269 |
|
270 | hnode_t* eggex_ops__No::PrettyTree(Dict<int, bool>* seen) {
|
271 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
272 | int heap_id = ObjectId(this);
|
273 | if (dict_contains(seen, heap_id)) {
|
274 | return Alloc<hnode::AlreadySeen>(heap_id);
|
275 | }
|
276 | seen->set(heap_id, true);
|
277 | hnode::Record* out_node = runtime::NewRecord(eggex_ops_str(this->tag()));
|
278 | return out_node;
|
279 | }
|
280 |
|
281 |
|
282 | hnode_t* eggex_ops__Yes::PrettyTree(Dict<int, bool>* seen) {
|
283 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
284 | int heap_id = ObjectId(this);
|
285 | if (dict_contains(seen, heap_id)) {
|
286 | return Alloc<hnode::AlreadySeen>(heap_id);
|
287 | }
|
288 | seen->set(heap_id, true);
|
289 | hnode::Record* out_node = runtime::NewRecord(eggex_ops_str(this->tag()));
|
290 | List<Field*>* L = out_node->fields;
|
291 |
|
292 | if (this->convert_funcs != nullptr) { // List
|
293 | hnode::Array* x0 = Alloc<hnode::Array>(Alloc<List<hnode_t*>>());
|
294 | for (ListIter<value_t*> it(this->convert_funcs); !it.Done(); it.Next()) {
|
295 | value_t* i0 = it.Value();
|
296 | hnode_t* h = (i0 == nullptr) ? Alloc<hnode::Leaf>(StrFromC("_"),
|
297 | color_e::OtherConst) : i0->PrettyTree(seen);
|
298 | x0->children->append(h);
|
299 | }
|
300 | L->append(Alloc<Field>(StrFromC("convert_funcs"), x0));
|
301 | }
|
302 |
|
303 | if (this->convert_toks != nullptr) { // List
|
304 | hnode::Array* x1 = Alloc<hnode::Array>(Alloc<List<hnode_t*>>());
|
305 | for (ListIter<syntax_asdl::Token*> it(this->convert_toks); !it.Done();
|
306 | it.Next()) {
|
307 | syntax_asdl::Token* i1 = it.Value();
|
308 | hnode_t* h = (i1 == nullptr) ? Alloc<hnode::Leaf>(StrFromC("_"),
|
309 | color_e::OtherConst) : i1->PrettyTree(seen);
|
310 | x1->children->append(h);
|
311 | }
|
312 | L->append(Alloc<Field>(StrFromC("convert_toks"), x1));
|
313 | }
|
314 |
|
315 | if (this->capture_names != nullptr) { // List
|
316 | hnode::Array* x2 = Alloc<hnode::Array>(Alloc<List<hnode_t*>>());
|
317 | for (ListIter<BigStr*> it(this->capture_names); !it.Done(); it.Next()) {
|
318 | BigStr* i2 = it.Value();
|
319 | x2->children->append(runtime::NewLeaf(i2, color_e::StringConst));
|
320 | }
|
321 | L->append(Alloc<Field>(StrFromC("capture_names"), x2));
|
322 | }
|
323 |
|
324 | return out_node;
|
325 | }
|
326 |
|
327 |
|
328 | hnode_t* eggex_ops_t::PrettyTree(Dict<int, bool>* seen) {
|
329 | switch (this->tag()) {
|
330 | case eggex_ops_e::No: {
|
331 | eggex_ops__No* obj = static_cast<eggex_ops__No*>(this);
|
332 | return obj->PrettyTree(seen);
|
333 | }
|
334 | case eggex_ops_e::Yes: {
|
335 | eggex_ops__Yes* obj = static_cast<eggex_ops__Yes*>(this);
|
336 | return obj->PrettyTree(seen);
|
337 | }
|
338 | default:
|
339 | assert(0);
|
340 | }
|
341 | }
|
342 |
|
343 | hnode_t* RegexMatch::PrettyTree(Dict<int, bool>* seen) {
|
344 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
345 | int heap_id = ObjectId(this);
|
346 | if (dict_contains(seen, heap_id)) {
|
347 | return Alloc<hnode::AlreadySeen>(heap_id);
|
348 | }
|
349 | seen->set(heap_id, true);
|
350 | hnode::Record* out_node = runtime::NewRecord(StrFromC("RegexMatch"));
|
351 | List<Field*>* L = out_node->fields;
|
352 |
|
353 | hnode_t* x0 = runtime::NewLeaf(this->s, color_e::StringConst);
|
354 | L->append(Alloc<Field>(StrFromC("s"), x0));
|
355 |
|
356 | if (this->indices != nullptr) { // List
|
357 | hnode::Array* x1 = Alloc<hnode::Array>(Alloc<List<hnode_t*>>());
|
358 | for (ListIter<int> it(this->indices); !it.Done(); it.Next()) {
|
359 | int i1 = it.Value();
|
360 | x1->children->append(Alloc<hnode::Leaf>(str(i1), color_e::OtherConst));
|
361 | }
|
362 | L->append(Alloc<Field>(StrFromC("indices"), x1));
|
363 | }
|
364 |
|
365 | hnode_t* x2 = this->ops->PrettyTree(seen);
|
366 | L->append(Alloc<Field>(StrFromC("ops"), x2));
|
367 |
|
368 | return out_node;
|
369 | }
|
370 |
|
371 | BigStr* regex_match_str(int tag, bool dot) {
|
372 | char buf[32];
|
373 | const char* v = nullptr;
|
374 | switch (tag) {
|
375 | case regex_match_e::No:
|
376 | v = "No"; break;
|
377 | case regex_match_e::Yes:
|
378 | v = "Yes"; break;
|
379 | default:
|
380 | assert(0);
|
381 | }
|
382 | if (dot) {
|
383 | snprintf(buf, 32, "regex_match.%s", v);
|
384 | return StrFromC(buf);
|
385 | } else {
|
386 | return StrFromC(v);
|
387 | }
|
388 | }
|
389 |
|
390 | regex_match__No* regex_match::No = &gregex_match__No.obj;
|
391 |
|
392 | GcGlobal<regex_match__No> gregex_match__No =
|
393 | { ObjHeader::Global(regex_match_e::No) };
|
394 |
|
395 | hnode_t* regex_match__No::PrettyTree(Dict<int, bool>* seen) {
|
396 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
397 | int heap_id = ObjectId(this);
|
398 | if (dict_contains(seen, heap_id)) {
|
399 | return Alloc<hnode::AlreadySeen>(heap_id);
|
400 | }
|
401 | seen->set(heap_id, true);
|
402 | hnode::Record* out_node = runtime::NewRecord(regex_match_str(this->tag()));
|
403 | return out_node;
|
404 | }
|
405 |
|
406 |
|
407 | hnode_t* regex_match_t::PrettyTree(Dict<int, bool>* seen) {
|
408 | switch (this->tag()) {
|
409 | case regex_match_e::No: {
|
410 | regex_match__No* obj = static_cast<regex_match__No*>(this);
|
411 | return obj->PrettyTree(seen);
|
412 | }
|
413 | case regex_match_e::Yes: {
|
414 | RegexMatch* obj = static_cast<RegexMatch*>(this);
|
415 | return obj->PrettyTree(seen);
|
416 | }
|
417 | default:
|
418 | assert(0);
|
419 | }
|
420 | }
|
421 | BigStr* value_str(int tag, bool dot) {
|
422 | char buf[32];
|
423 | const char* v = nullptr;
|
424 | switch (tag) {
|
425 | case value_e::Undef:
|
426 | v = "Undef"; break;
|
427 | case value_e::Str:
|
428 | v = "Str"; break;
|
429 | case value_e::BashArray:
|
430 | v = "BashArray"; break;
|
431 | case value_e::BashAssoc:
|
432 | v = "BashAssoc"; break;
|
433 | case value_e::Null:
|
434 | v = "Null"; break;
|
435 | case value_e::Bool:
|
436 | v = "Bool"; break;
|
437 | case value_e::Int:
|
438 | v = "Int"; break;
|
439 | case value_e::Float:
|
440 | v = "Float"; break;
|
441 | case value_e::List:
|
442 | v = "List"; break;
|
443 | case value_e::Dict:
|
444 | v = "Dict"; break;
|
445 | case value_e::Eggex:
|
446 | v = "Eggex"; break;
|
447 | case value_e::Match:
|
448 | v = "Match"; break;
|
449 | case value_e::Expr:
|
450 | v = "Expr"; break;
|
451 | case value_e::Command:
|
452 | v = "Command"; break;
|
453 | case value_e::Block:
|
454 | v = "Block"; break;
|
455 | case value_e::Place:
|
456 | v = "Place"; break;
|
457 | case value_e::Module:
|
458 | v = "Module"; break;
|
459 | case value_e::IO:
|
460 | v = "IO"; break;
|
461 | case value_e::Guts:
|
462 | v = "Guts"; break;
|
463 | case value_e::BuiltinFunc:
|
464 | v = "BuiltinFunc"; break;
|
465 | case value_e::BoundFunc:
|
466 | v = "BoundFunc"; break;
|
467 | case value_e::Proc:
|
468 | v = "Proc"; break;
|
469 | case value_e::Func:
|
470 | v = "Func"; break;
|
471 | case value_e::Slice:
|
472 | v = "Slice"; break;
|
473 | case value_e::Range:
|
474 | v = "Range"; break;
|
475 | default:
|
476 | assert(0);
|
477 | }
|
478 | if (dot) {
|
479 | snprintf(buf, 32, "value.%s", v);
|
480 | return StrFromC(buf);
|
481 | } else {
|
482 | return StrFromC(v);
|
483 | }
|
484 | }
|
485 |
|
486 | value__Undef* value::Undef = &gvalue__Undef.obj;
|
487 |
|
488 | GcGlobal<value__Undef> gvalue__Undef =
|
489 | { ObjHeader::Global(value_e::Undef) };
|
490 |
|
491 | value__Null* value::Null = &gvalue__Null.obj;
|
492 |
|
493 | GcGlobal<value__Null> gvalue__Null =
|
494 | { ObjHeader::Global(value_e::Null) };
|
495 |
|
496 | hnode_t* value__Undef::PrettyTree(Dict<int, bool>* seen) {
|
497 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
498 | int heap_id = ObjectId(this);
|
499 | if (dict_contains(seen, heap_id)) {
|
500 | return Alloc<hnode::AlreadySeen>(heap_id);
|
501 | }
|
502 | seen->set(heap_id, true);
|
503 | hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
|
504 | return out_node;
|
505 | }
|
506 |
|
507 |
|
508 | hnode_t* value__Str::PrettyTree(Dict<int, bool>* seen) {
|
509 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
510 | int heap_id = ObjectId(this);
|
511 | if (dict_contains(seen, heap_id)) {
|
512 | return Alloc<hnode::AlreadySeen>(heap_id);
|
513 | }
|
514 | seen->set(heap_id, true);
|
515 | hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
|
516 | List<Field*>* L = out_node->fields;
|
517 |
|
518 | hnode_t* x0 = runtime::NewLeaf(this->s, color_e::StringConst);
|
519 | L->append(Alloc<Field>(StrFromC("s"), x0));
|
520 |
|
521 | return out_node;
|
522 | }
|
523 |
|
524 |
|
525 | hnode_t* value__BashArray::PrettyTree(Dict<int, bool>* seen) {
|
526 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
527 | int heap_id = ObjectId(this);
|
528 | if (dict_contains(seen, heap_id)) {
|
529 | return Alloc<hnode::AlreadySeen>(heap_id);
|
530 | }
|
531 | seen->set(heap_id, true);
|
532 | hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
|
533 | List<Field*>* L = out_node->fields;
|
534 |
|
535 | if (this->strs != nullptr) { // List
|
536 | hnode::Array* x0 = Alloc<hnode::Array>(Alloc<List<hnode_t*>>());
|
537 | for (ListIter<BigStr*> it(this->strs); !it.Done(); it.Next()) {
|
538 | BigStr* i0 = it.Value();
|
539 | x0->children->append(runtime::NewLeaf(i0, color_e::StringConst));
|
540 | }
|
541 | L->append(Alloc<Field>(StrFromC("strs"), x0));
|
542 | }
|
543 |
|
544 | return out_node;
|
545 | }
|
546 |
|
547 |
|
548 | hnode_t* value__BashAssoc::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(value_str(this->tag()));
|
556 | List<Field*>* L = out_node->fields;
|
557 |
|
558 | if (this->d) { // Dict
|
559 | auto m = Alloc<hnode::Leaf>(StrFromC("Dict"), color_e::OtherConst);
|
560 | hnode::Array* x0 = Alloc<hnode::Array>(NewList<hnode_t*>({m}));
|
561 | for (DictIter<BigStr*, BigStr*> it(this->d); !it.Done(); it.Next()) {
|
562 | auto k0 = it.Key();
|
563 | auto v0 = it.Value();
|
564 | x0->children->append(runtime::NewLeaf(k0, color_e::StringConst));
|
565 | x0->children->append(runtime::NewLeaf(v0, color_e::StringConst));
|
566 | }
|
567 | L->append(Alloc<Field>(StrFromC ("d"), x0));
|
568 | }
|
569 |
|
570 | return out_node;
|
571 | }
|
572 |
|
573 |
|
574 | hnode_t* value__Null::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(value_str(this->tag()));
|
582 | return out_node;
|
583 | }
|
584 |
|
585 |
|
586 | hnode_t* value__Bool::PrettyTree(Dict<int, bool>* seen) {
|
587 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
588 | int heap_id = ObjectId(this);
|
589 | if (dict_contains(seen, heap_id)) {
|
590 | return Alloc<hnode::AlreadySeen>(heap_id);
|
591 | }
|
592 | seen->set(heap_id, true);
|
593 | hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
|
594 | List<Field*>* L = out_node->fields;
|
595 |
|
596 | hnode_t* x0 = Alloc<hnode::Leaf>(this->b ? runtime::TRUE_STR :
|
597 | runtime::FALSE_STR, color_e::OtherConst);
|
598 | L->append(Alloc<Field>(StrFromC("b"), x0));
|
599 |
|
600 | return out_node;
|
601 | }
|
602 |
|
603 |
|
604 | hnode_t* value__Int::PrettyTree(Dict<int, bool>* seen) {
|
605 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
606 | int heap_id = ObjectId(this);
|
607 | if (dict_contains(seen, heap_id)) {
|
608 | return Alloc<hnode::AlreadySeen>(heap_id);
|
609 | }
|
610 | seen->set(heap_id, true);
|
611 | hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
|
612 | List<Field*>* L = out_node->fields;
|
613 |
|
614 | hnode_t* x0 = Alloc<hnode::Leaf>(mops::ToStr(this->i), color_e::OtherConst);
|
615 | L->append(Alloc<Field>(StrFromC("i"), x0));
|
616 |
|
617 | return out_node;
|
618 | }
|
619 |
|
620 |
|
621 | hnode_t* value__Float::PrettyTree(Dict<int, bool>* seen) {
|
622 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
623 | int heap_id = ObjectId(this);
|
624 | if (dict_contains(seen, heap_id)) {
|
625 | return Alloc<hnode::AlreadySeen>(heap_id);
|
626 | }
|
627 | seen->set(heap_id, true);
|
628 | hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
|
629 | List<Field*>* L = out_node->fields;
|
630 |
|
631 | hnode_t* x0 = Alloc<hnode::Leaf>(str(this->f), color_e::OtherConst);
|
632 | L->append(Alloc<Field>(StrFromC("f"), x0));
|
633 |
|
634 | return out_node;
|
635 | }
|
636 |
|
637 |
|
638 | hnode_t* value__List::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(value_str(this->tag()));
|
646 | List<Field*>* L = out_node->fields;
|
647 |
|
648 | if (this->items != nullptr) { // List
|
649 | hnode::Array* x0 = Alloc<hnode::Array>(Alloc<List<hnode_t*>>());
|
650 | for (ListIter<value_t*> it(this->items); !it.Done(); it.Next()) {
|
651 | value_t* i0 = it.Value();
|
652 | hnode_t* h = (i0 == nullptr) ? Alloc<hnode::Leaf>(StrFromC("_"),
|
653 | color_e::OtherConst) : i0->PrettyTree(seen);
|
654 | x0->children->append(h);
|
655 | }
|
656 | L->append(Alloc<Field>(StrFromC("items"), x0));
|
657 | }
|
658 |
|
659 | return out_node;
|
660 | }
|
661 |
|
662 |
|
663 | hnode_t* value__Dict::PrettyTree(Dict<int, bool>* seen) {
|
664 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
665 | int heap_id = ObjectId(this);
|
666 | if (dict_contains(seen, heap_id)) {
|
667 | return Alloc<hnode::AlreadySeen>(heap_id);
|
668 | }
|
669 | seen->set(heap_id, true);
|
670 | hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
|
671 | List<Field*>* L = out_node->fields;
|
672 |
|
673 | if (this->d) { // Dict
|
674 | auto m = Alloc<hnode::Leaf>(StrFromC("Dict"), color_e::OtherConst);
|
675 | hnode::Array* x0 = Alloc<hnode::Array>(NewList<hnode_t*>({m}));
|
676 | for (DictIter<BigStr*, value_t*> it(this->d); !it.Done(); it.Next()) {
|
677 | auto k0 = it.Key();
|
678 | auto v0 = it.Value();
|
679 | x0->children->append(runtime::NewLeaf(k0, color_e::StringConst));
|
680 | x0->children->append(v0->PrettyTree(seen));
|
681 | }
|
682 | L->append(Alloc<Field>(StrFromC ("d"), x0));
|
683 | }
|
684 |
|
685 | return out_node;
|
686 | }
|
687 |
|
688 |
|
689 | hnode_t* value__Eggex::PrettyTree(Dict<int, bool>* seen) {
|
690 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
691 | int heap_id = ObjectId(this);
|
692 | if (dict_contains(seen, heap_id)) {
|
693 | return Alloc<hnode::AlreadySeen>(heap_id);
|
694 | }
|
695 | seen->set(heap_id, true);
|
696 | hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
|
697 | List<Field*>* L = out_node->fields;
|
698 |
|
699 | hnode_t* x0 = this->spliced->PrettyTree(seen);
|
700 | L->append(Alloc<Field>(StrFromC("spliced"), x0));
|
701 |
|
702 | hnode_t* x1 = runtime::NewLeaf(this->canonical_flags, color_e::StringConst);
|
703 | L->append(Alloc<Field>(StrFromC("canonical_flags"), x1));
|
704 |
|
705 | if (this->convert_funcs != nullptr) { // List
|
706 | hnode::Array* x2 = Alloc<hnode::Array>(Alloc<List<hnode_t*>>());
|
707 | for (ListIter<value_t*> it(this->convert_funcs); !it.Done(); it.Next()) {
|
708 | value_t* i2 = it.Value();
|
709 | hnode_t* h = (i2 == nullptr) ? Alloc<hnode::Leaf>(StrFromC("_"),
|
710 | color_e::OtherConst) : i2->PrettyTree(seen);
|
711 | x2->children->append(h);
|
712 | }
|
713 | L->append(Alloc<Field>(StrFromC("convert_funcs"), x2));
|
714 | }
|
715 |
|
716 | if (this->convert_toks != nullptr) { // List
|
717 | hnode::Array* x3 = Alloc<hnode::Array>(Alloc<List<hnode_t*>>());
|
718 | for (ListIter<syntax_asdl::Token*> it(this->convert_toks); !it.Done();
|
719 | it.Next()) {
|
720 | syntax_asdl::Token* i3 = it.Value();
|
721 | hnode_t* h = (i3 == nullptr) ? Alloc<hnode::Leaf>(StrFromC("_"),
|
722 | color_e::OtherConst) : i3->PrettyTree(seen);
|
723 | x3->children->append(h);
|
724 | }
|
725 | L->append(Alloc<Field>(StrFromC("convert_toks"), x3));
|
726 | }
|
727 |
|
728 | if (this->as_ere) { // Optional
|
729 | hnode_t* x4 = runtime::NewLeaf(this->as_ere, color_e::StringConst);
|
730 | L->append(Alloc<Field>(StrFromC("as_ere"), x4));
|
731 | }
|
732 |
|
733 | if (this->capture_names != nullptr) { // List
|
734 | hnode::Array* x5 = Alloc<hnode::Array>(Alloc<List<hnode_t*>>());
|
735 | for (ListIter<BigStr*> it(this->capture_names); !it.Done(); it.Next()) {
|
736 | BigStr* i5 = it.Value();
|
737 | x5->children->append(runtime::NewLeaf(i5, color_e::StringConst));
|
738 | }
|
739 | L->append(Alloc<Field>(StrFromC("capture_names"), x5));
|
740 | }
|
741 |
|
742 | return out_node;
|
743 | }
|
744 |
|
745 |
|
746 | hnode_t* value__Expr::PrettyTree(Dict<int, bool>* seen) {
|
747 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
748 | int heap_id = ObjectId(this);
|
749 | if (dict_contains(seen, heap_id)) {
|
750 | return Alloc<hnode::AlreadySeen>(heap_id);
|
751 | }
|
752 | seen->set(heap_id, true);
|
753 | hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
|
754 | List<Field*>* L = out_node->fields;
|
755 |
|
756 | hnode_t* x0 = this->e->PrettyTree(seen);
|
757 | L->append(Alloc<Field>(StrFromC("e"), x0));
|
758 |
|
759 | return out_node;
|
760 | }
|
761 |
|
762 |
|
763 | hnode_t* value__Command::PrettyTree(Dict<int, bool>* seen) {
|
764 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
765 | int heap_id = ObjectId(this);
|
766 | if (dict_contains(seen, heap_id)) {
|
767 | return Alloc<hnode::AlreadySeen>(heap_id);
|
768 | }
|
769 | seen->set(heap_id, true);
|
770 | hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
|
771 | List<Field*>* L = out_node->fields;
|
772 |
|
773 | hnode_t* x0 = this->c->PrettyTree(seen);
|
774 | L->append(Alloc<Field>(StrFromC("c"), x0));
|
775 |
|
776 | return out_node;
|
777 | }
|
778 |
|
779 |
|
780 | hnode_t* value__Block::PrettyTree(Dict<int, bool>* seen) {
|
781 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
782 | int heap_id = ObjectId(this);
|
783 | if (dict_contains(seen, heap_id)) {
|
784 | return Alloc<hnode::AlreadySeen>(heap_id);
|
785 | }
|
786 | seen->set(heap_id, true);
|
787 | hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
|
788 | List<Field*>* L = out_node->fields;
|
789 |
|
790 | hnode_t* x0 = this->block->PrettyTree(seen);
|
791 | L->append(Alloc<Field>(StrFromC("block"), x0));
|
792 |
|
793 | return out_node;
|
794 | }
|
795 |
|
796 |
|
797 | hnode_t* value__Place::PrettyTree(Dict<int, bool>* seen) {
|
798 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
799 | int heap_id = ObjectId(this);
|
800 | if (dict_contains(seen, heap_id)) {
|
801 | return Alloc<hnode::AlreadySeen>(heap_id);
|
802 | }
|
803 | seen->set(heap_id, true);
|
804 | hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
|
805 | List<Field*>* L = out_node->fields;
|
806 |
|
807 | hnode_t* x0 = this->lval->PrettyTree(seen);
|
808 | L->append(Alloc<Field>(StrFromC("lval"), x0));
|
809 |
|
810 | if (this->frame) { // Dict
|
811 | auto m = Alloc<hnode::Leaf>(StrFromC("Dict"), color_e::OtherConst);
|
812 | hnode::Array* x1 = Alloc<hnode::Array>(NewList<hnode_t*>({m}));
|
813 | for (DictIter<BigStr*, runtime_asdl::Cell*> it(this->frame); !it.Done();
|
814 | it.Next()) {
|
815 | auto k1 = it.Key();
|
816 | auto v1 = it.Value();
|
817 | x1->children->append(runtime::NewLeaf(k1, color_e::StringConst));
|
818 | x1->children->append(v1->PrettyTree(seen));
|
819 | }
|
820 | L->append(Alloc<Field>(StrFromC ("frame"), x1));
|
821 | }
|
822 |
|
823 | return out_node;
|
824 | }
|
825 |
|
826 |
|
827 | hnode_t* value__Module::PrettyTree(Dict<int, bool>* seen) {
|
828 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
829 | int heap_id = ObjectId(this);
|
830 | if (dict_contains(seen, heap_id)) {
|
831 | return Alloc<hnode::AlreadySeen>(heap_id);
|
832 | }
|
833 | seen->set(heap_id, true);
|
834 | hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
|
835 | List<Field*>* L = out_node->fields;
|
836 |
|
837 | if (this->defs) { // Dict
|
838 | auto m = Alloc<hnode::Leaf>(StrFromC("Dict"), color_e::OtherConst);
|
839 | hnode::Array* x0 = Alloc<hnode::Array>(NewList<hnode_t*>({m}));
|
840 | for (DictIter<BigStr*, value_t*> it(this->defs); !it.Done(); it.Next()) {
|
841 | auto k0 = it.Key();
|
842 | auto v0 = it.Value();
|
843 | x0->children->append(runtime::NewLeaf(k0, color_e::StringConst));
|
844 | x0->children->append(v0->PrettyTree(seen));
|
845 | }
|
846 | L->append(Alloc<Field>(StrFromC ("defs"), x0));
|
847 | }
|
848 |
|
849 | return out_node;
|
850 | }
|
851 |
|
852 |
|
853 | hnode_t* value__IO::PrettyTree(Dict<int, bool>* seen) {
|
854 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
855 | int heap_id = ObjectId(this);
|
856 | if (dict_contains(seen, heap_id)) {
|
857 | return Alloc<hnode::AlreadySeen>(heap_id);
|
858 | }
|
859 | seen->set(heap_id, true);
|
860 | hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
|
861 | List<Field*>* L = out_node->fields;
|
862 |
|
863 | hnode_t* x0 = Alloc<hnode::External>(this->cmd_ev);
|
864 | L->append(Alloc<Field>(StrFromC("cmd_ev"), x0));
|
865 |
|
866 | hnode_t* x1 = Alloc<hnode::External>(this->prompt_ev);
|
867 | L->append(Alloc<Field>(StrFromC("prompt_ev"), x1));
|
868 |
|
869 | return out_node;
|
870 | }
|
871 |
|
872 |
|
873 | hnode_t* value__Guts::PrettyTree(Dict<int, bool>* seen) {
|
874 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
875 | int heap_id = ObjectId(this);
|
876 | if (dict_contains(seen, heap_id)) {
|
877 | return Alloc<hnode::AlreadySeen>(heap_id);
|
878 | }
|
879 | seen->set(heap_id, true);
|
880 | hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
|
881 | List<Field*>* L = out_node->fields;
|
882 |
|
883 | hnode_t* x0 = Alloc<hnode::External>(this->vm);
|
884 | L->append(Alloc<Field>(StrFromC("vm"), x0));
|
885 |
|
886 | return out_node;
|
887 | }
|
888 |
|
889 |
|
890 | hnode_t* value__BuiltinFunc::PrettyTree(Dict<int, bool>* seen) {
|
891 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
892 | int heap_id = ObjectId(this);
|
893 | if (dict_contains(seen, heap_id)) {
|
894 | return Alloc<hnode::AlreadySeen>(heap_id);
|
895 | }
|
896 | seen->set(heap_id, true);
|
897 | hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
|
898 | List<Field*>* L = out_node->fields;
|
899 |
|
900 | hnode_t* x0 = Alloc<hnode::External>(this->callable);
|
901 | L->append(Alloc<Field>(StrFromC("callable"), x0));
|
902 |
|
903 | return out_node;
|
904 | }
|
905 |
|
906 |
|
907 | hnode_t* value__BoundFunc::PrettyTree(Dict<int, bool>* seen) {
|
908 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
909 | int heap_id = ObjectId(this);
|
910 | if (dict_contains(seen, heap_id)) {
|
911 | return Alloc<hnode::AlreadySeen>(heap_id);
|
912 | }
|
913 | seen->set(heap_id, true);
|
914 | hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
|
915 | List<Field*>* L = out_node->fields;
|
916 |
|
917 | hnode_t* x0 = this->me->PrettyTree(seen);
|
918 | L->append(Alloc<Field>(StrFromC("me"), x0));
|
919 |
|
920 | hnode_t* x1 = this->func->PrettyTree(seen);
|
921 | L->append(Alloc<Field>(StrFromC("func"), x1));
|
922 |
|
923 | return out_node;
|
924 | }
|
925 |
|
926 |
|
927 | hnode_t* value__Proc::PrettyTree(Dict<int, bool>* seen) {
|
928 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
929 | int heap_id = ObjectId(this);
|
930 | if (dict_contains(seen, heap_id)) {
|
931 | return Alloc<hnode::AlreadySeen>(heap_id);
|
932 | }
|
933 | seen->set(heap_id, true);
|
934 | hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
|
935 | List<Field*>* L = out_node->fields;
|
936 |
|
937 | hnode_t* x0 = runtime::NewLeaf(this->name, color_e::StringConst);
|
938 | L->append(Alloc<Field>(StrFromC("name"), x0));
|
939 |
|
940 | hnode_t* x1 = this->name_tok->PrettyTree(seen);
|
941 | L->append(Alloc<Field>(StrFromC("name_tok"), x1));
|
942 |
|
943 | hnode_t* x2 = this->sig->PrettyTree(seen);
|
944 | L->append(Alloc<Field>(StrFromC("sig"), x2));
|
945 |
|
946 | hnode_t* x3 = this->body->PrettyTree(seen);
|
947 | L->append(Alloc<Field>(StrFromC("body"), x3));
|
948 |
|
949 | if (this->defaults) { // Optional
|
950 | hnode_t* x4 = this->defaults->PrettyTree(seen);
|
951 | L->append(Alloc<Field>(StrFromC("defaults"), x4));
|
952 | }
|
953 |
|
954 | hnode_t* x5 = Alloc<hnode::Leaf>(this->sh_compat ? runtime::TRUE_STR :
|
955 | runtime::FALSE_STR, color_e::OtherConst);
|
956 | L->append(Alloc<Field>(StrFromC("sh_compat"), x5));
|
957 |
|
958 | return out_node;
|
959 | }
|
960 |
|
961 |
|
962 | hnode_t* value__Func::PrettyTree(Dict<int, bool>* seen) {
|
963 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
964 | int heap_id = ObjectId(this);
|
965 | if (dict_contains(seen, heap_id)) {
|
966 | return Alloc<hnode::AlreadySeen>(heap_id);
|
967 | }
|
968 | seen->set(heap_id, true);
|
969 | hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
|
970 | List<Field*>* L = out_node->fields;
|
971 |
|
972 | hnode_t* x0 = runtime::NewLeaf(this->name, color_e::StringConst);
|
973 | L->append(Alloc<Field>(StrFromC("name"), x0));
|
974 |
|
975 | hnode_t* x1 = this->parsed->PrettyTree(seen);
|
976 | L->append(Alloc<Field>(StrFromC("parsed"), x1));
|
977 |
|
978 | if (this->pos_defaults != nullptr) { // List
|
979 | hnode::Array* x2 = Alloc<hnode::Array>(Alloc<List<hnode_t*>>());
|
980 | for (ListIter<value_t*> it(this->pos_defaults); !it.Done(); it.Next()) {
|
981 | value_t* i2 = it.Value();
|
982 | hnode_t* h = (i2 == nullptr) ? Alloc<hnode::Leaf>(StrFromC("_"),
|
983 | color_e::OtherConst) : i2->PrettyTree(seen);
|
984 | x2->children->append(h);
|
985 | }
|
986 | L->append(Alloc<Field>(StrFromC("pos_defaults"), x2));
|
987 | }
|
988 |
|
989 | if (this->named_defaults) { // Dict
|
990 | auto m = Alloc<hnode::Leaf>(StrFromC("Dict"), color_e::OtherConst);
|
991 | hnode::Array* x3 = Alloc<hnode::Array>(NewList<hnode_t*>({m}));
|
992 | for (DictIter<BigStr*, value_t*> it(this->named_defaults); !it.Done();
|
993 | it.Next()) {
|
994 | auto k3 = it.Key();
|
995 | auto v3 = it.Value();
|
996 | x3->children->append(runtime::NewLeaf(k3, color_e::StringConst));
|
997 | x3->children->append(v3->PrettyTree(seen));
|
998 | }
|
999 | L->append(Alloc<Field>(StrFromC ("named_defaults"), x3));
|
1000 | }
|
1001 |
|
1002 | if (this->module_) { // Dict
|
1003 | auto m = Alloc<hnode::Leaf>(StrFromC("Dict"), color_e::OtherConst);
|
1004 | hnode::Array* x4 = Alloc<hnode::Array>(NewList<hnode_t*>({m}));
|
1005 | for (DictIter<BigStr*, runtime_asdl::Cell*> it(this->module_); !it.Done();
|
1006 | it.Next()) {
|
1007 | auto k4 = it.Key();
|
1008 | auto v4 = it.Value();
|
1009 | x4->children->append(runtime::NewLeaf(k4, color_e::StringConst));
|
1010 | x4->children->append(v4->PrettyTree(seen));
|
1011 | }
|
1012 | L->append(Alloc<Field>(StrFromC ("module_"), x4));
|
1013 | }
|
1014 |
|
1015 | return out_node;
|
1016 | }
|
1017 |
|
1018 |
|
1019 | hnode_t* value__Slice::PrettyTree(Dict<int, bool>* seen) {
|
1020 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
1021 | int heap_id = ObjectId(this);
|
1022 | if (dict_contains(seen, heap_id)) {
|
1023 | return Alloc<hnode::AlreadySeen>(heap_id);
|
1024 | }
|
1025 | seen->set(heap_id, true);
|
1026 | hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
|
1027 | List<Field*>* L = out_node->fields;
|
1028 |
|
1029 | if (this->lower) { // Optional
|
1030 | hnode_t* x0 = this->lower->PrettyTree(seen);
|
1031 | L->append(Alloc<Field>(StrFromC("lower"), x0));
|
1032 | }
|
1033 |
|
1034 | if (this->upper) { // Optional
|
1035 | hnode_t* x1 = this->upper->PrettyTree(seen);
|
1036 | L->append(Alloc<Field>(StrFromC("upper"), x1));
|
1037 | }
|
1038 |
|
1039 | return out_node;
|
1040 | }
|
1041 |
|
1042 |
|
1043 | hnode_t* value__Range::PrettyTree(Dict<int, bool>* seen) {
|
1044 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
1045 | int heap_id = ObjectId(this);
|
1046 | if (dict_contains(seen, heap_id)) {
|
1047 | return Alloc<hnode::AlreadySeen>(heap_id);
|
1048 | }
|
1049 | seen->set(heap_id, true);
|
1050 | hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
|
1051 | List<Field*>* L = out_node->fields;
|
1052 |
|
1053 | hnode_t* x0 = Alloc<hnode::Leaf>(str(this->lower), color_e::OtherConst);
|
1054 | L->append(Alloc<Field>(StrFromC("lower"), x0));
|
1055 |
|
1056 | hnode_t* x1 = Alloc<hnode::Leaf>(str(this->upper), color_e::OtherConst);
|
1057 | L->append(Alloc<Field>(StrFromC("upper"), x1));
|
1058 |
|
1059 | return out_node;
|
1060 | }
|
1061 |
|
1062 |
|
1063 | hnode_t* value_t::PrettyTree(Dict<int, bool>* seen) {
|
1064 | switch (this->tag()) {
|
1065 | case value_e::Undef: {
|
1066 | value__Undef* obj = static_cast<value__Undef*>(this);
|
1067 | return obj->PrettyTree(seen);
|
1068 | }
|
1069 | case value_e::Str: {
|
1070 | value__Str* obj = static_cast<value__Str*>(this);
|
1071 | return obj->PrettyTree(seen);
|
1072 | }
|
1073 | case value_e::BashArray: {
|
1074 | value__BashArray* obj = static_cast<value__BashArray*>(this);
|
1075 | return obj->PrettyTree(seen);
|
1076 | }
|
1077 | case value_e::BashAssoc: {
|
1078 | value__BashAssoc* obj = static_cast<value__BashAssoc*>(this);
|
1079 | return obj->PrettyTree(seen);
|
1080 | }
|
1081 | case value_e::Null: {
|
1082 | value__Null* obj = static_cast<value__Null*>(this);
|
1083 | return obj->PrettyTree(seen);
|
1084 | }
|
1085 | case value_e::Bool: {
|
1086 | value__Bool* obj = static_cast<value__Bool*>(this);
|
1087 | return obj->PrettyTree(seen);
|
1088 | }
|
1089 | case value_e::Int: {
|
1090 | value__Int* obj = static_cast<value__Int*>(this);
|
1091 | return obj->PrettyTree(seen);
|
1092 | }
|
1093 | case value_e::Float: {
|
1094 | value__Float* obj = static_cast<value__Float*>(this);
|
1095 | return obj->PrettyTree(seen);
|
1096 | }
|
1097 | case value_e::List: {
|
1098 | value__List* obj = static_cast<value__List*>(this);
|
1099 | return obj->PrettyTree(seen);
|
1100 | }
|
1101 | case value_e::Dict: {
|
1102 | value__Dict* obj = static_cast<value__Dict*>(this);
|
1103 | return obj->PrettyTree(seen);
|
1104 | }
|
1105 | case value_e::Eggex: {
|
1106 | value__Eggex* obj = static_cast<value__Eggex*>(this);
|
1107 | return obj->PrettyTree(seen);
|
1108 | }
|
1109 | case value_e::Match: {
|
1110 | RegexMatch* obj = static_cast<RegexMatch*>(this);
|
1111 | return obj->PrettyTree(seen);
|
1112 | }
|
1113 | case value_e::Expr: {
|
1114 | value__Expr* obj = static_cast<value__Expr*>(this);
|
1115 | return obj->PrettyTree(seen);
|
1116 | }
|
1117 | case value_e::Command: {
|
1118 | value__Command* obj = static_cast<value__Command*>(this);
|
1119 | return obj->PrettyTree(seen);
|
1120 | }
|
1121 | case value_e::Block: {
|
1122 | value__Block* obj = static_cast<value__Block*>(this);
|
1123 | return obj->PrettyTree(seen);
|
1124 | }
|
1125 | case value_e::Place: {
|
1126 | value__Place* obj = static_cast<value__Place*>(this);
|
1127 | return obj->PrettyTree(seen);
|
1128 | }
|
1129 | case value_e::Module: {
|
1130 | value__Module* obj = static_cast<value__Module*>(this);
|
1131 | return obj->PrettyTree(seen);
|
1132 | }
|
1133 | case value_e::IO: {
|
1134 | value__IO* obj = static_cast<value__IO*>(this);
|
1135 | return obj->PrettyTree(seen);
|
1136 | }
|
1137 | case value_e::Guts: {
|
1138 | value__Guts* obj = static_cast<value__Guts*>(this);
|
1139 | return obj->PrettyTree(seen);
|
1140 | }
|
1141 | case value_e::BuiltinFunc: {
|
1142 | value__BuiltinFunc* obj = static_cast<value__BuiltinFunc*>(this);
|
1143 | return obj->PrettyTree(seen);
|
1144 | }
|
1145 | case value_e::BoundFunc: {
|
1146 | value__BoundFunc* obj = static_cast<value__BoundFunc*>(this);
|
1147 | return obj->PrettyTree(seen);
|
1148 | }
|
1149 | case value_e::Proc: {
|
1150 | value__Proc* obj = static_cast<value__Proc*>(this);
|
1151 | return obj->PrettyTree(seen);
|
1152 | }
|
1153 | case value_e::Func: {
|
1154 | value__Func* obj = static_cast<value__Func*>(this);
|
1155 | return obj->PrettyTree(seen);
|
1156 | }
|
1157 | case value_e::Slice: {
|
1158 | value__Slice* obj = static_cast<value__Slice*>(this);
|
1159 | return obj->PrettyTree(seen);
|
1160 | }
|
1161 | case value_e::Range: {
|
1162 | value__Range* obj = static_cast<value__Range*>(this);
|
1163 | return obj->PrettyTree(seen);
|
1164 | }
|
1165 | default:
|
1166 | assert(0);
|
1167 | }
|
1168 | }
|
1169 |
|
1170 | } // namespace value_asdl
|