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