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