| 1 | // _gen/core/value.asdl.cc is generated by asdl_main.py
|
| 2 |
|
| 3 | #include "_gen/core/value.asdl.h"
|
| 4 | #include <assert.h>
|
| 5 | #include "prebuilt/asdl/runtime.mycpp.h" // generated code uses wrappers here
|
| 6 | #include "_gen/frontend/syntax.asdl.h" // "use" in ASDL
|
| 7 | #include "_gen/core/runtime.asdl.h" // "use" in ASDL
|
| 8 |
|
| 9 | // Generated code uses these types
|
| 10 | using hnode_asdl::hnode;
|
| 11 | using hnode_asdl::Field;
|
| 12 | using hnode_asdl::color_e;
|
| 13 |
|
| 14 |
|
| 15 | namespace value_asdl {
|
| 16 |
|
| 17 |
|
| 18 | hnode_t* IntBox::PrettyTree(Dict<int, bool>* seen) {
|
| 19 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
| 20 | int heap_id = ObjectId(this);
|
| 21 | if (dict_contains(seen, heap_id)) {
|
| 22 | return Alloc<hnode::AlreadySeen>(heap_id);
|
| 23 | }
|
| 24 | seen->set(heap_id, true);
|
| 25 | hnode::Record* out_node = runtime::NewRecord(StrFromC("IntBox"));
|
| 26 | List<Field*>* L = out_node->fields;
|
| 27 |
|
| 28 | hnode_t* x0 = Alloc<hnode::Leaf>(str(this->i), color_e::OtherConst);
|
| 29 | L->append(Alloc<Field>(StrFromC("i"), x0));
|
| 30 |
|
| 31 | return out_node;
|
| 32 | }
|
| 33 |
|
| 34 |
|
| 35 | hnode_t* ProcDefaults::PrettyTree(Dict<int, bool>* seen) {
|
| 36 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
| 37 | int heap_id = ObjectId(this);
|
| 38 | if (dict_contains(seen, heap_id)) {
|
| 39 | return Alloc<hnode::AlreadySeen>(heap_id);
|
| 40 | }
|
| 41 | seen->set(heap_id, true);
|
| 42 | hnode::Record* out_node = runtime::NewRecord(StrFromC("ProcDefaults"));
|
| 43 | List<Field*>* L = out_node->fields;
|
| 44 |
|
| 45 | if (this->for_word != nullptr) { // List
|
| 46 | hnode::Array* x0 = Alloc<hnode::Array>(Alloc<List<hnode_t*>>());
|
| 47 | for (ListIter<value_t*> it(this->for_word); !it.Done(); it.Next()) {
|
| 48 | value_t* i0 = it.Value();
|
| 49 | hnode_t* h = (i0 == nullptr) ? Alloc<hnode::Leaf>(StrFromC("_"),
|
| 50 | color_e::OtherConst) : i0->PrettyTree(seen);
|
| 51 | x0->children->append(h);
|
| 52 | }
|
| 53 | L->append(Alloc<Field>(StrFromC("for_word"), x0));
|
| 54 | }
|
| 55 |
|
| 56 | if (this->for_typed != nullptr) { // List
|
| 57 | hnode::Array* x1 = Alloc<hnode::Array>(Alloc<List<hnode_t*>>());
|
| 58 | for (ListIter<value_t*> it(this->for_typed); !it.Done(); it.Next()) {
|
| 59 | value_t* i1 = it.Value();
|
| 60 | hnode_t* h = (i1 == nullptr) ? Alloc<hnode::Leaf>(StrFromC("_"),
|
| 61 | color_e::OtherConst) : i1->PrettyTree(seen);
|
| 62 | x1->children->append(h);
|
| 63 | }
|
| 64 | L->append(Alloc<Field>(StrFromC("for_typed"), x1));
|
| 65 | }
|
| 66 |
|
| 67 | if (this->for_named) { // Dict
|
| 68 | auto m = Alloc<hnode::Leaf>(StrFromC("Dict"), color_e::OtherConst);
|
| 69 | hnode::Array* x2 = Alloc<hnode::Array>(NewList<hnode_t*>({m}));
|
| 70 | for (DictIter<BigStr*, value_t*> it(this->for_named); !it.Done();
|
| 71 | it.Next()) {
|
| 72 | auto k2 = it.Key();
|
| 73 | auto v2 = it.Value();
|
| 74 | x2->children->append(runtime::NewLeaf(k2, color_e::StringConst));
|
| 75 | x2->children->append(v2->PrettyTree(seen));
|
| 76 | }
|
| 77 | L->append(Alloc<Field>(StrFromC ("for_named"), x2));
|
| 78 | }
|
| 79 |
|
| 80 | if (this->for_block) { // Optional
|
| 81 | hnode_t* x3 = this->for_block->PrettyTree(seen);
|
| 82 | L->append(Alloc<Field>(StrFromC("for_block"), x3));
|
| 83 | }
|
| 84 |
|
| 85 | return out_node;
|
| 86 | }
|
| 87 |
|
| 88 |
|
| 89 | hnode_t* LeftName::PrettyTree(Dict<int, bool>* seen) {
|
| 90 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
| 91 | int heap_id = ObjectId(this);
|
| 92 | if (dict_contains(seen, heap_id)) {
|
| 93 | return Alloc<hnode::AlreadySeen>(heap_id);
|
| 94 | }
|
| 95 | seen->set(heap_id, true);
|
| 96 | hnode::Record* out_node = runtime::NewRecord(StrFromC("LeftName"));
|
| 97 | List<Field*>* L = out_node->fields;
|
| 98 |
|
| 99 | hnode_t* x0 = runtime::NewLeaf(this->name, color_e::StringConst);
|
| 100 | L->append(Alloc<Field>(StrFromC("name"), x0));
|
| 101 |
|
| 102 | hnode_t* x1 = this->blame_loc->PrettyTree(seen);
|
| 103 | L->append(Alloc<Field>(StrFromC("blame_loc"), x1));
|
| 104 |
|
| 105 | return out_node;
|
| 106 | }
|
| 107 |
|
| 108 | BigStr* y_lvalue_str(int tag, bool dot) {
|
| 109 | char buf[32];
|
| 110 | const char* v = nullptr;
|
| 111 | switch (tag) {
|
| 112 | case y_lvalue_e::Local:
|
| 113 | v = "Local"; break;
|
| 114 | case y_lvalue_e::Container:
|
| 115 | v = "Container"; break;
|
| 116 | default:
|
| 117 | assert(0);
|
| 118 | }
|
| 119 | if (dot) {
|
| 120 | snprintf(buf, 32, "y_lvalue.%s", v);
|
| 121 | return StrFromC(buf);
|
| 122 | } else {
|
| 123 | return StrFromC(v);
|
| 124 | }
|
| 125 | }
|
| 126 |
|
| 127 | hnode_t* y_lvalue__Container::PrettyTree(Dict<int, bool>* seen) {
|
| 128 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
| 129 | int heap_id = ObjectId(this);
|
| 130 | if (dict_contains(seen, heap_id)) {
|
| 131 | return Alloc<hnode::AlreadySeen>(heap_id);
|
| 132 | }
|
| 133 | seen->set(heap_id, true);
|
| 134 | hnode::Record* out_node = runtime::NewRecord(y_lvalue_str(this->tag()));
|
| 135 | List<Field*>* L = out_node->fields;
|
| 136 |
|
| 137 | hnode_t* x0 = this->obj->PrettyTree(seen);
|
| 138 | L->append(Alloc<Field>(StrFromC("obj"), x0));
|
| 139 |
|
| 140 | hnode_t* x1 = this->index->PrettyTree(seen);
|
| 141 | L->append(Alloc<Field>(StrFromC("index"), x1));
|
| 142 |
|
| 143 | return out_node;
|
| 144 | }
|
| 145 |
|
| 146 |
|
| 147 | hnode_t* y_lvalue_t::PrettyTree(Dict<int, bool>* seen) {
|
| 148 | switch (this->tag()) {
|
| 149 | case y_lvalue_e::Local: {
|
| 150 | LeftName* obj = static_cast<LeftName*>(this);
|
| 151 | return obj->PrettyTree(seen);
|
| 152 | }
|
| 153 | case y_lvalue_e::Container: {
|
| 154 | y_lvalue__Container* obj = static_cast<y_lvalue__Container*>(this);
|
| 155 | return obj->PrettyTree(seen);
|
| 156 | }
|
| 157 | default:
|
| 158 | assert(0);
|
| 159 | }
|
| 160 | }
|
| 161 | BigStr* sh_lvalue_str(int tag, bool dot) {
|
| 162 | char buf[32];
|
| 163 | const char* v = nullptr;
|
| 164 | switch (tag) {
|
| 165 | case sh_lvalue_e::Var:
|
| 166 | v = "Var"; break;
|
| 167 | case sh_lvalue_e::Indexed:
|
| 168 | v = "Indexed"; break;
|
| 169 | case sh_lvalue_e::Keyed:
|
| 170 | v = "Keyed"; break;
|
| 171 | default:
|
| 172 | assert(0);
|
| 173 | }
|
| 174 | if (dot) {
|
| 175 | snprintf(buf, 32, "sh_lvalue.%s", v);
|
| 176 | return StrFromC(buf);
|
| 177 | } else {
|
| 178 | return StrFromC(v);
|
| 179 | }
|
| 180 | }
|
| 181 |
|
| 182 | hnode_t* sh_lvalue__Indexed::PrettyTree(Dict<int, bool>* seen) {
|
| 183 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
| 184 | int heap_id = ObjectId(this);
|
| 185 | if (dict_contains(seen, heap_id)) {
|
| 186 | return Alloc<hnode::AlreadySeen>(heap_id);
|
| 187 | }
|
| 188 | seen->set(heap_id, true);
|
| 189 | hnode::Record* out_node = runtime::NewRecord(sh_lvalue_str(this->tag()));
|
| 190 | List<Field*>* L = out_node->fields;
|
| 191 |
|
| 192 | hnode_t* x0 = runtime::NewLeaf(this->name, color_e::StringConst);
|
| 193 | L->append(Alloc<Field>(StrFromC("name"), x0));
|
| 194 |
|
| 195 | hnode_t* x1 = Alloc<hnode::Leaf>(str(this->index), color_e::OtherConst);
|
| 196 | L->append(Alloc<Field>(StrFromC("index"), x1));
|
| 197 |
|
| 198 | hnode_t* x2 = this->blame_loc->PrettyTree(seen);
|
| 199 | L->append(Alloc<Field>(StrFromC("blame_loc"), x2));
|
| 200 |
|
| 201 | return out_node;
|
| 202 | }
|
| 203 |
|
| 204 |
|
| 205 | hnode_t* sh_lvalue__Keyed::PrettyTree(Dict<int, bool>* seen) {
|
| 206 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
| 207 | int heap_id = ObjectId(this);
|
| 208 | if (dict_contains(seen, heap_id)) {
|
| 209 | return Alloc<hnode::AlreadySeen>(heap_id);
|
| 210 | }
|
| 211 | seen->set(heap_id, true);
|
| 212 | hnode::Record* out_node = runtime::NewRecord(sh_lvalue_str(this->tag()));
|
| 213 | List<Field*>* L = out_node->fields;
|
| 214 |
|
| 215 | hnode_t* x0 = runtime::NewLeaf(this->name, color_e::StringConst);
|
| 216 | L->append(Alloc<Field>(StrFromC("name"), x0));
|
| 217 |
|
| 218 | hnode_t* x1 = runtime::NewLeaf(this->key, color_e::StringConst);
|
| 219 | L->append(Alloc<Field>(StrFromC("key"), x1));
|
| 220 |
|
| 221 | hnode_t* x2 = this->blame_loc->PrettyTree(seen);
|
| 222 | L->append(Alloc<Field>(StrFromC("blame_loc"), x2));
|
| 223 |
|
| 224 | return out_node;
|
| 225 | }
|
| 226 |
|
| 227 |
|
| 228 | hnode_t* sh_lvalue_t::PrettyTree(Dict<int, bool>* seen) {
|
| 229 | switch (this->tag()) {
|
| 230 | case sh_lvalue_e::Var: {
|
| 231 | LeftName* obj = static_cast<LeftName*>(this);
|
| 232 | return obj->PrettyTree(seen);
|
| 233 | }
|
| 234 | case sh_lvalue_e::Indexed: {
|
| 235 | sh_lvalue__Indexed* obj = static_cast<sh_lvalue__Indexed*>(this);
|
| 236 | return obj->PrettyTree(seen);
|
| 237 | }
|
| 238 | case sh_lvalue_e::Keyed: {
|
| 239 | sh_lvalue__Keyed* obj = static_cast<sh_lvalue__Keyed*>(this);
|
| 240 | return obj->PrettyTree(seen);
|
| 241 | }
|
| 242 | default:
|
| 243 | assert(0);
|
| 244 | }
|
| 245 | }
|
| 246 | BigStr* eggex_ops_str(int tag, bool dot) {
|
| 247 | char buf[32];
|
| 248 | const char* v = nullptr;
|
| 249 | switch (tag) {
|
| 250 | case eggex_ops_e::No:
|
| 251 | v = "No"; break;
|
| 252 | case eggex_ops_e::Yes:
|
| 253 | v = "Yes"; break;
|
| 254 | default:
|
| 255 | assert(0);
|
| 256 | }
|
| 257 | if (dot) {
|
| 258 | snprintf(buf, 32, "eggex_ops.%s", v);
|
| 259 | return StrFromC(buf);
|
| 260 | } else {
|
| 261 | return StrFromC(v);
|
| 262 | }
|
| 263 | }
|
| 264 |
|
| 265 | eggex_ops__No* eggex_ops::No = &geggex_ops__No.obj;
|
| 266 |
|
| 267 | GcGlobal<eggex_ops__No> geggex_ops__No =
|
| 268 | { ObjHeader::Global(eggex_ops_e::No) };
|
| 269 |
|
| 270 | hnode_t* eggex_ops__No::PrettyTree(Dict<int, bool>* seen) {
|
| 271 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
| 272 | int heap_id = ObjectId(this);
|
| 273 | if (dict_contains(seen, heap_id)) {
|
| 274 | return Alloc<hnode::AlreadySeen>(heap_id);
|
| 275 | }
|
| 276 | seen->set(heap_id, true);
|
| 277 | hnode::Record* out_node = runtime::NewRecord(eggex_ops_str(this->tag()));
|
| 278 | return out_node;
|
| 279 | }
|
| 280 |
|
| 281 |
|
| 282 | hnode_t* eggex_ops__Yes::PrettyTree(Dict<int, bool>* seen) {
|
| 283 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
| 284 | int heap_id = ObjectId(this);
|
| 285 | if (dict_contains(seen, heap_id)) {
|
| 286 | return Alloc<hnode::AlreadySeen>(heap_id);
|
| 287 | }
|
| 288 | seen->set(heap_id, true);
|
| 289 | hnode::Record* out_node = runtime::NewRecord(eggex_ops_str(this->tag()));
|
| 290 | List<Field*>* L = out_node->fields;
|
| 291 |
|
| 292 | if (this->convert_funcs != nullptr) { // List
|
| 293 | hnode::Array* x0 = Alloc<hnode::Array>(Alloc<List<hnode_t*>>());
|
| 294 | for (ListIter<value_t*> it(this->convert_funcs); !it.Done(); it.Next()) {
|
| 295 | value_t* i0 = it.Value();
|
| 296 | hnode_t* h = (i0 == nullptr) ? Alloc<hnode::Leaf>(StrFromC("_"),
|
| 297 | color_e::OtherConst) : i0->PrettyTree(seen);
|
| 298 | x0->children->append(h);
|
| 299 | }
|
| 300 | L->append(Alloc<Field>(StrFromC("convert_funcs"), x0));
|
| 301 | }
|
| 302 |
|
| 303 | if (this->convert_toks != nullptr) { // List
|
| 304 | hnode::Array* x1 = Alloc<hnode::Array>(Alloc<List<hnode_t*>>());
|
| 305 | for (ListIter<syntax_asdl::Token*> it(this->convert_toks); !it.Done();
|
| 306 | it.Next()) {
|
| 307 | syntax_asdl::Token* i1 = it.Value();
|
| 308 | hnode_t* h = (i1 == nullptr) ? Alloc<hnode::Leaf>(StrFromC("_"),
|
| 309 | color_e::OtherConst) : i1->PrettyTree(seen);
|
| 310 | x1->children->append(h);
|
| 311 | }
|
| 312 | L->append(Alloc<Field>(StrFromC("convert_toks"), x1));
|
| 313 | }
|
| 314 |
|
| 315 | if (this->capture_names != nullptr) { // List
|
| 316 | hnode::Array* x2 = Alloc<hnode::Array>(Alloc<List<hnode_t*>>());
|
| 317 | for (ListIter<BigStr*> it(this->capture_names); !it.Done(); it.Next()) {
|
| 318 | BigStr* i2 = it.Value();
|
| 319 | x2->children->append(runtime::NewLeaf(i2, color_e::StringConst));
|
| 320 | }
|
| 321 | L->append(Alloc<Field>(StrFromC("capture_names"), x2));
|
| 322 | }
|
| 323 |
|
| 324 | return out_node;
|
| 325 | }
|
| 326 |
|
| 327 |
|
| 328 | hnode_t* eggex_ops_t::PrettyTree(Dict<int, bool>* seen) {
|
| 329 | switch (this->tag()) {
|
| 330 | case eggex_ops_e::No: {
|
| 331 | eggex_ops__No* obj = static_cast<eggex_ops__No*>(this);
|
| 332 | return obj->PrettyTree(seen);
|
| 333 | }
|
| 334 | case eggex_ops_e::Yes: {
|
| 335 | eggex_ops__Yes* obj = static_cast<eggex_ops__Yes*>(this);
|
| 336 | return obj->PrettyTree(seen);
|
| 337 | }
|
| 338 | default:
|
| 339 | assert(0);
|
| 340 | }
|
| 341 | }
|
| 342 |
|
| 343 | hnode_t* RegexMatch::PrettyTree(Dict<int, bool>* seen) {
|
| 344 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
| 345 | int heap_id = ObjectId(this);
|
| 346 | if (dict_contains(seen, heap_id)) {
|
| 347 | return Alloc<hnode::AlreadySeen>(heap_id);
|
| 348 | }
|
| 349 | seen->set(heap_id, true);
|
| 350 | hnode::Record* out_node = runtime::NewRecord(StrFromC("RegexMatch"));
|
| 351 | List<Field*>* L = out_node->fields;
|
| 352 |
|
| 353 | hnode_t* x0 = runtime::NewLeaf(this->s, color_e::StringConst);
|
| 354 | L->append(Alloc<Field>(StrFromC("s"), x0));
|
| 355 |
|
| 356 | if (this->indices != nullptr) { // List
|
| 357 | hnode::Array* x1 = Alloc<hnode::Array>(Alloc<List<hnode_t*>>());
|
| 358 | for (ListIter<int> it(this->indices); !it.Done(); it.Next()) {
|
| 359 | int i1 = it.Value();
|
| 360 | x1->children->append(Alloc<hnode::Leaf>(str(i1), color_e::OtherConst));
|
| 361 | }
|
| 362 | L->append(Alloc<Field>(StrFromC("indices"), x1));
|
| 363 | }
|
| 364 |
|
| 365 | hnode_t* x2 = this->ops->PrettyTree(seen);
|
| 366 | L->append(Alloc<Field>(StrFromC("ops"), x2));
|
| 367 |
|
| 368 | return out_node;
|
| 369 | }
|
| 370 |
|
| 371 | BigStr* regex_match_str(int tag, bool dot) {
|
| 372 | char buf[32];
|
| 373 | const char* v = nullptr;
|
| 374 | switch (tag) {
|
| 375 | case regex_match_e::No:
|
| 376 | v = "No"; break;
|
| 377 | case regex_match_e::Yes:
|
| 378 | v = "Yes"; break;
|
| 379 | default:
|
| 380 | assert(0);
|
| 381 | }
|
| 382 | if (dot) {
|
| 383 | snprintf(buf, 32, "regex_match.%s", v);
|
| 384 | return StrFromC(buf);
|
| 385 | } else {
|
| 386 | return StrFromC(v);
|
| 387 | }
|
| 388 | }
|
| 389 |
|
| 390 | regex_match__No* regex_match::No = &gregex_match__No.obj;
|
| 391 |
|
| 392 | GcGlobal<regex_match__No> gregex_match__No =
|
| 393 | { ObjHeader::Global(regex_match_e::No) };
|
| 394 |
|
| 395 | hnode_t* regex_match__No::PrettyTree(Dict<int, bool>* seen) {
|
| 396 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
| 397 | int heap_id = ObjectId(this);
|
| 398 | if (dict_contains(seen, heap_id)) {
|
| 399 | return Alloc<hnode::AlreadySeen>(heap_id);
|
| 400 | }
|
| 401 | seen->set(heap_id, true);
|
| 402 | hnode::Record* out_node = runtime::NewRecord(regex_match_str(this->tag()));
|
| 403 | return out_node;
|
| 404 | }
|
| 405 |
|
| 406 |
|
| 407 | hnode_t* regex_match_t::PrettyTree(Dict<int, bool>* seen) {
|
| 408 | switch (this->tag()) {
|
| 409 | case regex_match_e::No: {
|
| 410 | regex_match__No* obj = static_cast<regex_match__No*>(this);
|
| 411 | return obj->PrettyTree(seen);
|
| 412 | }
|
| 413 | case regex_match_e::Yes: {
|
| 414 | RegexMatch* obj = static_cast<RegexMatch*>(this);
|
| 415 | return obj->PrettyTree(seen);
|
| 416 | }
|
| 417 | default:
|
| 418 | assert(0);
|
| 419 | }
|
| 420 | }
|
| 421 | BigStr* value_str(int tag, bool dot) {
|
| 422 | char buf[32];
|
| 423 | const char* v = nullptr;
|
| 424 | switch (tag) {
|
| 425 | case value_e::Interrupted:
|
| 426 | v = "Interrupted"; break;
|
| 427 | case value_e::Stdin:
|
| 428 | v = "Stdin"; break;
|
| 429 | case value_e::Undef:
|
| 430 | v = "Undef"; break;
|
| 431 | case value_e::Str:
|
| 432 | v = "Str"; break;
|
| 433 | case value_e::BashArray:
|
| 434 | v = "BashArray"; break;
|
| 435 | case value_e::SparseArray:
|
| 436 | v = "SparseArray"; break;
|
| 437 | case value_e::BashAssoc:
|
| 438 | v = "BashAssoc"; break;
|
| 439 | case value_e::Null:
|
| 440 | v = "Null"; break;
|
| 441 | case value_e::Bool:
|
| 442 | v = "Bool"; break;
|
| 443 | case value_e::Int:
|
| 444 | v = "Int"; break;
|
| 445 | case value_e::Float:
|
| 446 | v = "Float"; break;
|
| 447 | case value_e::List:
|
| 448 | v = "List"; break;
|
| 449 | case value_e::Dict:
|
| 450 | v = "Dict"; break;
|
| 451 | case value_e::Eggex:
|
| 452 | v = "Eggex"; break;
|
| 453 | case value_e::Match:
|
| 454 | v = "Match"; break;
|
| 455 | case value_e::Expr:
|
| 456 | v = "Expr"; break;
|
| 457 | case value_e::Command:
|
| 458 | v = "Command"; break;
|
| 459 | case value_e::Block:
|
| 460 | v = "Block"; break;
|
| 461 | case value_e::Place:
|
| 462 | v = "Place"; break;
|
| 463 | case value_e::Module:
|
| 464 | v = "Module"; break;
|
| 465 | case value_e::IO:
|
| 466 | v = "IO"; break;
|
| 467 | case value_e::Guts:
|
| 468 | v = "Guts"; break;
|
| 469 | case value_e::BuiltinFunc:
|
| 470 | v = "BuiltinFunc"; break;
|
| 471 | case value_e::BoundFunc:
|
| 472 | v = "BoundFunc"; break;
|
| 473 | case value_e::Proc:
|
| 474 | v = "Proc"; break;
|
| 475 | case value_e::Func:
|
| 476 | v = "Func"; break;
|
| 477 | case value_e::Slice:
|
| 478 | v = "Slice"; break;
|
| 479 | case value_e::Range:
|
| 480 | v = "Range"; break;
|
| 481 | default:
|
| 482 | assert(0);
|
| 483 | }
|
| 484 | if (dot) {
|
| 485 | snprintf(buf, 32, "value.%s", v);
|
| 486 | return StrFromC(buf);
|
| 487 | } else {
|
| 488 | return StrFromC(v);
|
| 489 | }
|
| 490 | }
|
| 491 |
|
| 492 | value__Interrupted* value::Interrupted = &gvalue__Interrupted.obj;
|
| 493 |
|
| 494 | GcGlobal<value__Interrupted> gvalue__Interrupted =
|
| 495 | { ObjHeader::Global(value_e::Interrupted) };
|
| 496 |
|
| 497 | value__Stdin* value::Stdin = &gvalue__Stdin.obj;
|
| 498 |
|
| 499 | GcGlobal<value__Stdin> gvalue__Stdin =
|
| 500 | { ObjHeader::Global(value_e::Stdin) };
|
| 501 |
|
| 502 | value__Undef* value::Undef = &gvalue__Undef.obj;
|
| 503 |
|
| 504 | GcGlobal<value__Undef> gvalue__Undef =
|
| 505 | { ObjHeader::Global(value_e::Undef) };
|
| 506 |
|
| 507 | value__Null* value::Null = &gvalue__Null.obj;
|
| 508 |
|
| 509 | GcGlobal<value__Null> gvalue__Null =
|
| 510 | { ObjHeader::Global(value_e::Null) };
|
| 511 |
|
| 512 | hnode_t* value__Interrupted::PrettyTree(Dict<int, bool>* seen) {
|
| 513 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
| 514 | int heap_id = ObjectId(this);
|
| 515 | if (dict_contains(seen, heap_id)) {
|
| 516 | return Alloc<hnode::AlreadySeen>(heap_id);
|
| 517 | }
|
| 518 | seen->set(heap_id, true);
|
| 519 | hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
|
| 520 | return out_node;
|
| 521 | }
|
| 522 |
|
| 523 |
|
| 524 | hnode_t* value__Stdin::PrettyTree(Dict<int, bool>* seen) {
|
| 525 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
| 526 | int heap_id = ObjectId(this);
|
| 527 | if (dict_contains(seen, heap_id)) {
|
| 528 | return Alloc<hnode::AlreadySeen>(heap_id);
|
| 529 | }
|
| 530 | seen->set(heap_id, true);
|
| 531 | hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
|
| 532 | return out_node;
|
| 533 | }
|
| 534 |
|
| 535 |
|
| 536 | hnode_t* value__Undef::PrettyTree(Dict<int, bool>* seen) {
|
| 537 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
| 538 | int heap_id = ObjectId(this);
|
| 539 | if (dict_contains(seen, heap_id)) {
|
| 540 | return Alloc<hnode::AlreadySeen>(heap_id);
|
| 541 | }
|
| 542 | seen->set(heap_id, true);
|
| 543 | hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
|
| 544 | return out_node;
|
| 545 | }
|
| 546 |
|
| 547 |
|
| 548 | hnode_t* value__Str::PrettyTree(Dict<int, bool>* seen) {
|
| 549 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
| 550 | int heap_id = ObjectId(this);
|
| 551 | if (dict_contains(seen, heap_id)) {
|
| 552 | return Alloc<hnode::AlreadySeen>(heap_id);
|
| 553 | }
|
| 554 | seen->set(heap_id, true);
|
| 555 | hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
|
| 556 | List<Field*>* L = out_node->fields;
|
| 557 |
|
| 558 | hnode_t* x0 = runtime::NewLeaf(this->s, color_e::StringConst);
|
| 559 | L->append(Alloc<Field>(StrFromC("s"), x0));
|
| 560 |
|
| 561 | return out_node;
|
| 562 | }
|
| 563 |
|
| 564 |
|
| 565 | hnode_t* value__BashArray::PrettyTree(Dict<int, bool>* seen) {
|
| 566 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
| 567 | int heap_id = ObjectId(this);
|
| 568 | if (dict_contains(seen, heap_id)) {
|
| 569 | return Alloc<hnode::AlreadySeen>(heap_id);
|
| 570 | }
|
| 571 | seen->set(heap_id, true);
|
| 572 | hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
|
| 573 | List<Field*>* L = out_node->fields;
|
| 574 |
|
| 575 | if (this->strs != nullptr) { // List
|
| 576 | hnode::Array* x0 = Alloc<hnode::Array>(Alloc<List<hnode_t*>>());
|
| 577 | for (ListIter<BigStr*> it(this->strs); !it.Done(); it.Next()) {
|
| 578 | BigStr* i0 = it.Value();
|
| 579 | x0->children->append(runtime::NewLeaf(i0, color_e::StringConst));
|
| 580 | }
|
| 581 | L->append(Alloc<Field>(StrFromC("strs"), x0));
|
| 582 | }
|
| 583 |
|
| 584 | return out_node;
|
| 585 | }
|
| 586 |
|
| 587 |
|
| 588 | hnode_t* value__SparseArray::PrettyTree(Dict<int, bool>* seen) {
|
| 589 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
| 590 | int heap_id = ObjectId(this);
|
| 591 | if (dict_contains(seen, heap_id)) {
|
| 592 | return Alloc<hnode::AlreadySeen>(heap_id);
|
| 593 | }
|
| 594 | seen->set(heap_id, true);
|
| 595 | hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
|
| 596 | List<Field*>* L = out_node->fields;
|
| 597 |
|
| 598 | if (this->d) { // Dict
|
| 599 | auto m = Alloc<hnode::Leaf>(StrFromC("Dict"), color_e::OtherConst);
|
| 600 | hnode::Array* x0 = Alloc<hnode::Array>(NewList<hnode_t*>({m}));
|
| 601 | for (DictIter<mops::BigInt, BigStr*> it(this->d); !it.Done(); it.Next()) {
|
| 602 | auto k0 = it.Key();
|
| 603 | auto v0 = it.Value();
|
| 604 | x0->children->append(Alloc<hnode::Leaf>(mops::ToStr(k0),
|
| 605 | color_e::OtherConst));
|
| 606 | x0->children->append(runtime::NewLeaf(v0, color_e::StringConst));
|
| 607 | }
|
| 608 | L->append(Alloc<Field>(StrFromC ("d"), x0));
|
| 609 | }
|
| 610 |
|
| 611 | hnode_t* x1 = Alloc<hnode::Leaf>(mops::ToStr(this->max_index),
|
| 612 | color_e::OtherConst);
|
| 613 | L->append(Alloc<Field>(StrFromC("max_index"), x1));
|
| 614 |
|
| 615 | return out_node;
|
| 616 | }
|
| 617 |
|
| 618 |
|
| 619 | hnode_t* value__BashAssoc::PrettyTree(Dict<int, bool>* seen) {
|
| 620 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
| 621 | int heap_id = ObjectId(this);
|
| 622 | if (dict_contains(seen, heap_id)) {
|
| 623 | return Alloc<hnode::AlreadySeen>(heap_id);
|
| 624 | }
|
| 625 | seen->set(heap_id, true);
|
| 626 | hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
|
| 627 | List<Field*>* L = out_node->fields;
|
| 628 |
|
| 629 | if (this->d) { // Dict
|
| 630 | auto m = Alloc<hnode::Leaf>(StrFromC("Dict"), color_e::OtherConst);
|
| 631 | hnode::Array* x0 = Alloc<hnode::Array>(NewList<hnode_t*>({m}));
|
| 632 | for (DictIter<BigStr*, BigStr*> it(this->d); !it.Done(); it.Next()) {
|
| 633 | auto k0 = it.Key();
|
| 634 | auto v0 = it.Value();
|
| 635 | x0->children->append(runtime::NewLeaf(k0, color_e::StringConst));
|
| 636 | x0->children->append(runtime::NewLeaf(v0, color_e::StringConst));
|
| 637 | }
|
| 638 | L->append(Alloc<Field>(StrFromC ("d"), x0));
|
| 639 | }
|
| 640 |
|
| 641 | return out_node;
|
| 642 | }
|
| 643 |
|
| 644 |
|
| 645 | hnode_t* value__Null::PrettyTree(Dict<int, bool>* seen) {
|
| 646 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
| 647 | int heap_id = ObjectId(this);
|
| 648 | if (dict_contains(seen, heap_id)) {
|
| 649 | return Alloc<hnode::AlreadySeen>(heap_id);
|
| 650 | }
|
| 651 | seen->set(heap_id, true);
|
| 652 | hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
|
| 653 | return out_node;
|
| 654 | }
|
| 655 |
|
| 656 |
|
| 657 | hnode_t* value__Bool::PrettyTree(Dict<int, bool>* seen) {
|
| 658 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
| 659 | int heap_id = ObjectId(this);
|
| 660 | if (dict_contains(seen, heap_id)) {
|
| 661 | return Alloc<hnode::AlreadySeen>(heap_id);
|
| 662 | }
|
| 663 | seen->set(heap_id, true);
|
| 664 | hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
|
| 665 | List<Field*>* L = out_node->fields;
|
| 666 |
|
| 667 | hnode_t* x0 = Alloc<hnode::Leaf>(this->b ? runtime::TRUE_STR :
|
| 668 | runtime::FALSE_STR, color_e::OtherConst);
|
| 669 | L->append(Alloc<Field>(StrFromC("b"), x0));
|
| 670 |
|
| 671 | return out_node;
|
| 672 | }
|
| 673 |
|
| 674 |
|
| 675 | hnode_t* value__Int::PrettyTree(Dict<int, bool>* seen) {
|
| 676 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
| 677 | int heap_id = ObjectId(this);
|
| 678 | if (dict_contains(seen, heap_id)) {
|
| 679 | return Alloc<hnode::AlreadySeen>(heap_id);
|
| 680 | }
|
| 681 | seen->set(heap_id, true);
|
| 682 | hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
|
| 683 | List<Field*>* L = out_node->fields;
|
| 684 |
|
| 685 | hnode_t* x0 = Alloc<hnode::Leaf>(mops::ToStr(this->i), color_e::OtherConst);
|
| 686 | L->append(Alloc<Field>(StrFromC("i"), x0));
|
| 687 |
|
| 688 | return out_node;
|
| 689 | }
|
| 690 |
|
| 691 |
|
| 692 | hnode_t* value__Float::PrettyTree(Dict<int, bool>* seen) {
|
| 693 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
| 694 | int heap_id = ObjectId(this);
|
| 695 | if (dict_contains(seen, heap_id)) {
|
| 696 | return Alloc<hnode::AlreadySeen>(heap_id);
|
| 697 | }
|
| 698 | seen->set(heap_id, true);
|
| 699 | hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
|
| 700 | List<Field*>* L = out_node->fields;
|
| 701 |
|
| 702 | hnode_t* x0 = Alloc<hnode::Leaf>(str(this->f), color_e::OtherConst);
|
| 703 | L->append(Alloc<Field>(StrFromC("f"), x0));
|
| 704 |
|
| 705 | return out_node;
|
| 706 | }
|
| 707 |
|
| 708 |
|
| 709 | hnode_t* value__List::PrettyTree(Dict<int, bool>* seen) {
|
| 710 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
| 711 | int heap_id = ObjectId(this);
|
| 712 | if (dict_contains(seen, heap_id)) {
|
| 713 | return Alloc<hnode::AlreadySeen>(heap_id);
|
| 714 | }
|
| 715 | seen->set(heap_id, true);
|
| 716 | hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
|
| 717 | List<Field*>* L = out_node->fields;
|
| 718 |
|
| 719 | if (this->items != nullptr) { // List
|
| 720 | hnode::Array* x0 = Alloc<hnode::Array>(Alloc<List<hnode_t*>>());
|
| 721 | for (ListIter<value_t*> it(this->items); !it.Done(); it.Next()) {
|
| 722 | value_t* i0 = it.Value();
|
| 723 | hnode_t* h = (i0 == nullptr) ? Alloc<hnode::Leaf>(StrFromC("_"),
|
| 724 | color_e::OtherConst) : i0->PrettyTree(seen);
|
| 725 | x0->children->append(h);
|
| 726 | }
|
| 727 | L->append(Alloc<Field>(StrFromC("items"), x0));
|
| 728 | }
|
| 729 |
|
| 730 | return out_node;
|
| 731 | }
|
| 732 |
|
| 733 |
|
| 734 | hnode_t* value__Dict::PrettyTree(Dict<int, bool>* seen) {
|
| 735 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
| 736 | int heap_id = ObjectId(this);
|
| 737 | if (dict_contains(seen, heap_id)) {
|
| 738 | return Alloc<hnode::AlreadySeen>(heap_id);
|
| 739 | }
|
| 740 | seen->set(heap_id, true);
|
| 741 | hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
|
| 742 | List<Field*>* L = out_node->fields;
|
| 743 |
|
| 744 | if (this->d) { // Dict
|
| 745 | auto m = Alloc<hnode::Leaf>(StrFromC("Dict"), color_e::OtherConst);
|
| 746 | hnode::Array* x0 = Alloc<hnode::Array>(NewList<hnode_t*>({m}));
|
| 747 | for (DictIter<BigStr*, value_t*> it(this->d); !it.Done(); it.Next()) {
|
| 748 | auto k0 = it.Key();
|
| 749 | auto v0 = it.Value();
|
| 750 | x0->children->append(runtime::NewLeaf(k0, color_e::StringConst));
|
| 751 | x0->children->append(v0->PrettyTree(seen));
|
| 752 | }
|
| 753 | L->append(Alloc<Field>(StrFromC ("d"), x0));
|
| 754 | }
|
| 755 |
|
| 756 | return out_node;
|
| 757 | }
|
| 758 |
|
| 759 |
|
| 760 | hnode_t* value__Eggex::PrettyTree(Dict<int, bool>* seen) {
|
| 761 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
| 762 | int heap_id = ObjectId(this);
|
| 763 | if (dict_contains(seen, heap_id)) {
|
| 764 | return Alloc<hnode::AlreadySeen>(heap_id);
|
| 765 | }
|
| 766 | seen->set(heap_id, true);
|
| 767 | hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
|
| 768 | List<Field*>* L = out_node->fields;
|
| 769 |
|
| 770 | hnode_t* x0 = this->spliced->PrettyTree(seen);
|
| 771 | L->append(Alloc<Field>(StrFromC("spliced"), x0));
|
| 772 |
|
| 773 | hnode_t* x1 = runtime::NewLeaf(this->canonical_flags, color_e::StringConst);
|
| 774 | L->append(Alloc<Field>(StrFromC("canonical_flags"), x1));
|
| 775 |
|
| 776 | if (this->convert_funcs != nullptr) { // List
|
| 777 | hnode::Array* x2 = Alloc<hnode::Array>(Alloc<List<hnode_t*>>());
|
| 778 | for (ListIter<value_t*> it(this->convert_funcs); !it.Done(); it.Next()) {
|
| 779 | value_t* i2 = it.Value();
|
| 780 | hnode_t* h = (i2 == nullptr) ? Alloc<hnode::Leaf>(StrFromC("_"),
|
| 781 | color_e::OtherConst) : i2->PrettyTree(seen);
|
| 782 | x2->children->append(h);
|
| 783 | }
|
| 784 | L->append(Alloc<Field>(StrFromC("convert_funcs"), x2));
|
| 785 | }
|
| 786 |
|
| 787 | if (this->convert_toks != nullptr) { // List
|
| 788 | hnode::Array* x3 = Alloc<hnode::Array>(Alloc<List<hnode_t*>>());
|
| 789 | for (ListIter<syntax_asdl::Token*> it(this->convert_toks); !it.Done();
|
| 790 | it.Next()) {
|
| 791 | syntax_asdl::Token* i3 = it.Value();
|
| 792 | hnode_t* h = (i3 == nullptr) ? Alloc<hnode::Leaf>(StrFromC("_"),
|
| 793 | color_e::OtherConst) : i3->PrettyTree(seen);
|
| 794 | x3->children->append(h);
|
| 795 | }
|
| 796 | L->append(Alloc<Field>(StrFromC("convert_toks"), x3));
|
| 797 | }
|
| 798 |
|
| 799 | if (this->as_ere) { // Optional
|
| 800 | hnode_t* x4 = runtime::NewLeaf(this->as_ere, color_e::StringConst);
|
| 801 | L->append(Alloc<Field>(StrFromC("as_ere"), x4));
|
| 802 | }
|
| 803 |
|
| 804 | if (this->capture_names != nullptr) { // List
|
| 805 | hnode::Array* x5 = Alloc<hnode::Array>(Alloc<List<hnode_t*>>());
|
| 806 | for (ListIter<BigStr*> it(this->capture_names); !it.Done(); it.Next()) {
|
| 807 | BigStr* i5 = it.Value();
|
| 808 | x5->children->append(runtime::NewLeaf(i5, color_e::StringConst));
|
| 809 | }
|
| 810 | L->append(Alloc<Field>(StrFromC("capture_names"), x5));
|
| 811 | }
|
| 812 |
|
| 813 | return out_node;
|
| 814 | }
|
| 815 |
|
| 816 |
|
| 817 | hnode_t* value__Expr::PrettyTree(Dict<int, bool>* seen) {
|
| 818 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
| 819 | int heap_id = ObjectId(this);
|
| 820 | if (dict_contains(seen, heap_id)) {
|
| 821 | return Alloc<hnode::AlreadySeen>(heap_id);
|
| 822 | }
|
| 823 | seen->set(heap_id, true);
|
| 824 | hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
|
| 825 | List<Field*>* L = out_node->fields;
|
| 826 |
|
| 827 | hnode_t* x0 = this->e->PrettyTree(seen);
|
| 828 | L->append(Alloc<Field>(StrFromC("e"), x0));
|
| 829 |
|
| 830 | return out_node;
|
| 831 | }
|
| 832 |
|
| 833 |
|
| 834 | hnode_t* value__Command::PrettyTree(Dict<int, bool>* seen) {
|
| 835 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
| 836 | int heap_id = ObjectId(this);
|
| 837 | if (dict_contains(seen, heap_id)) {
|
| 838 | return Alloc<hnode::AlreadySeen>(heap_id);
|
| 839 | }
|
| 840 | seen->set(heap_id, true);
|
| 841 | hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
|
| 842 | List<Field*>* L = out_node->fields;
|
| 843 |
|
| 844 | hnode_t* x0 = this->c->PrettyTree(seen);
|
| 845 | L->append(Alloc<Field>(StrFromC("c"), x0));
|
| 846 |
|
| 847 | return out_node;
|
| 848 | }
|
| 849 |
|
| 850 |
|
| 851 | hnode_t* value__Block::PrettyTree(Dict<int, bool>* seen) {
|
| 852 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
| 853 | int heap_id = ObjectId(this);
|
| 854 | if (dict_contains(seen, heap_id)) {
|
| 855 | return Alloc<hnode::AlreadySeen>(heap_id);
|
| 856 | }
|
| 857 | seen->set(heap_id, true);
|
| 858 | hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
|
| 859 | List<Field*>* L = out_node->fields;
|
| 860 |
|
| 861 | hnode_t* x0 = this->block->PrettyTree(seen);
|
| 862 | L->append(Alloc<Field>(StrFromC("block"), x0));
|
| 863 |
|
| 864 | return out_node;
|
| 865 | }
|
| 866 |
|
| 867 |
|
| 868 | hnode_t* value__Place::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 | hnode_t* x0 = this->lval->PrettyTree(seen);
|
| 879 | L->append(Alloc<Field>(StrFromC("lval"), x0));
|
| 880 |
|
| 881 | if (this->frame) { // Dict
|
| 882 | auto m = Alloc<hnode::Leaf>(StrFromC("Dict"), color_e::OtherConst);
|
| 883 | hnode::Array* x1 = Alloc<hnode::Array>(NewList<hnode_t*>({m}));
|
| 884 | for (DictIter<BigStr*, runtime_asdl::Cell*> it(this->frame); !it.Done();
|
| 885 | it.Next()) {
|
| 886 | auto k1 = it.Key();
|
| 887 | auto v1 = it.Value();
|
| 888 | x1->children->append(runtime::NewLeaf(k1, color_e::StringConst));
|
| 889 | x1->children->append(v1->PrettyTree(seen));
|
| 890 | }
|
| 891 | L->append(Alloc<Field>(StrFromC ("frame"), x1));
|
| 892 | }
|
| 893 |
|
| 894 | return out_node;
|
| 895 | }
|
| 896 |
|
| 897 |
|
| 898 | hnode_t* value__Module::PrettyTree(Dict<int, bool>* seen) {
|
| 899 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
| 900 | int heap_id = ObjectId(this);
|
| 901 | if (dict_contains(seen, heap_id)) {
|
| 902 | return Alloc<hnode::AlreadySeen>(heap_id);
|
| 903 | }
|
| 904 | seen->set(heap_id, true);
|
| 905 | hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
|
| 906 | List<Field*>* L = out_node->fields;
|
| 907 |
|
| 908 | if (this->defs) { // Dict
|
| 909 | auto m = Alloc<hnode::Leaf>(StrFromC("Dict"), color_e::OtherConst);
|
| 910 | hnode::Array* x0 = Alloc<hnode::Array>(NewList<hnode_t*>({m}));
|
| 911 | for (DictIter<BigStr*, value_t*> it(this->defs); !it.Done(); it.Next()) {
|
| 912 | auto k0 = it.Key();
|
| 913 | auto v0 = it.Value();
|
| 914 | x0->children->append(runtime::NewLeaf(k0, color_e::StringConst));
|
| 915 | x0->children->append(v0->PrettyTree(seen));
|
| 916 | }
|
| 917 | L->append(Alloc<Field>(StrFromC ("defs"), x0));
|
| 918 | }
|
| 919 |
|
| 920 | return out_node;
|
| 921 | }
|
| 922 |
|
| 923 |
|
| 924 | hnode_t* value__IO::PrettyTree(Dict<int, bool>* seen) {
|
| 925 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
| 926 | int heap_id = ObjectId(this);
|
| 927 | if (dict_contains(seen, heap_id)) {
|
| 928 | return Alloc<hnode::AlreadySeen>(heap_id);
|
| 929 | }
|
| 930 | seen->set(heap_id, true);
|
| 931 | hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
|
| 932 | List<Field*>* L = out_node->fields;
|
| 933 |
|
| 934 | hnode_t* x0 = Alloc<hnode::External>(this->cmd_ev);
|
| 935 | L->append(Alloc<Field>(StrFromC("cmd_ev"), x0));
|
| 936 |
|
| 937 | hnode_t* x1 = Alloc<hnode::External>(this->prompt_ev);
|
| 938 | L->append(Alloc<Field>(StrFromC("prompt_ev"), x1));
|
| 939 |
|
| 940 | return out_node;
|
| 941 | }
|
| 942 |
|
| 943 |
|
| 944 | hnode_t* value__Guts::PrettyTree(Dict<int, bool>* seen) {
|
| 945 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
| 946 | int heap_id = ObjectId(this);
|
| 947 | if (dict_contains(seen, heap_id)) {
|
| 948 | return Alloc<hnode::AlreadySeen>(heap_id);
|
| 949 | }
|
| 950 | seen->set(heap_id, true);
|
| 951 | hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
|
| 952 | List<Field*>* L = out_node->fields;
|
| 953 |
|
| 954 | hnode_t* x0 = Alloc<hnode::External>(this->vm);
|
| 955 | L->append(Alloc<Field>(StrFromC("vm"), x0));
|
| 956 |
|
| 957 | return out_node;
|
| 958 | }
|
| 959 |
|
| 960 |
|
| 961 | hnode_t* value__BuiltinFunc::PrettyTree(Dict<int, bool>* seen) {
|
| 962 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
| 963 | int heap_id = ObjectId(this);
|
| 964 | if (dict_contains(seen, heap_id)) {
|
| 965 | return Alloc<hnode::AlreadySeen>(heap_id);
|
| 966 | }
|
| 967 | seen->set(heap_id, true);
|
| 968 | hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
|
| 969 | List<Field*>* L = out_node->fields;
|
| 970 |
|
| 971 | hnode_t* x0 = Alloc<hnode::External>(this->callable);
|
| 972 | L->append(Alloc<Field>(StrFromC("callable"), x0));
|
| 973 |
|
| 974 | return out_node;
|
| 975 | }
|
| 976 |
|
| 977 |
|
| 978 | hnode_t* value__BoundFunc::PrettyTree(Dict<int, bool>* seen) {
|
| 979 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
| 980 | int heap_id = ObjectId(this);
|
| 981 | if (dict_contains(seen, heap_id)) {
|
| 982 | return Alloc<hnode::AlreadySeen>(heap_id);
|
| 983 | }
|
| 984 | seen->set(heap_id, true);
|
| 985 | hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
|
| 986 | List<Field*>* L = out_node->fields;
|
| 987 |
|
| 988 | hnode_t* x0 = this->me->PrettyTree(seen);
|
| 989 | L->append(Alloc<Field>(StrFromC("me"), x0));
|
| 990 |
|
| 991 | hnode_t* x1 = this->func->PrettyTree(seen);
|
| 992 | L->append(Alloc<Field>(StrFromC("func"), x1));
|
| 993 |
|
| 994 | return out_node;
|
| 995 | }
|
| 996 |
|
| 997 |
|
| 998 | hnode_t* value__Proc::PrettyTree(Dict<int, bool>* seen) {
|
| 999 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
| 1000 | int heap_id = ObjectId(this);
|
| 1001 | if (dict_contains(seen, heap_id)) {
|
| 1002 | return Alloc<hnode::AlreadySeen>(heap_id);
|
| 1003 | }
|
| 1004 | seen->set(heap_id, true);
|
| 1005 | hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
|
| 1006 | List<Field*>* L = out_node->fields;
|
| 1007 |
|
| 1008 | hnode_t* x0 = runtime::NewLeaf(this->name, color_e::StringConst);
|
| 1009 | L->append(Alloc<Field>(StrFromC("name"), x0));
|
| 1010 |
|
| 1011 | hnode_t* x1 = this->name_tok->PrettyTree(seen);
|
| 1012 | L->append(Alloc<Field>(StrFromC("name_tok"), x1));
|
| 1013 |
|
| 1014 | hnode_t* x2 = this->sig->PrettyTree(seen);
|
| 1015 | L->append(Alloc<Field>(StrFromC("sig"), x2));
|
| 1016 |
|
| 1017 | hnode_t* x3 = this->body->PrettyTree(seen);
|
| 1018 | L->append(Alloc<Field>(StrFromC("body"), x3));
|
| 1019 |
|
| 1020 | if (this->defaults) { // Optional
|
| 1021 | hnode_t* x4 = this->defaults->PrettyTree(seen);
|
| 1022 | L->append(Alloc<Field>(StrFromC("defaults"), x4));
|
| 1023 | }
|
| 1024 |
|
| 1025 | hnode_t* x5 = Alloc<hnode::Leaf>(this->sh_compat ? runtime::TRUE_STR :
|
| 1026 | runtime::FALSE_STR, color_e::OtherConst);
|
| 1027 | L->append(Alloc<Field>(StrFromC("sh_compat"), x5));
|
| 1028 |
|
| 1029 | return out_node;
|
| 1030 | }
|
| 1031 |
|
| 1032 |
|
| 1033 | hnode_t* value__Func::PrettyTree(Dict<int, bool>* seen) {
|
| 1034 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
| 1035 | int heap_id = ObjectId(this);
|
| 1036 | if (dict_contains(seen, heap_id)) {
|
| 1037 | return Alloc<hnode::AlreadySeen>(heap_id);
|
| 1038 | }
|
| 1039 | seen->set(heap_id, true);
|
| 1040 | hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
|
| 1041 | List<Field*>* L = out_node->fields;
|
| 1042 |
|
| 1043 | hnode_t* x0 = runtime::NewLeaf(this->name, color_e::StringConst);
|
| 1044 | L->append(Alloc<Field>(StrFromC("name"), x0));
|
| 1045 |
|
| 1046 | hnode_t* x1 = this->parsed->PrettyTree(seen);
|
| 1047 | L->append(Alloc<Field>(StrFromC("parsed"), x1));
|
| 1048 |
|
| 1049 | if (this->pos_defaults != nullptr) { // List
|
| 1050 | hnode::Array* x2 = Alloc<hnode::Array>(Alloc<List<hnode_t*>>());
|
| 1051 | for (ListIter<value_t*> it(this->pos_defaults); !it.Done(); it.Next()) {
|
| 1052 | value_t* i2 = it.Value();
|
| 1053 | hnode_t* h = (i2 == nullptr) ? Alloc<hnode::Leaf>(StrFromC("_"),
|
| 1054 | color_e::OtherConst) : i2->PrettyTree(seen);
|
| 1055 | x2->children->append(h);
|
| 1056 | }
|
| 1057 | L->append(Alloc<Field>(StrFromC("pos_defaults"), x2));
|
| 1058 | }
|
| 1059 |
|
| 1060 | if (this->named_defaults) { // Dict
|
| 1061 | auto m = Alloc<hnode::Leaf>(StrFromC("Dict"), color_e::OtherConst);
|
| 1062 | hnode::Array* x3 = Alloc<hnode::Array>(NewList<hnode_t*>({m}));
|
| 1063 | for (DictIter<BigStr*, value_t*> it(this->named_defaults); !it.Done();
|
| 1064 | it.Next()) {
|
| 1065 | auto k3 = it.Key();
|
| 1066 | auto v3 = it.Value();
|
| 1067 | x3->children->append(runtime::NewLeaf(k3, color_e::StringConst));
|
| 1068 | x3->children->append(v3->PrettyTree(seen));
|
| 1069 | }
|
| 1070 | L->append(Alloc<Field>(StrFromC ("named_defaults"), x3));
|
| 1071 | }
|
| 1072 |
|
| 1073 | if (this->module_) { // Dict
|
| 1074 | auto m = Alloc<hnode::Leaf>(StrFromC("Dict"), color_e::OtherConst);
|
| 1075 | hnode::Array* x4 = Alloc<hnode::Array>(NewList<hnode_t*>({m}));
|
| 1076 | for (DictIter<BigStr*, runtime_asdl::Cell*> it(this->module_); !it.Done();
|
| 1077 | it.Next()) {
|
| 1078 | auto k4 = it.Key();
|
| 1079 | auto v4 = it.Value();
|
| 1080 | x4->children->append(runtime::NewLeaf(k4, color_e::StringConst));
|
| 1081 | x4->children->append(v4->PrettyTree(seen));
|
| 1082 | }
|
| 1083 | L->append(Alloc<Field>(StrFromC ("module_"), x4));
|
| 1084 | }
|
| 1085 |
|
| 1086 | return out_node;
|
| 1087 | }
|
| 1088 |
|
| 1089 |
|
| 1090 | hnode_t* value__Slice::PrettyTree(Dict<int, bool>* seen) {
|
| 1091 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
| 1092 | int heap_id = ObjectId(this);
|
| 1093 | if (dict_contains(seen, heap_id)) {
|
| 1094 | return Alloc<hnode::AlreadySeen>(heap_id);
|
| 1095 | }
|
| 1096 | seen->set(heap_id, true);
|
| 1097 | hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
|
| 1098 | List<Field*>* L = out_node->fields;
|
| 1099 |
|
| 1100 | if (this->lower) { // Optional
|
| 1101 | hnode_t* x0 = this->lower->PrettyTree(seen);
|
| 1102 | L->append(Alloc<Field>(StrFromC("lower"), x0));
|
| 1103 | }
|
| 1104 |
|
| 1105 | if (this->upper) { // Optional
|
| 1106 | hnode_t* x1 = this->upper->PrettyTree(seen);
|
| 1107 | L->append(Alloc<Field>(StrFromC("upper"), x1));
|
| 1108 | }
|
| 1109 |
|
| 1110 | return out_node;
|
| 1111 | }
|
| 1112 |
|
| 1113 |
|
| 1114 | hnode_t* value__Range::PrettyTree(Dict<int, bool>* seen) {
|
| 1115 | seen = seen ? seen : Alloc<Dict<int, bool>>();
|
| 1116 | int heap_id = ObjectId(this);
|
| 1117 | if (dict_contains(seen, heap_id)) {
|
| 1118 | return Alloc<hnode::AlreadySeen>(heap_id);
|
| 1119 | }
|
| 1120 | seen->set(heap_id, true);
|
| 1121 | hnode::Record* out_node = runtime::NewRecord(value_str(this->tag()));
|
| 1122 | List<Field*>* L = out_node->fields;
|
| 1123 |
|
| 1124 | hnode_t* x0 = Alloc<hnode::Leaf>(str(this->lower), color_e::OtherConst);
|
| 1125 | L->append(Alloc<Field>(StrFromC("lower"), x0));
|
| 1126 |
|
| 1127 | hnode_t* x1 = Alloc<hnode::Leaf>(str(this->upper), color_e::OtherConst);
|
| 1128 | L->append(Alloc<Field>(StrFromC("upper"), x1));
|
| 1129 |
|
| 1130 | return out_node;
|
| 1131 | }
|
| 1132 |
|
| 1133 |
|
| 1134 | hnode_t* value_t::PrettyTree(Dict<int, bool>* seen) {
|
| 1135 | switch (this->tag()) {
|
| 1136 | case value_e::Interrupted: {
|
| 1137 | value__Interrupted* obj = static_cast<value__Interrupted*>(this);
|
| 1138 | return obj->PrettyTree(seen);
|
| 1139 | }
|
| 1140 | case value_e::Stdin: {
|
| 1141 | value__Stdin* obj = static_cast<value__Stdin*>(this);
|
| 1142 | return obj->PrettyTree(seen);
|
| 1143 | }
|
| 1144 | case value_e::Undef: {
|
| 1145 | value__Undef* obj = static_cast<value__Undef*>(this);
|
| 1146 | return obj->PrettyTree(seen);
|
| 1147 | }
|
| 1148 | case value_e::Str: {
|
| 1149 | value__Str* obj = static_cast<value__Str*>(this);
|
| 1150 | return obj->PrettyTree(seen);
|
| 1151 | }
|
| 1152 | case value_e::BashArray: {
|
| 1153 | value__BashArray* obj = static_cast<value__BashArray*>(this);
|
| 1154 | return obj->PrettyTree(seen);
|
| 1155 | }
|
| 1156 | case value_e::SparseArray: {
|
| 1157 | value__SparseArray* obj = static_cast<value__SparseArray*>(this);
|
| 1158 | return obj->PrettyTree(seen);
|
| 1159 | }
|
| 1160 | case value_e::BashAssoc: {
|
| 1161 | value__BashAssoc* obj = static_cast<value__BashAssoc*>(this);
|
| 1162 | return obj->PrettyTree(seen);
|
| 1163 | }
|
| 1164 | case value_e::Null: {
|
| 1165 | value__Null* obj = static_cast<value__Null*>(this);
|
| 1166 | return obj->PrettyTree(seen);
|
| 1167 | }
|
| 1168 | case value_e::Bool: {
|
| 1169 | value__Bool* obj = static_cast<value__Bool*>(this);
|
| 1170 | return obj->PrettyTree(seen);
|
| 1171 | }
|
| 1172 | case value_e::Int: {
|
| 1173 | value__Int* obj = static_cast<value__Int*>(this);
|
| 1174 | return obj->PrettyTree(seen);
|
| 1175 | }
|
| 1176 | case value_e::Float: {
|
| 1177 | value__Float* obj = static_cast<value__Float*>(this);
|
| 1178 | return obj->PrettyTree(seen);
|
| 1179 | }
|
| 1180 | case value_e::List: {
|
| 1181 | value__List* obj = static_cast<value__List*>(this);
|
| 1182 | return obj->PrettyTree(seen);
|
| 1183 | }
|
| 1184 | case value_e::Dict: {
|
| 1185 | value__Dict* obj = static_cast<value__Dict*>(this);
|
| 1186 | return obj->PrettyTree(seen);
|
| 1187 | }
|
| 1188 | case value_e::Eggex: {
|
| 1189 | value__Eggex* obj = static_cast<value__Eggex*>(this);
|
| 1190 | return obj->PrettyTree(seen);
|
| 1191 | }
|
| 1192 | case value_e::Match: {
|
| 1193 | RegexMatch* obj = static_cast<RegexMatch*>(this);
|
| 1194 | return obj->PrettyTree(seen);
|
| 1195 | }
|
| 1196 | case value_e::Expr: {
|
| 1197 | value__Expr* obj = static_cast<value__Expr*>(this);
|
| 1198 | return obj->PrettyTree(seen);
|
| 1199 | }
|
| 1200 | case value_e::Command: {
|
| 1201 | value__Command* obj = static_cast<value__Command*>(this);
|
| 1202 | return obj->PrettyTree(seen);
|
| 1203 | }
|
| 1204 | case value_e::Block: {
|
| 1205 | value__Block* obj = static_cast<value__Block*>(this);
|
| 1206 | return obj->PrettyTree(seen);
|
| 1207 | }
|
| 1208 | case value_e::Place: {
|
| 1209 | value__Place* obj = static_cast<value__Place*>(this);
|
| 1210 | return obj->PrettyTree(seen);
|
| 1211 | }
|
| 1212 | case value_e::Module: {
|
| 1213 | value__Module* obj = static_cast<value__Module*>(this);
|
| 1214 | return obj->PrettyTree(seen);
|
| 1215 | }
|
| 1216 | case value_e::IO: {
|
| 1217 | value__IO* obj = static_cast<value__IO*>(this);
|
| 1218 | return obj->PrettyTree(seen);
|
| 1219 | }
|
| 1220 | case value_e::Guts: {
|
| 1221 | value__Guts* obj = static_cast<value__Guts*>(this);
|
| 1222 | return obj->PrettyTree(seen);
|
| 1223 | }
|
| 1224 | case value_e::BuiltinFunc: {
|
| 1225 | value__BuiltinFunc* obj = static_cast<value__BuiltinFunc*>(this);
|
| 1226 | return obj->PrettyTree(seen);
|
| 1227 | }
|
| 1228 | case value_e::BoundFunc: {
|
| 1229 | value__BoundFunc* obj = static_cast<value__BoundFunc*>(this);
|
| 1230 | return obj->PrettyTree(seen);
|
| 1231 | }
|
| 1232 | case value_e::Proc: {
|
| 1233 | value__Proc* obj = static_cast<value__Proc*>(this);
|
| 1234 | return obj->PrettyTree(seen);
|
| 1235 | }
|
| 1236 | case value_e::Func: {
|
| 1237 | value__Func* obj = static_cast<value__Func*>(this);
|
| 1238 | return obj->PrettyTree(seen);
|
| 1239 | }
|
| 1240 | case value_e::Slice: {
|
| 1241 | value__Slice* obj = static_cast<value__Slice*>(this);
|
| 1242 | return obj->PrettyTree(seen);
|
| 1243 | }
|
| 1244 | case value_e::Range: {
|
| 1245 | value__Range* obj = static_cast<value__Range*>(this);
|
| 1246 | return obj->PrettyTree(seen);
|
| 1247 | }
|
| 1248 | default:
|
| 1249 | assert(0);
|
| 1250 | }
|
| 1251 | }
|
| 1252 |
|
| 1253 | } // namespace value_asdl
|