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