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