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::Interrupted:
|
426 | v = "Interrupted"; break;
|
427 | case value_e::Undef:
|
428 | v = "Undef"; break;
|
429 | case value_e::Str:
|
430 | v = "Str"; break;
|
431 | case value_e::BashArray:
|
432 | v = "BashArray"; break;
|
433 | case value_e::SparseArray:
|
434 | v = "SparseArray"; break;
|
435 | case value_e::BashAssoc:
|
436 | v = "BashAssoc"; break;
|
437 | case value_e::Null:
|
438 | v = "Null"; break;
|
439 | case value_e::Bool:
|
440 | v = "Bool"; break;
|
441 | case value_e::Int:
|
442 | v = "Int"; break;
|
443 | case value_e::Float:
|
444 | v = "Float"; break;
|
445 | case value_e::List:
|
446 | v = "List"; break;
|
447 | case value_e::Dict:
|
448 | v = "Dict"; break;
|
449 | case value_e::Eggex:
|
450 | v = "Eggex"; break;
|
451 | case value_e::Match:
|
452 | v = "Match"; break;
|
453 | case value_e::Expr:
|
454 | v = "Expr"; break;
|
455 | case value_e::Command:
|
456 | v = "Command"; break;
|
457 | case value_e::Block:
|
458 | v = "Block"; break;
|
459 | case value_e::Place:
|
460 | v = "Place"; break;
|
461 | case value_e::Module:
|
462 | v = "Module"; break;
|
463 | case value_e::IO:
|
464 | v = "IO"; break;
|
465 | case value_e::Guts:
|
466 | v = "Guts"; break;
|
467 | case value_e::BuiltinFunc:
|
468 | v = "BuiltinFunc"; break;
|
469 | case value_e::BoundFunc:
|
470 | v = "BoundFunc"; break;
|
471 | case value_e::Proc:
|
472 | v = "Proc"; break;
|
473 | case value_e::Func:
|
474 | v = "Func"; break;
|
475 | case value_e::Slice:
|
476 | v = "Slice"; break;
|
477 | case value_e::Range:
|
478 | v = "Range"; break;
|
479 | default:
|
480 | assert(0);
|
481 | }
|
482 | if (dot) {
|
483 | snprintf(buf, 32, "value.%s", v);
|
484 | return StrFromC(buf);
|
485 | } else {
|
486 | return StrFromC(v);
|
487 | }
|
488 | }
|
489 |
|
490 | value__Interrupted* value::Interrupted = &gvalue__Interrupted.obj;
|
491 |
|
492 | GcGlobal<value__Interrupted> gvalue__Interrupted =
|
493 | { ObjHeader::Global(value_e::Interrupted) };
|
494 |
|
495 | value__Undef* value::Undef = &gvalue__Undef.obj;
|
496 |
|
497 | GcGlobal<value__Undef> gvalue__Undef =
|
498 | { ObjHeader::Global(value_e::Undef) };
|
499 |
|
500 | value__Null* value::Null = &gvalue__Null.obj;
|
501 |
|
502 | GcGlobal<value__Null> gvalue__Null =
|
503 | { ObjHeader::Global(value_e::Null) };
|
504 |
|
505 | hnode_t* value__Interrupted::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 | return out_node;
|
514 | }
|
515 |
|
516 |
|
517 | hnode_t* value__Undef::PrettyTree(Dict<int, bool>* seen) {
|
518 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
519 | int heap_id = ObjectId(this);
|
520 | if (dict_contains(seen, heap_id)) {
|
521 | return Alloc<hnode::AlreadySeen>(heap_id);
|
522 | }
|
523 | seen->set(heap_id, true);
|
524 | hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
|
525 | return out_node;
|
526 | }
|
527 |
|
528 |
|
529 | hnode_t* value__Str::PrettyTree(Dict<int, bool>* seen) {
|
530 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
531 | int heap_id = ObjectId(this);
|
532 | if (dict_contains(seen, heap_id)) {
|
533 | return Alloc<hnode::AlreadySeen>(heap_id);
|
534 | }
|
535 | seen->set(heap_id, true);
|
536 | hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
|
537 | List<Field*>* L = out_node->fields;
|
538 |
|
539 | hnode_t* x0 = runtime::NewLeaf(this->s, color_e::StringConst);
|
540 | L->append(Alloc<Field>(StrFromC("s"), x0));
|
541 |
|
542 | return out_node;
|
543 | }
|
544 |
|
545 |
|
546 | hnode_t* value__BashArray::PrettyTree(Dict<int, bool>* seen) {
|
547 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
548 | int heap_id = ObjectId(this);
|
549 | if (dict_contains(seen, heap_id)) {
|
550 | return Alloc<hnode::AlreadySeen>(heap_id);
|
551 | }
|
552 | seen->set(heap_id, true);
|
553 | hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
|
554 | List<Field*>* L = out_node->fields;
|
555 |
|
556 | if (this->strs != nullptr) { // List
|
557 | hnode::Array* x0 = Alloc<hnode::Array>(Alloc<List<hnode_t*>>());
|
558 | for (ListIter<BigStr*> it(this->strs); !it.Done(); it.Next()) {
|
559 | BigStr* i0 = it.Value();
|
560 | x0->children->append(runtime::NewLeaf(i0, color_e::StringConst));
|
561 | }
|
562 | L->append(Alloc<Field>(StrFromC("strs"), x0));
|
563 | }
|
564 |
|
565 | return out_node;
|
566 | }
|
567 |
|
568 |
|
569 | hnode_t* value__SparseArray::PrettyTree(Dict<int, bool>* seen) {
|
570 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
571 | int heap_id = ObjectId(this);
|
572 | if (dict_contains(seen, heap_id)) {
|
573 | return Alloc<hnode::AlreadySeen>(heap_id);
|
574 | }
|
575 | seen->set(heap_id, true);
|
576 | hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
|
577 | List<Field*>* L = out_node->fields;
|
578 |
|
579 | if (this->d) { // Dict
|
580 | auto m = Alloc<hnode::Leaf>(StrFromC("Dict"), color_e::OtherConst);
|
581 | hnode::Array* x0 = Alloc<hnode::Array>(NewList<hnode_t*>({m}));
|
582 | for (DictIter<mops::BigInt, BigStr*> it(this->d); !it.Done(); it.Next()) {
|
583 | auto k0 = it.Key();
|
584 | auto v0 = it.Value();
|
585 | x0->children->append(Alloc<hnode::Leaf>(mops::ToStr(k0),
|
586 | color_e::OtherConst));
|
587 | x0->children->append(runtime::NewLeaf(v0, color_e::StringConst));
|
588 | }
|
589 | L->append(Alloc<Field>(StrFromC ("d"), x0));
|
590 | }
|
591 |
|
592 | hnode_t* x1 = Alloc<hnode::Leaf>(mops::ToStr(this->max_index),
|
593 | color_e::OtherConst);
|
594 | L->append(Alloc<Field>(StrFromC("max_index"), x1));
|
595 |
|
596 | return out_node;
|
597 | }
|
598 |
|
599 |
|
600 | hnode_t* value__BashAssoc::PrettyTree(Dict<int, bool>* seen) {
|
601 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
602 | int heap_id = ObjectId(this);
|
603 | if (dict_contains(seen, heap_id)) {
|
604 | return Alloc<hnode::AlreadySeen>(heap_id);
|
605 | }
|
606 | seen->set(heap_id, true);
|
607 | hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
|
608 | List<Field*>* L = out_node->fields;
|
609 |
|
610 | if (this->d) { // Dict
|
611 | auto m = Alloc<hnode::Leaf>(StrFromC("Dict"), color_e::OtherConst);
|
612 | hnode::Array* x0 = Alloc<hnode::Array>(NewList<hnode_t*>({m}));
|
613 | for (DictIter<BigStr*, BigStr*> it(this->d); !it.Done(); it.Next()) {
|
614 | auto k0 = it.Key();
|
615 | auto v0 = it.Value();
|
616 | x0->children->append(runtime::NewLeaf(k0, color_e::StringConst));
|
617 | x0->children->append(runtime::NewLeaf(v0, color_e::StringConst));
|
618 | }
|
619 | L->append(Alloc<Field>(StrFromC ("d"), x0));
|
620 | }
|
621 |
|
622 | return out_node;
|
623 | }
|
624 |
|
625 |
|
626 | hnode_t* value__Null::PrettyTree(Dict<int, bool>* seen) {
|
627 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
628 | int heap_id = ObjectId(this);
|
629 | if (dict_contains(seen, heap_id)) {
|
630 | return Alloc<hnode::AlreadySeen>(heap_id);
|
631 | }
|
632 | seen->set(heap_id, true);
|
633 | hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
|
634 | return out_node;
|
635 | }
|
636 |
|
637 |
|
638 | hnode_t* value__Bool::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 | hnode_t* x0 = Alloc<hnode::Leaf>(this->b ? runtime::TRUE_STR :
|
649 | runtime::FALSE_STR, color_e::OtherConst);
|
650 | L->append(Alloc<Field>(StrFromC("b"), x0));
|
651 |
|
652 | return out_node;
|
653 | }
|
654 |
|
655 |
|
656 | hnode_t* value__Int::PrettyTree(Dict<int, bool>* seen) {
|
657 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
658 | int heap_id = ObjectId(this);
|
659 | if (dict_contains(seen, heap_id)) {
|
660 | return Alloc<hnode::AlreadySeen>(heap_id);
|
661 | }
|
662 | seen->set(heap_id, true);
|
663 | hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
|
664 | List<Field*>* L = out_node->fields;
|
665 |
|
666 | hnode_t* x0 = Alloc<hnode::Leaf>(mops::ToStr(this->i), color_e::OtherConst);
|
667 | L->append(Alloc<Field>(StrFromC("i"), x0));
|
668 |
|
669 | return out_node;
|
670 | }
|
671 |
|
672 |
|
673 | hnode_t* value__Float::PrettyTree(Dict<int, bool>* seen) {
|
674 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
675 | int heap_id = ObjectId(this);
|
676 | if (dict_contains(seen, heap_id)) {
|
677 | return Alloc<hnode::AlreadySeen>(heap_id);
|
678 | }
|
679 | seen->set(heap_id, true);
|
680 | hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
|
681 | List<Field*>* L = out_node->fields;
|
682 |
|
683 | hnode_t* x0 = Alloc<hnode::Leaf>(str(this->f), color_e::OtherConst);
|
684 | L->append(Alloc<Field>(StrFromC("f"), x0));
|
685 |
|
686 | return out_node;
|
687 | }
|
688 |
|
689 |
|
690 | hnode_t* value__List::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(value_str(this->tag()));
|
698 | List<Field*>* L = out_node->fields;
|
699 |
|
700 | if (this->items != nullptr) { // List
|
701 | hnode::Array* x0 = Alloc<hnode::Array>(Alloc<List<hnode_t*>>());
|
702 | for (ListIter<value_t*> it(this->items); !it.Done(); it.Next()) {
|
703 | value_t* i0 = it.Value();
|
704 | hnode_t* h = (i0 == nullptr) ? Alloc<hnode::Leaf>(StrFromC("_"),
|
705 | color_e::OtherConst) : i0->PrettyTree(seen);
|
706 | x0->children->append(h);
|
707 | }
|
708 | L->append(Alloc<Field>(StrFromC("items"), x0));
|
709 | }
|
710 |
|
711 | return out_node;
|
712 | }
|
713 |
|
714 |
|
715 | hnode_t* value__Dict::PrettyTree(Dict<int, bool>* seen) {
|
716 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
717 | int heap_id = ObjectId(this);
|
718 | if (dict_contains(seen, heap_id)) {
|
719 | return Alloc<hnode::AlreadySeen>(heap_id);
|
720 | }
|
721 | seen->set(heap_id, true);
|
722 | hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
|
723 | List<Field*>* L = out_node->fields;
|
724 |
|
725 | if (this->d) { // Dict
|
726 | auto m = Alloc<hnode::Leaf>(StrFromC("Dict"), color_e::OtherConst);
|
727 | hnode::Array* x0 = Alloc<hnode::Array>(NewList<hnode_t*>({m}));
|
728 | for (DictIter<BigStr*, value_t*> it(this->d); !it.Done(); it.Next()) {
|
729 | auto k0 = it.Key();
|
730 | auto v0 = it.Value();
|
731 | x0->children->append(runtime::NewLeaf(k0, color_e::StringConst));
|
732 | x0->children->append(v0->PrettyTree(seen));
|
733 | }
|
734 | L->append(Alloc<Field>(StrFromC ("d"), x0));
|
735 | }
|
736 |
|
737 | return out_node;
|
738 | }
|
739 |
|
740 |
|
741 | hnode_t* value__Eggex::PrettyTree(Dict<int, bool>* seen) {
|
742 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
743 | int heap_id = ObjectId(this);
|
744 | if (dict_contains(seen, heap_id)) {
|
745 | return Alloc<hnode::AlreadySeen>(heap_id);
|
746 | }
|
747 | seen->set(heap_id, true);
|
748 | hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
|
749 | List<Field*>* L = out_node->fields;
|
750 |
|
751 | hnode_t* x0 = this->spliced->PrettyTree(seen);
|
752 | L->append(Alloc<Field>(StrFromC("spliced"), x0));
|
753 |
|
754 | hnode_t* x1 = runtime::NewLeaf(this->canonical_flags, color_e::StringConst);
|
755 | L->append(Alloc<Field>(StrFromC("canonical_flags"), x1));
|
756 |
|
757 | if (this->convert_funcs != nullptr) { // List
|
758 | hnode::Array* x2 = Alloc<hnode::Array>(Alloc<List<hnode_t*>>());
|
759 | for (ListIter<value_t*> it(this->convert_funcs); !it.Done(); it.Next()) {
|
760 | value_t* i2 = it.Value();
|
761 | hnode_t* h = (i2 == nullptr) ? Alloc<hnode::Leaf>(StrFromC("_"),
|
762 | color_e::OtherConst) : i2->PrettyTree(seen);
|
763 | x2->children->append(h);
|
764 | }
|
765 | L->append(Alloc<Field>(StrFromC("convert_funcs"), x2));
|
766 | }
|
767 |
|
768 | if (this->convert_toks != nullptr) { // List
|
769 | hnode::Array* x3 = Alloc<hnode::Array>(Alloc<List<hnode_t*>>());
|
770 | for (ListIter<syntax_asdl::Token*> it(this->convert_toks); !it.Done();
|
771 | it.Next()) {
|
772 | syntax_asdl::Token* i3 = it.Value();
|
773 | hnode_t* h = (i3 == nullptr) ? Alloc<hnode::Leaf>(StrFromC("_"),
|
774 | color_e::OtherConst) : i3->PrettyTree(seen);
|
775 | x3->children->append(h);
|
776 | }
|
777 | L->append(Alloc<Field>(StrFromC("convert_toks"), x3));
|
778 | }
|
779 |
|
780 | if (this->as_ere) { // Optional
|
781 | hnode_t* x4 = runtime::NewLeaf(this->as_ere, color_e::StringConst);
|
782 | L->append(Alloc<Field>(StrFromC("as_ere"), x4));
|
783 | }
|
784 |
|
785 | if (this->capture_names != nullptr) { // List
|
786 | hnode::Array* x5 = Alloc<hnode::Array>(Alloc<List<hnode_t*>>());
|
787 | for (ListIter<BigStr*> it(this->capture_names); !it.Done(); it.Next()) {
|
788 | BigStr* i5 = it.Value();
|
789 | x5->children->append(runtime::NewLeaf(i5, color_e::StringConst));
|
790 | }
|
791 | L->append(Alloc<Field>(StrFromC("capture_names"), x5));
|
792 | }
|
793 |
|
794 | return out_node;
|
795 | }
|
796 |
|
797 |
|
798 | hnode_t* value__Expr::PrettyTree(Dict<int, bool>* seen) {
|
799 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
800 | int heap_id = ObjectId(this);
|
801 | if (dict_contains(seen, heap_id)) {
|
802 | return Alloc<hnode::AlreadySeen>(heap_id);
|
803 | }
|
804 | seen->set(heap_id, true);
|
805 | hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
|
806 | List<Field*>* L = out_node->fields;
|
807 |
|
808 | hnode_t* x0 = this->e->PrettyTree(seen);
|
809 | L->append(Alloc<Field>(StrFromC("e"), x0));
|
810 |
|
811 | return out_node;
|
812 | }
|
813 |
|
814 |
|
815 | hnode_t* value__Command::PrettyTree(Dict<int, bool>* seen) {
|
816 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
817 | int heap_id = ObjectId(this);
|
818 | if (dict_contains(seen, heap_id)) {
|
819 | return Alloc<hnode::AlreadySeen>(heap_id);
|
820 | }
|
821 | seen->set(heap_id, true);
|
822 | hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
|
823 | List<Field*>* L = out_node->fields;
|
824 |
|
825 | hnode_t* x0 = this->c->PrettyTree(seen);
|
826 | L->append(Alloc<Field>(StrFromC("c"), x0));
|
827 |
|
828 | return out_node;
|
829 | }
|
830 |
|
831 |
|
832 | hnode_t* value__Block::PrettyTree(Dict<int, bool>* seen) {
|
833 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
834 | int heap_id = ObjectId(this);
|
835 | if (dict_contains(seen, heap_id)) {
|
836 | return Alloc<hnode::AlreadySeen>(heap_id);
|
837 | }
|
838 | seen->set(heap_id, true);
|
839 | hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
|
840 | List<Field*>* L = out_node->fields;
|
841 |
|
842 | hnode_t* x0 = this->block->PrettyTree(seen);
|
843 | L->append(Alloc<Field>(StrFromC("block"), x0));
|
844 |
|
845 | return out_node;
|
846 | }
|
847 |
|
848 |
|
849 | hnode_t* value__Place::PrettyTree(Dict<int, bool>* seen) {
|
850 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
851 | int heap_id = ObjectId(this);
|
852 | if (dict_contains(seen, heap_id)) {
|
853 | return Alloc<hnode::AlreadySeen>(heap_id);
|
854 | }
|
855 | seen->set(heap_id, true);
|
856 | hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
|
857 | List<Field*>* L = out_node->fields;
|
858 |
|
859 | hnode_t* x0 = this->lval->PrettyTree(seen);
|
860 | L->append(Alloc<Field>(StrFromC("lval"), x0));
|
861 |
|
862 | if (this->frame) { // Dict
|
863 | auto m = Alloc<hnode::Leaf>(StrFromC("Dict"), color_e::OtherConst);
|
864 | hnode::Array* x1 = Alloc<hnode::Array>(NewList<hnode_t*>({m}));
|
865 | for (DictIter<BigStr*, runtime_asdl::Cell*> it(this->frame); !it.Done();
|
866 | it.Next()) {
|
867 | auto k1 = it.Key();
|
868 | auto v1 = it.Value();
|
869 | x1->children->append(runtime::NewLeaf(k1, color_e::StringConst));
|
870 | x1->children->append(v1->PrettyTree(seen));
|
871 | }
|
872 | L->append(Alloc<Field>(StrFromC ("frame"), x1));
|
873 | }
|
874 |
|
875 | return out_node;
|
876 | }
|
877 |
|
878 |
|
879 | hnode_t* value__Module::PrettyTree(Dict<int, bool>* seen) {
|
880 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
881 | int heap_id = ObjectId(this);
|
882 | if (dict_contains(seen, heap_id)) {
|
883 | return Alloc<hnode::AlreadySeen>(heap_id);
|
884 | }
|
885 | seen->set(heap_id, true);
|
886 | hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
|
887 | List<Field*>* L = out_node->fields;
|
888 |
|
889 | if (this->defs) { // Dict
|
890 | auto m = Alloc<hnode::Leaf>(StrFromC("Dict"), color_e::OtherConst);
|
891 | hnode::Array* x0 = Alloc<hnode::Array>(NewList<hnode_t*>({m}));
|
892 | for (DictIter<BigStr*, value_t*> it(this->defs); !it.Done(); it.Next()) {
|
893 | auto k0 = it.Key();
|
894 | auto v0 = it.Value();
|
895 | x0->children->append(runtime::NewLeaf(k0, color_e::StringConst));
|
896 | x0->children->append(v0->PrettyTree(seen));
|
897 | }
|
898 | L->append(Alloc<Field>(StrFromC ("defs"), x0));
|
899 | }
|
900 |
|
901 | return out_node;
|
902 | }
|
903 |
|
904 |
|
905 | hnode_t* value__IO::PrettyTree(Dict<int, bool>* seen) {
|
906 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
907 | int heap_id = ObjectId(this);
|
908 | if (dict_contains(seen, heap_id)) {
|
909 | return Alloc<hnode::AlreadySeen>(heap_id);
|
910 | }
|
911 | seen->set(heap_id, true);
|
912 | hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
|
913 | List<Field*>* L = out_node->fields;
|
914 |
|
915 | hnode_t* x0 = Alloc<hnode::External>(this->cmd_ev);
|
916 | L->append(Alloc<Field>(StrFromC("cmd_ev"), x0));
|
917 |
|
918 | hnode_t* x1 = Alloc<hnode::External>(this->prompt_ev);
|
919 | L->append(Alloc<Field>(StrFromC("prompt_ev"), x1));
|
920 |
|
921 | return out_node;
|
922 | }
|
923 |
|
924 |
|
925 | hnode_t* value__Guts::PrettyTree(Dict<int, bool>* seen) {
|
926 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
927 | int heap_id = ObjectId(this);
|
928 | if (dict_contains(seen, heap_id)) {
|
929 | return Alloc<hnode::AlreadySeen>(heap_id);
|
930 | }
|
931 | seen->set(heap_id, true);
|
932 | hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
|
933 | List<Field*>* L = out_node->fields;
|
934 |
|
935 | hnode_t* x0 = Alloc<hnode::External>(this->vm);
|
936 | L->append(Alloc<Field>(StrFromC("vm"), x0));
|
937 |
|
938 | return out_node;
|
939 | }
|
940 |
|
941 |
|
942 | hnode_t* value__BuiltinFunc::PrettyTree(Dict<int, bool>* seen) {
|
943 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
944 | int heap_id = ObjectId(this);
|
945 | if (dict_contains(seen, heap_id)) {
|
946 | return Alloc<hnode::AlreadySeen>(heap_id);
|
947 | }
|
948 | seen->set(heap_id, true);
|
949 | hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
|
950 | List<Field*>* L = out_node->fields;
|
951 |
|
952 | hnode_t* x0 = Alloc<hnode::External>(this->callable);
|
953 | L->append(Alloc<Field>(StrFromC("callable"), x0));
|
954 |
|
955 | return out_node;
|
956 | }
|
957 |
|
958 |
|
959 | hnode_t* value__BoundFunc::PrettyTree(Dict<int, bool>* seen) {
|
960 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
961 | int heap_id = ObjectId(this);
|
962 | if (dict_contains(seen, heap_id)) {
|
963 | return Alloc<hnode::AlreadySeen>(heap_id);
|
964 | }
|
965 | seen->set(heap_id, true);
|
966 | hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
|
967 | List<Field*>* L = out_node->fields;
|
968 |
|
969 | hnode_t* x0 = this->me->PrettyTree(seen);
|
970 | L->append(Alloc<Field>(StrFromC("me"), x0));
|
971 |
|
972 | hnode_t* x1 = this->func->PrettyTree(seen);
|
973 | L->append(Alloc<Field>(StrFromC("func"), x1));
|
974 |
|
975 | return out_node;
|
976 | }
|
977 |
|
978 |
|
979 | hnode_t* value__Proc::PrettyTree(Dict<int, bool>* seen) {
|
980 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
981 | int heap_id = ObjectId(this);
|
982 | if (dict_contains(seen, heap_id)) {
|
983 | return Alloc<hnode::AlreadySeen>(heap_id);
|
984 | }
|
985 | seen->set(heap_id, true);
|
986 | hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
|
987 | List<Field*>* L = out_node->fields;
|
988 |
|
989 | hnode_t* x0 = runtime::NewLeaf(this->name, color_e::StringConst);
|
990 | L->append(Alloc<Field>(StrFromC("name"), x0));
|
991 |
|
992 | hnode_t* x1 = this->name_tok->PrettyTree(seen);
|
993 | L->append(Alloc<Field>(StrFromC("name_tok"), x1));
|
994 |
|
995 | hnode_t* x2 = this->sig->PrettyTree(seen);
|
996 | L->append(Alloc<Field>(StrFromC("sig"), x2));
|
997 |
|
998 | hnode_t* x3 = this->body->PrettyTree(seen);
|
999 | L->append(Alloc<Field>(StrFromC("body"), x3));
|
1000 |
|
1001 | if (this->defaults) { // Optional
|
1002 | hnode_t* x4 = this->defaults->PrettyTree(seen);
|
1003 | L->append(Alloc<Field>(StrFromC("defaults"), x4));
|
1004 | }
|
1005 |
|
1006 | hnode_t* x5 = Alloc<hnode::Leaf>(this->sh_compat ? runtime::TRUE_STR :
|
1007 | runtime::FALSE_STR, color_e::OtherConst);
|
1008 | L->append(Alloc<Field>(StrFromC("sh_compat"), x5));
|
1009 |
|
1010 | return out_node;
|
1011 | }
|
1012 |
|
1013 |
|
1014 | hnode_t* value__Func::PrettyTree(Dict<int, bool>* seen) {
|
1015 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
1016 | int heap_id = ObjectId(this);
|
1017 | if (dict_contains(seen, heap_id)) {
|
1018 | return Alloc<hnode::AlreadySeen>(heap_id);
|
1019 | }
|
1020 | seen->set(heap_id, true);
|
1021 | hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
|
1022 | List<Field*>* L = out_node->fields;
|
1023 |
|
1024 | hnode_t* x0 = runtime::NewLeaf(this->name, color_e::StringConst);
|
1025 | L->append(Alloc<Field>(StrFromC("name"), x0));
|
1026 |
|
1027 | hnode_t* x1 = this->parsed->PrettyTree(seen);
|
1028 | L->append(Alloc<Field>(StrFromC("parsed"), x1));
|
1029 |
|
1030 | if (this->pos_defaults != nullptr) { // List
|
1031 | hnode::Array* x2 = Alloc<hnode::Array>(Alloc<List<hnode_t*>>());
|
1032 | for (ListIter<value_t*> it(this->pos_defaults); !it.Done(); it.Next()) {
|
1033 | value_t* i2 = it.Value();
|
1034 | hnode_t* h = (i2 == nullptr) ? Alloc<hnode::Leaf>(StrFromC("_"),
|
1035 | color_e::OtherConst) : i2->PrettyTree(seen);
|
1036 | x2->children->append(h);
|
1037 | }
|
1038 | L->append(Alloc<Field>(StrFromC("pos_defaults"), x2));
|
1039 | }
|
1040 |
|
1041 | if (this->named_defaults) { // Dict
|
1042 | auto m = Alloc<hnode::Leaf>(StrFromC("Dict"), color_e::OtherConst);
|
1043 | hnode::Array* x3 = Alloc<hnode::Array>(NewList<hnode_t*>({m}));
|
1044 | for (DictIter<BigStr*, value_t*> it(this->named_defaults); !it.Done();
|
1045 | it.Next()) {
|
1046 | auto k3 = it.Key();
|
1047 | auto v3 = it.Value();
|
1048 | x3->children->append(runtime::NewLeaf(k3, color_e::StringConst));
|
1049 | x3->children->append(v3->PrettyTree(seen));
|
1050 | }
|
1051 | L->append(Alloc<Field>(StrFromC ("named_defaults"), x3));
|
1052 | }
|
1053 |
|
1054 | if (this->module_) { // Dict
|
1055 | auto m = Alloc<hnode::Leaf>(StrFromC("Dict"), color_e::OtherConst);
|
1056 | hnode::Array* x4 = Alloc<hnode::Array>(NewList<hnode_t*>({m}));
|
1057 | for (DictIter<BigStr*, runtime_asdl::Cell*> it(this->module_); !it.Done();
|
1058 | it.Next()) {
|
1059 | auto k4 = it.Key();
|
1060 | auto v4 = it.Value();
|
1061 | x4->children->append(runtime::NewLeaf(k4, color_e::StringConst));
|
1062 | x4->children->append(v4->PrettyTree(seen));
|
1063 | }
|
1064 | L->append(Alloc<Field>(StrFromC ("module_"), x4));
|
1065 | }
|
1066 |
|
1067 | return out_node;
|
1068 | }
|
1069 |
|
1070 |
|
1071 | hnode_t* value__Slice::PrettyTree(Dict<int, bool>* seen) {
|
1072 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
1073 | int heap_id = ObjectId(this);
|
1074 | if (dict_contains(seen, heap_id)) {
|
1075 | return Alloc<hnode::AlreadySeen>(heap_id);
|
1076 | }
|
1077 | seen->set(heap_id, true);
|
1078 | hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
|
1079 | List<Field*>* L = out_node->fields;
|
1080 |
|
1081 | if (this->lower) { // Optional
|
1082 | hnode_t* x0 = this->lower->PrettyTree(seen);
|
1083 | L->append(Alloc<Field>(StrFromC("lower"), x0));
|
1084 | }
|
1085 |
|
1086 | if (this->upper) { // Optional
|
1087 | hnode_t* x1 = this->upper->PrettyTree(seen);
|
1088 | L->append(Alloc<Field>(StrFromC("upper"), x1));
|
1089 | }
|
1090 |
|
1091 | return out_node;
|
1092 | }
|
1093 |
|
1094 |
|
1095 | hnode_t* value__Range::PrettyTree(Dict<int, bool>* seen) {
|
1096 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
1097 | int heap_id = ObjectId(this);
|
1098 | if (dict_contains(seen, heap_id)) {
|
1099 | return Alloc<hnode::AlreadySeen>(heap_id);
|
1100 | }
|
1101 | seen->set(heap_id, true);
|
1102 | hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
|
1103 | List<Field*>* L = out_node->fields;
|
1104 |
|
1105 | hnode_t* x0 = Alloc<hnode::Leaf>(str(this->lower), color_e::OtherConst);
|
1106 | L->append(Alloc<Field>(StrFromC("lower"), x0));
|
1107 |
|
1108 | hnode_t* x1 = Alloc<hnode::Leaf>(str(this->upper), color_e::OtherConst);
|
1109 | L->append(Alloc<Field>(StrFromC("upper"), x1));
|
1110 |
|
1111 | return out_node;
|
1112 | }
|
1113 |
|
1114 |
|
1115 | hnode_t* value_t::PrettyTree(Dict<int, bool>* seen) {
|
1116 | switch (this->tag()) {
|
1117 | case value_e::Interrupted: {
|
1118 | value__Interrupted* obj = static_cast<value__Interrupted*>(this);
|
1119 | return obj->PrettyTree(seen);
|
1120 | }
|
1121 | case value_e::Undef: {
|
1122 | value__Undef* obj = static_cast<value__Undef*>(this);
|
1123 | return obj->PrettyTree(seen);
|
1124 | }
|
1125 | case value_e::Str: {
|
1126 | value__Str* obj = static_cast<value__Str*>(this);
|
1127 | return obj->PrettyTree(seen);
|
1128 | }
|
1129 | case value_e::BashArray: {
|
1130 | value__BashArray* obj = static_cast<value__BashArray*>(this);
|
1131 | return obj->PrettyTree(seen);
|
1132 | }
|
1133 | case value_e::SparseArray: {
|
1134 | value__SparseArray* obj = static_cast<value__SparseArray*>(this);
|
1135 | return obj->PrettyTree(seen);
|
1136 | }
|
1137 | case value_e::BashAssoc: {
|
1138 | value__BashAssoc* obj = static_cast<value__BashAssoc*>(this);
|
1139 | return obj->PrettyTree(seen);
|
1140 | }
|
1141 | case value_e::Null: {
|
1142 | value__Null* obj = static_cast<value__Null*>(this);
|
1143 | return obj->PrettyTree(seen);
|
1144 | }
|
1145 | case value_e::Bool: {
|
1146 | value__Bool* obj = static_cast<value__Bool*>(this);
|
1147 | return obj->PrettyTree(seen);
|
1148 | }
|
1149 | case value_e::Int: {
|
1150 | value__Int* obj = static_cast<value__Int*>(this);
|
1151 | return obj->PrettyTree(seen);
|
1152 | }
|
1153 | case value_e::Float: {
|
1154 | value__Float* obj = static_cast<value__Float*>(this);
|
1155 | return obj->PrettyTree(seen);
|
1156 | }
|
1157 | case value_e::List: {
|
1158 | value__List* obj = static_cast<value__List*>(this);
|
1159 | return obj->PrettyTree(seen);
|
1160 | }
|
1161 | case value_e::Dict: {
|
1162 | value__Dict* obj = static_cast<value__Dict*>(this);
|
1163 | return obj->PrettyTree(seen);
|
1164 | }
|
1165 | case value_e::Eggex: {
|
1166 | value__Eggex* obj = static_cast<value__Eggex*>(this);
|
1167 | return obj->PrettyTree(seen);
|
1168 | }
|
1169 | case value_e::Match: {
|
1170 | RegexMatch* obj = static_cast<RegexMatch*>(this);
|
1171 | return obj->PrettyTree(seen);
|
1172 | }
|
1173 | case value_e::Expr: {
|
1174 | value__Expr* obj = static_cast<value__Expr*>(this);
|
1175 | return obj->PrettyTree(seen);
|
1176 | }
|
1177 | case value_e::Command: {
|
1178 | value__Command* obj = static_cast<value__Command*>(this);
|
1179 | return obj->PrettyTree(seen);
|
1180 | }
|
1181 | case value_e::Block: {
|
1182 | value__Block* obj = static_cast<value__Block*>(this);
|
1183 | return obj->PrettyTree(seen);
|
1184 | }
|
1185 | case value_e::Place: {
|
1186 | value__Place* obj = static_cast<value__Place*>(this);
|
1187 | return obj->PrettyTree(seen);
|
1188 | }
|
1189 | case value_e::Module: {
|
1190 | value__Module* obj = static_cast<value__Module*>(this);
|
1191 | return obj->PrettyTree(seen);
|
1192 | }
|
1193 | case value_e::IO: {
|
1194 | value__IO* obj = static_cast<value__IO*>(this);
|
1195 | return obj->PrettyTree(seen);
|
1196 | }
|
1197 | case value_e::Guts: {
|
1198 | value__Guts* obj = static_cast<value__Guts*>(this);
|
1199 | return obj->PrettyTree(seen);
|
1200 | }
|
1201 | case value_e::BuiltinFunc: {
|
1202 | value__BuiltinFunc* obj = static_cast<value__BuiltinFunc*>(this);
|
1203 | return obj->PrettyTree(seen);
|
1204 | }
|
1205 | case value_e::BoundFunc: {
|
1206 | value__BoundFunc* obj = static_cast<value__BoundFunc*>(this);
|
1207 | return obj->PrettyTree(seen);
|
1208 | }
|
1209 | case value_e::Proc: {
|
1210 | value__Proc* obj = static_cast<value__Proc*>(this);
|
1211 | return obj->PrettyTree(seen);
|
1212 | }
|
1213 | case value_e::Func: {
|
1214 | value__Func* obj = static_cast<value__Func*>(this);
|
1215 | return obj->PrettyTree(seen);
|
1216 | }
|
1217 | case value_e::Slice: {
|
1218 | value__Slice* obj = static_cast<value__Slice*>(this);
|
1219 | return obj->PrettyTree(seen);
|
1220 | }
|
1221 | case value_e::Range: {
|
1222 | value__Range* obj = static_cast<value__Range*>(this);
|
1223 | return obj->PrettyTree(seen);
|
1224 | }
|
1225 | default:
|
1226 | assert(0);
|
1227 | }
|
1228 | }
|
1229 |
|
1230 | } // namespace value_asdl
|