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