| 1 |
// Copyright (C) 2020-2025 Free Software Foundation, Inc. |
| 2 |
|
| 3 |
// This file is part of GCC. |
| 4 |
|
| 5 |
// GCC is free software; you can redistribute it and/or modify it under |
| 6 |
// the terms of the GNU General Public License as published by the Free |
| 7 |
// Software Foundation; either version 3, or (at your option) any later |
| 8 |
// version. |
| 9 |
|
| 10 |
// GCC is distributed in the hope that it will be useful, but WITHOUT ANY |
| 11 |
// WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 12 |
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 13 |
// for more details. |
| 14 |
|
| 15 |
// You should have received a copy of the GNU General Public License |
| 16 |
// along with GCC; see the file COPYING3. If not see |
| 17 |
// <http://www.gnu.org/licenses/>. |
| 18 |
|
| 19 |
#include "rust-hir-dump.h" |
| 20 |
#include "rust-abi.h" |
| 21 |
#include "rust-hir-item.h" |
| 22 |
#include "rust-hir-path.h" |
| 23 |
#include "rust-hir-type.h" |
| 24 |
#include "rust-hir.h" |
| 25 |
#include "rust-attribute-values.h" |
| 26 |
#include "tree/rust-hir-expr.h" |
| 27 |
#include "rust-system.h" |
| 28 |
|
| 29 |
namespace Rust { |
| 30 |
namespace HIR { |
| 31 |
|
| 32 |
// Dump Format for HIR |
| 33 |
// |
| 34 |
// SomeHIRNode [ |
| 35 |
// field: ... |
| 36 |
// field: ... |
| 37 |
// field: ... |
| 38 |
// ] |
| 39 |
// |
| 40 |
// When a field is a collection of other HIR objects: |
| 41 |
// field { |
| 42 |
// SomeHIRNode [ ... ] |
| 43 |
// SomeOtherHIRNode [ ... ] |
| 44 |
// } |
| 45 |
// |
| 46 |
// If a field is an empty collection: |
| 47 |
// field: empty |
| 48 |
// |
| 49 |
// If a field is optional and is currently not holding anything: |
| 50 |
// field: none |
| 51 |
|
| 52 |
std::string Dump::delims[2][2] = { |
| 53 |
{std::string ("{"), std::string ("}")}, |
| 54 |
{std::string ("["), std::string ("]")}, |
| 55 |
}; |
| 56 |
|
| 57 |
static std::string |
| 58 |
BoundPolarityString (BoundPolarity polarity) |
| 59 |
{ |
| 60 |
switch (polarity) |
| 61 |
{ |
| 62 |
case RegularBound: |
| 63 |
return "regular"; |
| 64 |
case NegativeBound: |
| 65 |
return "negative"; |
| 66 |
case AntiBound: |
| 67 |
return "anti"; |
| 68 |
} |
| 69 |
return "unknown"; |
| 70 |
} |
| 71 |
|
| 72 |
/** |
| 73 |
* Static member used to dump HIR from the debugger to stderr. |
| 74 |
* |
| 75 |
* @param v The HIR node to dump |
| 76 |
*/ |
| 77 |
void |
| 78 |
Dump::debug (FullVisitable &v) |
| 79 |
{ |
| 80 |
Dump dump (std::cerr); |
| 81 |
v.accept_vis (dump); |
| 82 |
} |
| 83 |
|
| 84 |
void |
| 85 |
Dump::go (HIR::Crate &e) |
| 86 |
{ |
| 87 |
begin ("Crate"); |
| 88 |
do_inner_attrs (e); |
| 89 |
do_mappings (e.get_mappings ()); |
| 90 |
|
| 91 |
visit_collection ("items", e.get_items ()); |
| 92 |
end ("Crate"); |
| 93 |
} |
| 94 |
|
| 95 |
Dump::Dump (std::ostream &stream) : stream (stream) {} |
| 96 |
|
| 97 |
/** |
| 98 |
* Writes TEXT with a final newline if ENDLINE is true. |
| 99 |
* If TEXT is starting the current line, its first line is indented. |
| 100 |
* If TEXT is multiline, all followning lines are also indented. |
| 101 |
* |
| 102 |
* @param text Text to emit |
| 103 |
* @param endline If true, newline is emitted after text |
| 104 |
*/ |
| 105 |
void |
| 106 |
Dump::put (std::string text, bool endline) |
| 107 |
{ |
| 108 |
if (beg_of_line) |
| 109 |
{ |
| 110 |
stream << indentation; |
| 111 |
beg_of_line = false; |
| 112 |
} |
| 113 |
|
| 114 |
// keep multiline string indented |
| 115 |
std::string::size_type pos = 0; |
| 116 |
std::string::size_type prev = 0; |
| 117 |
auto first = true; |
| 118 |
while ((pos = text.find ('\n', prev)) != std::string::npos) |
| 119 |
{ |
| 120 |
if (!first) |
| 121 |
stream << std::endl << indentation; |
| 122 |
first = false; |
| 123 |
|
| 124 |
stream << text.substr (prev, pos - prev); |
| 125 |
prev = pos + 1; |
| 126 |
} |
| 127 |
|
| 128 |
if (first) |
| 129 |
stream << text; |
| 130 |
|
| 131 |
if (endline) |
| 132 |
{ |
| 133 |
stream << std::endl; |
| 134 |
beg_of_line = endline; |
| 135 |
} |
| 136 |
} |
| 137 |
|
| 138 |
/** |
| 139 |
* Called when starting to emit info for an HIR node. |
| 140 |
* Emits NAME and an opening delimiter denoted by D. |
| 141 |
* |
| 142 |
* @param name Name of HIR node |
| 143 |
* @param d Delimiter |
| 144 |
*/ |
| 145 |
void |
| 146 |
Dump::begin (std::string name, enum delim d) |
| 147 |
{ |
| 148 |
if (!beg_of_line) |
| 149 |
put (""); |
| 150 |
put (name + " " + delims[d][0], true); |
| 151 |
indentation.increment (); |
| 152 |
} |
| 153 |
|
| 154 |
/** |
| 155 |
* Called when ending the dump info for an HIR node. Emits a C++-style |
| 156 |
* comment with NAME and a closing delimiter denoted by D. |
| 157 |
* |
| 158 |
* @param name Name of HIR node |
| 159 |
* @param d Delimiter |
| 160 |
*/ |
| 161 |
void |
| 162 |
Dump::end (std::string name, enum delim d) |
| 163 |
{ |
| 164 |
indentation.decrement (); |
| 165 |
if (!beg_of_line) |
| 166 |
stream << std::endl; |
| 167 |
put (delims[d][1] + " // " + name); |
| 168 |
} |
| 169 |
|
| 170 |
/** |
| 171 |
* Called when starting to emit info for a field within an HIR node. |
| 172 |
* Emits NAME and an opening curly brace |
| 173 |
* |
| 174 |
* @param name HIR field name |
| 175 |
*/ |
| 176 |
void |
| 177 |
Dump::begin_field (std::string name) |
| 178 |
{ |
| 179 |
begin (name, CURLY); |
| 180 |
} |
| 181 |
|
| 182 |
/** |
| 183 |
* Called when ending the dump info for a field within an HIR node. |
| 184 |
* Emits a C++-style comment with NAME and a closing curly brace |
| 185 |
* |
| 186 |
* @param name HIR field name |
| 187 |
*/ |
| 188 |
void |
| 189 |
Dump::end_field (std::string name) |
| 190 |
{ |
| 191 |
end (name, CURLY); |
| 192 |
} |
| 193 |
|
| 194 |
/** |
| 195 |
* Emits a single field/value pair denoted by NAME and TEXT. |
| 196 |
* |
| 197 |
* @param name Field name |
| 198 |
* @param text Field value |
| 199 |
*/ |
| 200 |
void |
| 201 |
Dump::put_field (std::string name, std::string text) |
| 202 |
{ |
| 203 |
put (name + ": ", false); |
| 204 |
indentation.increment (); |
| 205 |
put (text); |
| 206 |
indentation.decrement (); |
| 207 |
} |
| 208 |
|
| 209 |
/** |
| 210 |
* Recursively visits an HIR field NAME with value possibly pointed to by |
| 211 |
* PTR, if PTR is not null. If PTR is null, simply emits FIELD_NAME/NULL pair. |
| 212 |
* |
| 213 |
* @param name Field name |
| 214 |
* @param ptr Pointer to field's value |
| 215 |
*/ |
| 216 |
template <class T> |
| 217 |
void |
| 218 |
Dump::visit_field (std::string name, std::unique_ptr<T> &ptr) |
| 219 |
{ |
| 220 |
if (ptr) |
| 221 |
visit_field (name, *ptr); |
| 222 |
else |
| 223 |
put_field (name, "NULL"); |
| 224 |
} |
| 225 |
|
| 226 |
/** |
| 227 |
* Recursively visits an HIR field NAME with value V. |
| 228 |
* |
| 229 |
* @param name Field name |
| 230 |
* @param v Field value |
| 231 |
*/ |
| 232 |
void |
| 233 |
Dump::visit_field (std::string name, FullVisitable &v) |
| 234 |
{ |
| 235 |
put (name + ": ", false); |
| 236 |
indentation.increment (); |
| 237 |
v.accept_vis (*this); |
| 238 |
indentation.decrement (); |
| 239 |
} |
| 240 |
|
| 241 |
/** |
| 242 |
* Recursively visits a collection VEC of HIR node for field NAME. |
| 243 |
* If VEC is empty, simply emits the NAME/empty pair. |
| 244 |
* |
| 245 |
* @param name Field name |
| 246 |
* @param vec Field value as a vector |
| 247 |
*/ |
| 248 |
template <class T> |
| 249 |
void |
| 250 |
Dump::visit_collection (std::string name, std::vector<std::unique_ptr<T>> &vec) |
| 251 |
{ |
| 252 |
if (vec.empty ()) |
| 253 |
{ |
| 254 |
put_field (name, "empty"); |
| 255 |
return; |
| 256 |
} |
| 257 |
|
| 258 |
begin_field (name); |
| 259 |
for (const auto &elt : vec) |
| 260 |
elt->accept_vis (*this); |
| 261 |
end_field (name); |
| 262 |
} |
| 263 |
|
| 264 |
/** |
| 265 |
* Recursively visits a collection VEC of HIR node for field NAME. |
| 266 |
* If VEC is empty, simply emits the NAME/empty pair. |
| 267 |
* |
| 268 |
* @param name Field name |
| 269 |
* @param vec Field value as a vector |
| 270 |
*/ |
| 271 |
template <class T> |
| 272 |
void |
| 273 |
Dump::visit_collection (std::string name, std::vector<T> &vec) |
| 274 |
{ |
| 275 |
if (vec.empty ()) |
| 276 |
{ |
| 277 |
put_field (name, "empty"); |
| 278 |
return; |
| 279 |
} |
| 280 |
|
| 281 |
begin_field (name); |
| 282 |
for (auto &elt : vec) |
| 283 |
elt.accept_vis (*this); |
| 284 |
end_field (name); |
| 285 |
} |
| 286 |
|
| 287 |
void |
| 288 |
Dump::do_traititem (TraitItem &e) |
| 289 |
{ |
| 290 |
do_mappings (e.get_mappings ()); |
| 291 |
auto oa = e.get_outer_attrs (); |
| 292 |
do_outer_attrs (oa); |
| 293 |
} |
| 294 |
|
| 295 |
void |
| 296 |
Dump::do_vis_item (VisItem &e) |
| 297 |
{ |
| 298 |
do_item (e); |
| 299 |
std::string str = "none"; |
| 300 |
if (e.has_visibility ()) |
| 301 |
str = e.get_visibility ().as_string (); |
| 302 |
put_field ("visibility", str); |
| 303 |
} |
| 304 |
|
| 305 |
void |
| 306 |
Dump::do_functionparam (FunctionParam &e) |
| 307 |
{ |
| 308 |
begin ("FunctionParam"); |
| 309 |
do_mappings (e.get_mappings ()); |
| 310 |
visit_field ("param_name", e.get_param_name ()); |
| 311 |
visit_field ("type", e.get_type ()); |
| 312 |
end ("FunctionParam"); |
| 313 |
} |
| 314 |
|
| 315 |
void |
| 316 |
Dump::do_pathpattern (PathPattern &e) |
| 317 |
{ |
| 318 |
if (e.get_path_kind () == PathPattern::Kind::LangItem) |
| 319 |
{ |
| 320 |
put_field ("segments", "#[lang = \"" |
| 321 |
+ LangItem::ToString (e.get_lang_item ()) |
| 322 |
+ "\"]"); |
| 323 |
return; |
| 324 |
} |
| 325 |
|
| 326 |
std::string str = ""; |
| 327 |
|
| 328 |
for (const auto &segment : e.get_segments ()) |
| 329 |
str += segment.as_string () + ", "; |
| 330 |
|
| 331 |
put_field ("segments", str); |
| 332 |
} |
| 333 |
|
| 334 |
void |
| 335 |
Dump::do_structexprstruct (StructExprStruct &e) |
| 336 |
{ |
| 337 |
do_expr (e); |
| 338 |
|
| 339 |
// StructExpr |
| 340 |
visit_field ("struct_name", e.get_struct_name ()); |
| 341 |
|
| 342 |
// StructExprStruct |
| 343 |
do_mappings (e.get_mappings ()); |
| 344 |
do_inner_attrs (e); |
| 345 |
} |
| 346 |
|
| 347 |
void |
| 348 |
Dump::do_ifexpr (IfExpr &e) |
| 349 |
{ |
| 350 |
do_expr (e); |
| 351 |
visit_field ("condition", e.get_if_condition ()); |
| 352 |
visit_field ("if_block", e.get_if_block ()); |
| 353 |
} |
| 354 |
|
| 355 |
void |
| 356 |
Dump::do_expr (Expr &e) |
| 357 |
{ |
| 358 |
do_mappings (e.get_mappings ()); |
| 359 |
auto oa = e.get_outer_attrs (); |
| 360 |
do_outer_attrs (oa); |
| 361 |
} |
| 362 |
|
| 363 |
void |
| 364 |
Dump::do_matcharm (MatchArm &e) |
| 365 |
{ |
| 366 |
begin ("MatchArm"); |
| 367 |
// FIXME Can't remember how to handle that. Let's see later. |
| 368 |
// do_outer_attrs(e); |
| 369 |
visit_collection ("match_arm_patterns", e.get_patterns ()); |
| 370 |
if (e.has_match_arm_guard ()) |
| 371 |
visit_field ("guard_expr", e.get_guard_expr ()); |
| 372 |
end ("MatchArm"); |
| 373 |
} |
| 374 |
|
| 375 |
void |
| 376 |
Dump::do_matchcase (HIR::MatchCase &e) |
| 377 |
{ |
| 378 |
begin ("MatchCase"); |
| 379 |
|
| 380 |
begin_field ("arm"); |
| 381 |
do_matcharm (e.get_arm ()); |
| 382 |
end_field ("arm"); |
| 383 |
|
| 384 |
visit_field ("expr", e.get_expr ()); |
| 385 |
|
| 386 |
end ("MatchCase"); |
| 387 |
} |
| 388 |
|
| 389 |
void |
| 390 |
Dump::do_pathexpr (PathExpr &e) |
| 391 |
{ |
| 392 |
do_expr (e); |
| 393 |
} |
| 394 |
|
| 395 |
void |
| 396 |
Dump::do_typepathsegment (TypePathSegment &e) |
| 397 |
{ |
| 398 |
do_mappings (e.get_mappings ()); |
| 399 |
if (e.is_lang_item ()) |
| 400 |
put_field ("ident_segment", LangItem::PrettyString (e.get_lang_item ())); |
| 401 |
else |
| 402 |
put_field ("ident_segment", e.get_ident_segment ().as_string ()); |
| 403 |
} |
| 404 |
|
| 405 |
void |
| 406 |
Dump::do_typepathfunction (TypePathFunction &e) |
| 407 |
{ |
| 408 |
visit_collection ("params", e.get_params ()); |
| 409 |
visit_field ("return_type", e.get_return_type ()); |
| 410 |
} |
| 411 |
|
| 412 |
void |
| 413 |
Dump::do_qualifiedpathtype (QualifiedPathType &e) |
| 414 |
{ |
| 415 |
do_mappings (e.get_mappings ()); |
| 416 |
if (e.has_type ()) |
| 417 |
visit_field ("type", e.get_type ()); |
| 418 |
else |
| 419 |
put_field ("type", "none"); |
| 420 |
|
| 421 |
if (e.has_trait ()) |
| 422 |
visit_field ("trait", e.get_trait ()); |
| 423 |
} |
| 424 |
|
| 425 |
void |
| 426 |
Dump::do_operatorexpr (OperatorExpr &e) |
| 427 |
{ |
| 428 |
visit_field ("main_or_left_expr", e.get_expr ()); |
| 429 |
} |
| 430 |
|
| 431 |
void |
| 432 |
Dump::do_mappings (const Analysis::NodeMapping &mappings) |
| 433 |
{ |
| 434 |
put ("mapping: ", false); |
| 435 |
put (mappings.as_string ()); |
| 436 |
} |
| 437 |
|
| 438 |
void |
| 439 |
Dump::do_inner_attrs (WithInnerAttrs &e) |
| 440 |
{ |
| 441 |
auto attrs = e.get_inner_attrs (); |
| 442 |
|
| 443 |
if (attrs.empty ()) |
| 444 |
{ |
| 445 |
put_field ("inner_attrs", "empty"); |
| 446 |
return; |
| 447 |
} |
| 448 |
|
| 449 |
begin_field ("inner_attrs"); |
| 450 |
for (auto &elt : attrs) |
| 451 |
visit (elt); |
| 452 |
end_field ("inner_attrs"); |
| 453 |
} |
| 454 |
|
| 455 |
void |
| 456 |
Dump::do_outer_attrs (std::vector<AST::Attribute> &attrs) |
| 457 |
{ |
| 458 |
if (attrs.empty ()) |
| 459 |
put_field ("outer_attributes", "empty"); |
| 460 |
else |
| 461 |
{ |
| 462 |
begin_field ("outer_attributes"); |
| 463 |
for (const auto &attr : attrs) |
| 464 |
put (attr.as_string ()); |
| 465 |
end_field ("outer_attributes"); |
| 466 |
} |
| 467 |
} |
| 468 |
|
| 469 |
void |
| 470 |
Dump::do_baseloopexpr (BaseLoopExpr &e) |
| 471 |
{ |
| 472 |
do_expr (e); |
| 473 |
|
| 474 |
if (!e.has_loop_label ()) |
| 475 |
put_field ("label", "none"); |
| 476 |
else |
| 477 |
put_field ("label", e.get_loop_label ().as_string ()); |
| 478 |
|
| 479 |
visit_field ("loop_block", e.get_loop_block ()); |
| 480 |
} |
| 481 |
|
| 482 |
void |
| 483 |
Dump::do_struct (Struct &e) |
| 484 |
{ |
| 485 |
do_vis_item (e); |
| 486 |
put_field ("struct_name", e.get_identifier ().as_string ()); |
| 487 |
visit_collection ("generic_params", e.get_generic_params ()); |
| 488 |
|
| 489 |
if (!e.has_where_clause ()) |
| 490 |
put_field ("where_clause", "none"); |
| 491 |
else |
| 492 |
put_field ("where clause", e.get_where_clause ().as_string ()); |
| 493 |
} |
| 494 |
|
| 495 |
void |
| 496 |
Dump::do_enumitem (EnumItem &e) |
| 497 |
{ |
| 498 |
do_item (e); |
| 499 |
|
| 500 |
put_field ("variant_name", e.get_identifier ().as_string ()); |
| 501 |
|
| 502 |
std::string str; |
| 503 |
switch (e.get_enum_item_kind ()) |
| 504 |
{ |
| 505 |
case EnumItem::EnumItemKind::Named: |
| 506 |
str = "[Named variant]"; |
| 507 |
break; |
| 508 |
case EnumItem::EnumItemKind::Tuple: |
| 509 |
str = "[Tuple variant]"; |
| 510 |
break; |
| 511 |
case EnumItem::EnumItemKind::Struct: |
| 512 |
str = "[Struct variant]"; |
| 513 |
break; |
| 514 |
case EnumItem::EnumItemKind::Discriminant: |
| 515 |
str = "[Discriminant variant]"; |
| 516 |
break; |
| 517 |
} |
| 518 |
put_field ("item_kind", str); |
| 519 |
} |
| 520 |
|
| 521 |
void |
| 522 |
Dump::do_traitfunctiondecl (TraitFunctionDecl &e) |
| 523 |
{ |
| 524 |
begin ("TraitFunctionDecl"); |
| 525 |
put_field ("qualifiers", e.get_qualifiers ().as_string ()); |
| 526 |
put_field ("function_name", e.get_function_name ().as_string ()); |
| 527 |
visit_collection ("generic_params", e.get_generic_params ()); |
| 528 |
|
| 529 |
if (!e.get_function_params ().empty ()) |
| 530 |
{ |
| 531 |
begin_field ("function_params"); |
| 532 |
for (auto &item : e.get_function_params ()) |
| 533 |
do_functionparam (item); |
| 534 |
end_field ("function_params"); |
| 535 |
} |
| 536 |
else |
| 537 |
put_field ("function_params", "empty"); |
| 538 |
|
| 539 |
if (e.has_return_type ()) |
| 540 |
visit_field ("return_type", e.get_return_type ()); |
| 541 |
else |
| 542 |
put_field ("return_type", "none"); |
| 543 |
|
| 544 |
if (e.has_where_clause ()) |
| 545 |
put_field ("where_clause", e.get_where_clause ().as_string ()); |
| 546 |
else |
| 547 |
put_field ("where_clause", "none"); |
| 548 |
|
| 549 |
if (e.is_method ()) |
| 550 |
put_field ("self", e.get_self_unchecked ().as_string ()); |
| 551 |
|
| 552 |
end ("TraitFunctionDecl"); |
| 553 |
} |
| 554 |
|
| 555 |
void |
| 556 |
Dump::do_externalitem (ExternalItem &e) |
| 557 |
{ |
| 558 |
do_mappings (e.get_mappings ()); |
| 559 |
|
| 560 |
auto oa = e.get_outer_attrs (); |
| 561 |
do_outer_attrs (oa); |
| 562 |
|
| 563 |
std::string str = "none"; |
| 564 |
if (e.has_visibility ()) |
| 565 |
str = e.get_visibility ().as_string (); |
| 566 |
put_field ("visibility", str); |
| 567 |
put_field ("item_name", e.get_item_name ().as_string ()); |
| 568 |
} |
| 569 |
|
| 570 |
void |
| 571 |
Dump::do_namefunctionparam (NamedFunctionParam &e) |
| 572 |
{ |
| 573 |
begin ("NamedFunctionParam"); |
| 574 |
do_mappings (e.get_mappings ()); |
| 575 |
put_field ("name", e.get_param_name ().as_string ()); |
| 576 |
visit_field ("type", e.get_type ()); |
| 577 |
end ("NamedFunctionParam"); |
| 578 |
} |
| 579 |
|
| 580 |
void |
| 581 |
Dump::do_stmt (Stmt &e) |
| 582 |
{ |
| 583 |
do_mappings (e.get_mappings ()); |
| 584 |
} |
| 585 |
|
| 586 |
void |
| 587 |
Dump::do_type (Type &e) |
| 588 |
{ |
| 589 |
do_mappings (e.get_mappings ()); |
| 590 |
} |
| 591 |
|
| 592 |
void |
| 593 |
Dump::do_item (Item &e) |
| 594 |
{ |
| 595 |
do_stmt (e); |
| 596 |
auto oa = e.get_outer_attrs (); |
| 597 |
do_outer_attrs (oa); |
| 598 |
} |
| 599 |
|
| 600 |
void |
| 601 |
Dump::do_tuplefield (TupleField &e) |
| 602 |
{ |
| 603 |
do_mappings (e.get_mappings ()); |
| 604 |
auto oa = e.get_outer_attrs (); |
| 605 |
do_outer_attrs (oa); |
| 606 |
|
| 607 |
std::string str = "none"; |
| 608 |
if (e.has_visibility ()) |
| 609 |
str = e.get_visibility ().as_string (); |
| 610 |
put_field ("visibility", str); |
| 611 |
|
| 612 |
visit_field ("field_type", e.get_field_type ()); |
| 613 |
} |
| 614 |
|
| 615 |
void |
| 616 |
Dump::do_structfield (StructField &e) |
| 617 |
{ |
| 618 |
do_mappings (e.get_mappings ()); |
| 619 |
auto oa = e.get_outer_attrs (); |
| 620 |
do_outer_attrs (oa); |
| 621 |
|
| 622 |
std::string str = "none"; |
| 623 |
if (e.has_visibility ()) |
| 624 |
str = e.get_visibility ().as_string (); |
| 625 |
put_field ("visibility", str); |
| 626 |
put_field ("field_name", e.get_field_name ().as_string ()); |
| 627 |
visit_field ("field_type", e.get_field_type ()); |
| 628 |
} |
| 629 |
|
| 630 |
void |
| 631 |
Dump::do_genericargs (GenericArgs &e) |
| 632 |
{ |
| 633 |
visit_collection ("lifetime_args", e.get_lifetime_args ()); |
| 634 |
visit_collection ("type_args", e.get_type_args ()); |
| 635 |
|
| 636 |
if (e.get_const_args ().empty ()) |
| 637 |
{ |
| 638 |
put_field ("binding_args", "empty"); |
| 639 |
} |
| 640 |
else |
| 641 |
{ |
| 642 |
begin_field ("const_args"); |
| 643 |
for (auto &arg : e.get_const_args ()) |
| 644 |
{ |
| 645 |
begin ("ConstGenericArg"); |
| 646 |
visit_field ("expression", arg.get_expression ()); |
| 647 |
end ("ConstGenericArg"); |
| 648 |
} |
| 649 |
end_field ("const_args"); |
| 650 |
} |
| 651 |
|
| 652 |
if (e.get_binding_args ().empty ()) |
| 653 |
{ |
| 654 |
put_field ("binding_args", "empty"); |
| 655 |
} |
| 656 |
else |
| 657 |
{ |
| 658 |
begin_field ("binding_args"); |
| 659 |
for (auto &arg : e.get_binding_args ()) |
| 660 |
{ |
| 661 |
begin ("GenericArgsBinding"); |
| 662 |
put_field ("identfier", arg.get_identifier ().as_string ()); |
| 663 |
visit_field ("type", arg.get_type ()); |
| 664 |
end ("GenericArgsBinding"); |
| 665 |
} |
| 666 |
end_field ("binding_args"); |
| 667 |
} |
| 668 |
} |
| 669 |
|
| 670 |
void |
| 671 |
Dump::do_maybenamedparam (MaybeNamedParam &e) |
| 672 |
{ |
| 673 |
visit_field ("param_type", e.get_type ()); |
| 674 |
put_field ("param_kind", enum_to_str (e.get_param_kind ())); |
| 675 |
put_field ("name", e.get_name ().as_string ()); |
| 676 |
} |
| 677 |
|
| 678 |
// All visit methods |
| 679 |
|
| 680 |
void |
| 681 |
Dump::visit (AST::Attribute &attribute) |
| 682 |
{ |
| 683 |
// Special, no begin/end as this is called by do_inner_attrs. |
| 684 |
put_field (Values::Attributes::PATH, attribute.get_path ().as_string ()); |
| 685 |
|
| 686 |
std::string str = "none"; |
| 687 |
if (attribute.has_attr_input ()) |
| 688 |
str = attribute.get_attr_input ().as_string (); |
| 689 |
put_field ("attr_input", str); |
| 690 |
} |
| 691 |
|
| 692 |
void |
| 693 |
Dump::visit (Lifetime &e) |
| 694 |
{ |
| 695 |
do_mappings (e.get_mappings ()); |
| 696 |
|
| 697 |
std::string type; |
| 698 |
std::string name = e.get_name (); |
| 699 |
switch (e.get_lifetime_type ()) |
| 700 |
{ |
| 701 |
case AST::Lifetime::LifetimeType::NAMED: |
| 702 |
type = "[NAMED]"; |
| 703 |
break; |
| 704 |
case AST::Lifetime::LifetimeType::STATIC: |
| 705 |
type = "[STATIC]"; |
| 706 |
name += " (not applicable for type)"; |
| 707 |
break; |
| 708 |
case AST::Lifetime::LifetimeType::WILDCARD: |
| 709 |
type = "[WILDCARD]"; |
| 710 |
name += " (not applicable for type)"; |
| 711 |
break; |
| 712 |
default: |
| 713 |
rust_assert (false); |
| 714 |
break; |
| 715 |
} |
| 716 |
put_field ("lifetime_type", type); |
| 717 |
put_field ("lifetime_name", name); |
| 718 |
} |
| 719 |
|
| 720 |
void |
| 721 |
Dump::visit (LifetimeParam &lifetimeparam) |
| 722 |
{ |
| 723 |
begin ("Lifetimeparam"); |
| 724 |
put (lifetimeparam.as_string ()); |
| 725 |
end ("Lifetimeparam"); |
| 726 |
} |
| 727 |
|
| 728 |
void |
| 729 |
Dump::visit (PathInExpression &e) |
| 730 |
{ |
| 731 |
begin ("PathInExpression"); |
| 732 |
do_pathpattern (e); |
| 733 |
do_pathexpr (e); |
| 734 |
|
| 735 |
put_field ("has_opening_scope_resolution", |
| 736 |
std::to_string (e.opening_scope_resolution ())); |
| 737 |
end ("PathInExpression"); |
| 738 |
} |
| 739 |
|
| 740 |
void |
| 741 |
Dump::visit (TypePathSegment &e) |
| 742 |
{ |
| 743 |
begin ("TypePathSegment"); |
| 744 |
do_typepathsegment (e); |
| 745 |
end ("TypePathSegment"); |
| 746 |
} |
| 747 |
|
| 748 |
void |
| 749 |
Dump::visit (TypePathSegmentGeneric &e) |
| 750 |
{ |
| 751 |
begin ("TypePathSegmentGeneric"); |
| 752 |
do_typepathsegment (e); |
| 753 |
|
| 754 |
if (e.has_generic_args ()) |
| 755 |
{ |
| 756 |
begin_field ("generic_args"); |
| 757 |
begin ("GenericArgs"); |
| 758 |
do_genericargs (e.get_generic_args ()); |
| 759 |
end ("GenericArgs"); |
| 760 |
end_field ("generic_args"); |
| 761 |
} |
| 762 |
else |
| 763 |
{ |
| 764 |
put_field ("generic_args", "empty"); |
| 765 |
} |
| 766 |
|
| 767 |
end ("TypePathSegmentGeneric"); |
| 768 |
} |
| 769 |
|
| 770 |
void |
| 771 |
Dump::visit (TypePathSegmentFunction &e) |
| 772 |
{ |
| 773 |
begin ("TypePathSegmentFunction"); |
| 774 |
do_typepathsegment (e); |
| 775 |
|
| 776 |
begin ("function_path"); |
| 777 |
do_typepathfunction (e.get_function_path ()); |
| 778 |
end ("function_path"); |
| 779 |
|
| 780 |
end ("TypePathSegmentFunction"); |
| 781 |
} |
| 782 |
|
| 783 |
void |
| 784 |
Dump::visit (TypePath &e) |
| 785 |
{ |
| 786 |
begin ("TypePath"); |
| 787 |
put_field ("has_opening_scope_resolution", |
| 788 |
std::to_string (e.has_opening_scope_resolution_op ())); |
| 789 |
|
| 790 |
visit_collection ("segments", e.get_segments ()); |
| 791 |
|
| 792 |
end ("TypePath"); |
| 793 |
} |
| 794 |
|
| 795 |
void |
| 796 |
Dump::visit (QualifiedPathInExpression &e) |
| 797 |
{ |
| 798 |
begin ("QualifiedPathInExpression"); |
| 799 |
do_pathpattern (e); |
| 800 |
do_expr (e); |
| 801 |
|
| 802 |
begin_field ("path_type"); |
| 803 |
|
| 804 |
begin ("QualifiedPathType"); |
| 805 |
do_qualifiedpathtype (e.get_path_type ()); |
| 806 |
end ("QualifiedPathType"); |
| 807 |
|
| 808 |
end_field ("path_type"); |
| 809 |
|
| 810 |
end ("QualifiedPathInExpression"); |
| 811 |
} |
| 812 |
|
| 813 |
void |
| 814 |
Dump::visit (QualifiedPathInType &e) |
| 815 |
{ |
| 816 |
begin ("QualifiedPathInType"); |
| 817 |
|
| 818 |
begin_field ("path_type"); |
| 819 |
do_qualifiedpathtype (e.get_path_type ()); |
| 820 |
end_field ("path_type"); |
| 821 |
|
| 822 |
begin_field ("associated_segment"); |
| 823 |
do_typepathsegment (e.get_associated_segment ()); |
| 824 |
end_field ("associated_segment"); |
| 825 |
|
| 826 |
visit_collection ("segments", e.get_segments ()); |
| 827 |
|
| 828 |
end ("QualifiedPathInType"); |
| 829 |
} |
| 830 |
|
| 831 |
void |
| 832 |
Dump::visit (LiteralExpr &e) |
| 833 |
{ |
| 834 |
begin ("LiteralExpr"); |
| 835 |
do_expr (e); |
| 836 |
put_field ("literal", e.get_literal ().as_string ()); |
| 837 |
end ("LiteralExpr"); |
| 838 |
} |
| 839 |
|
| 840 |
void |
| 841 |
Dump::visit (BorrowExpr &e) |
| 842 |
{ |
| 843 |
begin ("BorrowExpr"); |
| 844 |
do_operatorexpr (e); |
| 845 |
|
| 846 |
put_field ("mut", enum_to_str (e.get_mut ())); |
| 847 |
|
| 848 |
end ("BorrowExpr"); |
| 849 |
} |
| 850 |
|
| 851 |
void |
| 852 |
Dump::visit (DereferenceExpr &e) |
| 853 |
{ |
| 854 |
begin ("DereferenceExpr"); |
| 855 |
do_operatorexpr (e); |
| 856 |
end ("DereferenceExpr"); |
| 857 |
} |
| 858 |
|
| 859 |
void |
| 860 |
Dump::visit (ErrorPropagationExpr &e) |
| 861 |
{ |
| 862 |
begin ("ErrorPropagationExpr"); |
| 863 |
do_operatorexpr (e); |
| 864 |
end ("ErrorPropagationExpr"); |
| 865 |
} |
| 866 |
|
| 867 |
void |
| 868 |
Dump::visit (NegationExpr &e) |
| 869 |
{ |
| 870 |
begin ("NegationExpr"); |
| 871 |
do_operatorexpr (e); |
| 872 |
std::string str; |
| 873 |
switch (e.get_expr_type ()) |
| 874 |
{ |
| 875 |
case NegationOperator::NEGATE: |
| 876 |
str = "[NEGATE]"; |
| 877 |
break; |
| 878 |
case NegationOperator::NOT: |
| 879 |
str = "[NOT]"; |
| 880 |
break; |
| 881 |
default: |
| 882 |
rust_assert (false); |
| 883 |
} |
| 884 |
put_field ("expr_type", str); |
| 885 |
|
| 886 |
end ("NegationExpr"); |
| 887 |
} |
| 888 |
|
| 889 |
void |
| 890 |
Dump::visit (ArithmeticOrLogicalExpr &e) |
| 891 |
{ |
| 892 |
begin ("ArithmeticOrLogicalExpr"); |
| 893 |
std::string str; |
| 894 |
|
| 895 |
// which operator |
| 896 |
switch (e.get_expr_type ()) |
| 897 |
{ |
| 898 |
case ArithmeticOrLogicalOperator::ADD: |
| 899 |
str = "[ADD]"; |
| 900 |
break; |
| 901 |
case ArithmeticOrLogicalOperator::SUBTRACT: |
| 902 |
str = "SUBTRACT"; |
| 903 |
break; |
| 904 |
case ArithmeticOrLogicalOperator::MULTIPLY: |
| 905 |
str = "MULTIPLY"; |
| 906 |
break; |
| 907 |
case ArithmeticOrLogicalOperator::DIVIDE: |
| 908 |
str = "DIVIDE"; |
| 909 |
break; |
| 910 |
case ArithmeticOrLogicalOperator::MODULUS: |
| 911 |
str = "MODULUS"; |
| 912 |
break; |
| 913 |
case ArithmeticOrLogicalOperator::BITWISE_AND: |
| 914 |
str = "BITWISE"; |
| 915 |
break; |
| 916 |
case ArithmeticOrLogicalOperator::BITWISE_OR: |
| 917 |
str = "BITWISE"; |
| 918 |
break; |
| 919 |
case ArithmeticOrLogicalOperator::BITWISE_XOR: |
| 920 |
str = "BITWISE"; |
| 921 |
break; |
| 922 |
case ArithmeticOrLogicalOperator::LEFT_SHIFT: |
| 923 |
str = "<LEFT"; |
| 924 |
break; |
| 925 |
case ArithmeticOrLogicalOperator::RIGHT_SHIFT: |
| 926 |
str = ">RIGHT"; |
| 927 |
break; |
| 928 |
default: |
| 929 |
rust_unreachable (); |
| 930 |
break; |
| 931 |
} |
| 932 |
put_field ("expr_type", str); |
| 933 |
do_operatorexpr (e); |
| 934 |
visit_field ("right_expr", e.get_rhs ()); |
| 935 |
|
| 936 |
end ("ArithmeticOrLogicalExpr"); |
| 937 |
} |
| 938 |
|
| 939 |
void |
| 940 |
Dump::visit (ComparisonExpr &e) |
| 941 |
{ |
| 942 |
begin ("ComparisonExpr"); |
| 943 |
std::string str; |
| 944 |
switch (e.get_expr_type ()) |
| 945 |
{ |
| 946 |
case ComparisonOperator::EQUAL: |
| 947 |
str = "EQUAL"; |
| 948 |
break; |
| 949 |
case ComparisonOperator::NOT_EQUAL: |
| 950 |
str = "NOT_EQUAL"; |
| 951 |
break; |
| 952 |
case ComparisonOperator::GREATER_THAN: |
| 953 |
str = "GREATER_THAN"; |
| 954 |
break; |
| 955 |
case ComparisonOperator::LESS_THAN: |
| 956 |
str = "LESS_THAN"; |
| 957 |
break; |
| 958 |
case ComparisonOperator::GREATER_OR_EQUAL: |
| 959 |
str = "GREATER_OR_EQUAL"; |
| 960 |
break; |
| 961 |
case ComparisonOperator::LESS_OR_EQUAL: |
| 962 |
str = "LESS_OR_EQUAL"; |
| 963 |
break; |
| 964 |
default: |
| 965 |
rust_assert (false); |
| 966 |
} |
| 967 |
put_field ("expr_type", str); |
| 968 |
do_operatorexpr (e); |
| 969 |
visit_field ("right_expr", e.get_rhs ()); |
| 970 |
end ("ComparisonExpr"); |
| 971 |
} |
| 972 |
|
| 973 |
void |
| 974 |
Dump::visit (LazyBooleanExpr &e) |
| 975 |
{ |
| 976 |
begin ("LazyBooleanExpr"); |
| 977 |
|
| 978 |
std::string str; |
| 979 |
switch (e.get_expr_type ()) |
| 980 |
{ |
| 981 |
case LazyBooleanOperator::LOGICAL_OR: |
| 982 |
str = "LOGICAL_OR"; |
| 983 |
break; |
| 984 |
case LazyBooleanOperator::LOGICAL_AND: |
| 985 |
str = "LOGICAL_AND"; |
| 986 |
break; |
| 987 |
default: |
| 988 |
rust_assert (false); |
| 989 |
} |
| 990 |
|
| 991 |
do_operatorexpr (e); |
| 992 |
visit_field ("right_expr", e.get_rhs ()); |
| 993 |
end ("LazyBooleanExpr"); |
| 994 |
} |
| 995 |
|
| 996 |
void |
| 997 |
Dump::visit (TypeCastExpr &e) |
| 998 |
{ |
| 999 |
begin ("TypeCastExpr"); |
| 1000 |
do_operatorexpr (e); |
| 1001 |
visit_field ("type_to_convert_to", e.get_type_to_convert_to ()); |
| 1002 |
end ("TypeCastExpr"); |
| 1003 |
} |
| 1004 |
|
| 1005 |
void |
| 1006 |
Dump::visit (AssignmentExpr &e) |
| 1007 |
{ |
| 1008 |
begin ("AssignmentExpr"); |
| 1009 |
do_operatorexpr (e); |
| 1010 |
visit_field ("right_expr", e.get_rhs ()); |
| 1011 |
end ("AssignmentExpr"); |
| 1012 |
} |
| 1013 |
|
| 1014 |
void |
| 1015 |
Dump::visit (CompoundAssignmentExpr &e) |
| 1016 |
{ |
| 1017 |
begin ("CompoundAssignmentExpr"); |
| 1018 |
|
| 1019 |
do_operatorexpr (e); |
| 1020 |
visit_field ("right_expr", e.get_rhs ()); |
| 1021 |
|
| 1022 |
std::string str; |
| 1023 |
|
| 1024 |
// get operator string |
| 1025 |
switch (e.get_expr_type ()) |
| 1026 |
{ |
| 1027 |
case ArithmeticOrLogicalOperator::ADD: |
| 1028 |
str = "ADD"; |
| 1029 |
break; |
| 1030 |
case ArithmeticOrLogicalOperator::SUBTRACT: |
| 1031 |
str = "SUBTRACT"; |
| 1032 |
break; |
| 1033 |
case ArithmeticOrLogicalOperator::MULTIPLY: |
| 1034 |
str = "MULTIPLY"; |
| 1035 |
break; |
| 1036 |
case ArithmeticOrLogicalOperator::DIVIDE: |
| 1037 |
str = "DIVIDE"; |
| 1038 |
break; |
| 1039 |
case ArithmeticOrLogicalOperator::MODULUS: |
| 1040 |
str = "MODULUS"; |
| 1041 |
break; |
| 1042 |
case ArithmeticOrLogicalOperator::BITWISE_AND: |
| 1043 |
str = "BITWISE_AND"; |
| 1044 |
break; |
| 1045 |
case ArithmeticOrLogicalOperator::BITWISE_OR: |
| 1046 |
str = "BITWISE_OR"; |
| 1047 |
break; |
| 1048 |
case ArithmeticOrLogicalOperator::BITWISE_XOR: |
| 1049 |
str = "BITWISE_XOR"; |
| 1050 |
break; |
| 1051 |
case ArithmeticOrLogicalOperator::LEFT_SHIFT: |
| 1052 |
str = "LEFT_SHIFT"; |
| 1053 |
break; |
| 1054 |
case ArithmeticOrLogicalOperator::RIGHT_SHIFT: |
| 1055 |
str = "RIGHT_SHIFT"; |
| 1056 |
break; |
| 1057 |
default: |
| 1058 |
gcc_unreachable (); |
| 1059 |
break; |
| 1060 |
} |
| 1061 |
put_field ("expr_type", str); |
| 1062 |
end ("CompoundAssignmentExpr"); |
| 1063 |
} |
| 1064 |
|
| 1065 |
void |
| 1066 |
Dump::visit (GroupedExpr &e) |
| 1067 |
{ |
| 1068 |
begin ("GroupedExpr"); |
| 1069 |
do_expr (e); |
| 1070 |
do_inner_attrs (e); |
| 1071 |
|
| 1072 |
visit_field ("expr_in_parens", e.get_expr_in_parens ()); |
| 1073 |
|
| 1074 |
end ("GroupedExpr"); |
| 1075 |
} |
| 1076 |
|
| 1077 |
void |
| 1078 |
Dump::visit (ArrayElemsValues &e) |
| 1079 |
{ |
| 1080 |
begin ("ArrayElemsValues"); |
| 1081 |
do_mappings (e.get_mappings ()); |
| 1082 |
|
| 1083 |
visit_collection ("values", e.get_values ()); |
| 1084 |
end ("ArrayElemsValues"); |
| 1085 |
} |
| 1086 |
|
| 1087 |
void |
| 1088 |
Dump::visit (ArrayElemsCopied &e) |
| 1089 |
{ |
| 1090 |
begin ("ArrayElemsCopied"); |
| 1091 |
do_mappings (e.get_mappings ()); |
| 1092 |
|
| 1093 |
visit_field ("copied_elem", e.get_elem_to_copy ()); |
| 1094 |
visit_field ("num_copies", e.get_num_copies_expr ()); |
| 1095 |
|
| 1096 |
end ("ArrayElemsCopied"); |
| 1097 |
} |
| 1098 |
|
| 1099 |
void |
| 1100 |
Dump::visit (ArrayExpr &e) |
| 1101 |
{ |
| 1102 |
begin ("ArrayExpr"); |
| 1103 |
do_expr (e); |
| 1104 |
do_inner_attrs (e); |
| 1105 |
|
| 1106 |
visit_field ("internal_elements", e.get_internal_elements ()); |
| 1107 |
|
| 1108 |
end ("ArrayExpr"); |
| 1109 |
} |
| 1110 |
|
| 1111 |
void |
| 1112 |
Dump::visit (ArrayIndexExpr &e) |
| 1113 |
{ |
| 1114 |
begin ("ArrayIndexExpr"); |
| 1115 |
do_expr (e); |
| 1116 |
|
| 1117 |
visit_field ("array_expr", e.get_array_expr ()); |
| 1118 |
visit_field ("index_expr", e.get_index_expr ()); |
| 1119 |
end ("ArrayIndexExpr"); |
| 1120 |
} |
| 1121 |
|
| 1122 |
void |
| 1123 |
Dump::visit (TupleExpr &e) |
| 1124 |
{ |
| 1125 |
begin ("TupleExpr"); |
| 1126 |
do_expr (e); |
| 1127 |
do_inner_attrs (e); |
| 1128 |
|
| 1129 |
visit_collection ("tuple_elems", e.get_tuple_elems ()); |
| 1130 |
|
| 1131 |
end ("TupleExpr"); |
| 1132 |
} |
| 1133 |
|
| 1134 |
void |
| 1135 |
Dump::visit (TupleIndexExpr &e) |
| 1136 |
{ |
| 1137 |
begin ("TupleIndexExpr"); |
| 1138 |
do_expr (e); |
| 1139 |
visit_field ("tuple_expr", e.get_tuple_expr ()); |
| 1140 |
put_field ("tuple_index", std::to_string (e.get_tuple_index ())); |
| 1141 |
end ("TupleIndexExpr"); |
| 1142 |
} |
| 1143 |
|
| 1144 |
void |
| 1145 |
Dump::visit (StructExprStruct &e) |
| 1146 |
{ |
| 1147 |
begin ("StructExprStruct"); |
| 1148 |
do_structexprstruct (e); |
| 1149 |
end ("StructExprStruct"); |
| 1150 |
} |
| 1151 |
|
| 1152 |
void |
| 1153 |
Dump::visit (StructExprFieldIdentifier &e) |
| 1154 |
{ |
| 1155 |
begin ("StructExprFieldIdentifier"); |
| 1156 |
do_mappings (e.get_mappings ()); |
| 1157 |
|
| 1158 |
put_field ("field_name", e.get_field_name ().as_string ()); |
| 1159 |
end ("StructExprFieldIdentifier"); |
| 1160 |
} |
| 1161 |
|
| 1162 |
void |
| 1163 |
Dump::visit (StructExprFieldIdentifierValue &e) |
| 1164 |
{ |
| 1165 |
begin ("StructExprFieldIdentifierValue"); |
| 1166 |
do_mappings (e.get_mappings ()); |
| 1167 |
|
| 1168 |
visit_field ("value", e.get_value ()); |
| 1169 |
end ("StructExprFieldIdentifierValue"); |
| 1170 |
} |
| 1171 |
|
| 1172 |
void |
| 1173 |
Dump::visit (StructExprFieldIndexValue &e) |
| 1174 |
{ |
| 1175 |
begin ("StructExprFieldIndexValue"); |
| 1176 |
do_mappings (e.get_mappings ()); |
| 1177 |
|
| 1178 |
put_field ("index", std::to_string (e.get_tuple_index ())); |
| 1179 |
visit_field ("value", e.get_value ()); |
| 1180 |
end ("StructExprFieldIndexValue"); |
| 1181 |
} |
| 1182 |
|
| 1183 |
void |
| 1184 |
Dump::visit (StructExprStructFields &e) |
| 1185 |
{ |
| 1186 |
begin ("StructExprStructFields"); |
| 1187 |
do_structexprstruct (e); |
| 1188 |
|
| 1189 |
visit_collection ("fields", e.get_fields ()); |
| 1190 |
|
| 1191 |
if (!e.has_struct_base ()) |
| 1192 |
put_field ("struct_base", "none"); |
| 1193 |
else |
| 1194 |
put_field ("struct_base", e.get_struct_base ().as_string ()); |
| 1195 |
|
| 1196 |
end ("StructExprStructFields"); |
| 1197 |
} |
| 1198 |
|
| 1199 |
void |
| 1200 |
Dump::visit (StructExprStructBase &e) |
| 1201 |
{ |
| 1202 |
begin ("StructExprStructBase"); |
| 1203 |
do_structexprstruct (e); |
| 1204 |
|
| 1205 |
put_field ("struct_base", e.get_struct_base ().as_string ()); |
| 1206 |
|
| 1207 |
end ("StructExprStructBase"); |
| 1208 |
} |
| 1209 |
|
| 1210 |
void |
| 1211 |
Dump::visit (CallExpr &e) |
| 1212 |
{ |
| 1213 |
begin ("CallExpr"); |
| 1214 |
do_expr (e); |
| 1215 |
visit_field ("function", e.get_fnexpr ()); |
| 1216 |
|
| 1217 |
visit_collection ("params", e.get_arguments ()); |
| 1218 |
|
| 1219 |
end ("CallExpr"); |
| 1220 |
} |
| 1221 |
|
| 1222 |
void |
| 1223 |
Dump::visit (MethodCallExpr &e) |
| 1224 |
{ |
| 1225 |
begin ("MethodCallExpr"); |
| 1226 |
do_expr (e); |
| 1227 |
|
| 1228 |
visit_field ("receiver", e.get_receiver ()); |
| 1229 |
put_field ("method_name", e.get_method_name ().as_string ()); |
| 1230 |
visit_collection ("params", e.get_arguments ()); |
| 1231 |
|
| 1232 |
end ("MethodCallExpr"); |
| 1233 |
} |
| 1234 |
|
| 1235 |
void |
| 1236 |
Dump::visit (FieldAccessExpr &e) |
| 1237 |
{ |
| 1238 |
begin ("FieldAccessExpr"); |
| 1239 |
do_expr (e); |
| 1240 |
visit_field ("receiver", e.get_receiver_expr ()); |
| 1241 |
put_field ("field", e.get_field_name ().as_string ()); |
| 1242 |
end ("FieldAccessExpr"); |
| 1243 |
} |
| 1244 |
|
| 1245 |
void |
| 1246 |
Dump::visit (ClosureExpr &e) |
| 1247 |
{ |
| 1248 |
begin ("ClosureExpr"); |
| 1249 |
do_expr (e); |
| 1250 |
|
| 1251 |
if (!e.has_params ()) |
| 1252 |
{ |
| 1253 |
put_field ("params", "none"); |
| 1254 |
} |
| 1255 |
else |
| 1256 |
{ |
| 1257 |
begin_field ("params"); |
| 1258 |
for (auto ¶m : e.get_params ()) |
| 1259 |
{ |
| 1260 |
begin ("ClosureParam"); |
| 1261 |
auto oa = param.get_outer_attrs (); |
| 1262 |
do_outer_attrs (oa); |
| 1263 |
visit_field ("pattern", param.get_pattern ()); |
| 1264 |
|
| 1265 |
if (param.has_type_given ()) |
| 1266 |
visit_field ("type", param.get_type ()); |
| 1267 |
|
| 1268 |
end ("ClosureParam"); |
| 1269 |
} |
| 1270 |
end_field ("params"); |
| 1271 |
} |
| 1272 |
|
| 1273 |
if (e.has_return_type ()) |
| 1274 |
visit_field ("return_type", e.get_return_type ()); |
| 1275 |
|
| 1276 |
visit_field ("expr", e.get_expr ()); |
| 1277 |
end ("ClosureExpr"); |
| 1278 |
} |
| 1279 |
|
| 1280 |
void |
| 1281 |
Dump::visit (BlockExpr &e) |
| 1282 |
{ |
| 1283 |
begin ("BlockExpr"); |
| 1284 |
do_expr (e); |
| 1285 |
do_inner_attrs (e); |
| 1286 |
put_field ("tail_reachable", std::to_string (e.is_tail_reachable ())); |
| 1287 |
put_field ("label", e.get_label ().as_string ()); |
| 1288 |
|
| 1289 |
visit_collection ("statements", e.get_statements ()); |
| 1290 |
|
| 1291 |
if (e.has_final_expr ()) |
| 1292 |
visit_field ("expr", e.get_final_expr ()); |
| 1293 |
|
| 1294 |
end ("BlockExpr"); |
| 1295 |
} |
| 1296 |
|
| 1297 |
void |
| 1298 |
Dump::visit (ContinueExpr &e) |
| 1299 |
{ |
| 1300 |
begin ("ContinueExpr"); |
| 1301 |
|
| 1302 |
if (e.has_label ()) |
| 1303 |
put_field ("label", e.get_label ().as_string ()); |
| 1304 |
else |
| 1305 |
put_field ("label", "none"); |
| 1306 |
|
| 1307 |
end ("ContinueExpr"); |
| 1308 |
} |
| 1309 |
|
| 1310 |
void |
| 1311 |
Dump::visit (BreakExpr &e) |
| 1312 |
{ |
| 1313 |
begin ("BreakExpr"); |
| 1314 |
std::string str ("break "); |
| 1315 |
|
| 1316 |
if (e.has_label ()) |
| 1317 |
put_field ("label", e.get_label ().as_string ()); |
| 1318 |
else |
| 1319 |
put_field ("label", "none"); |
| 1320 |
|
| 1321 |
if (e.has_break_expr ()) |
| 1322 |
visit_field ("break_expr ", e.get_expr ()); |
| 1323 |
else |
| 1324 |
put_field ("break_expr", "none"); |
| 1325 |
|
| 1326 |
end ("BreakExpr"); |
| 1327 |
} |
| 1328 |
|
| 1329 |
void |
| 1330 |
Dump::visit (RangeFromToExpr &e) |
| 1331 |
{ |
| 1332 |
begin ("RangeFromToExpr"); |
| 1333 |
|
| 1334 |
visit_field ("from", e.get_from_expr ()); |
| 1335 |
visit_field ("to", e.get_to_expr ()); |
| 1336 |
|
| 1337 |
end ("RangeFromToExpr"); |
| 1338 |
} |
| 1339 |
|
| 1340 |
void |
| 1341 |
Dump::visit (RangeFromExpr &e) |
| 1342 |
{ |
| 1343 |
begin ("RangeFromExpr"); |
| 1344 |
|
| 1345 |
visit_field ("from", e.get_from_expr ()); |
| 1346 |
|
| 1347 |
end ("RangeFromExpr"); |
| 1348 |
} |
| 1349 |
|
| 1350 |
void |
| 1351 |
Dump::visit (RangeToExpr &e) |
| 1352 |
{ |
| 1353 |
begin ("RangeToExpr"); |
| 1354 |
|
| 1355 |
visit_field ("to", e.get_to_expr ()); |
| 1356 |
|
| 1357 |
end ("RangeToExpr"); |
| 1358 |
} |
| 1359 |
|
| 1360 |
void |
| 1361 |
Dump::visit (RangeFullExpr &e) |
| 1362 |
{ |
| 1363 |
begin ("RangeFullExpr"); |
| 1364 |
end ("RangeFullExpr"); |
| 1365 |
} |
| 1366 |
|
| 1367 |
void |
| 1368 |
Dump::visit (RangeFromToInclExpr &e) |
| 1369 |
{ |
| 1370 |
begin ("RangeFromToInclExpr"); |
| 1371 |
|
| 1372 |
visit_field ("from", e.get_from_expr ()); |
| 1373 |
visit_field ("to", e.get_to_expr ()); |
| 1374 |
|
| 1375 |
end ("RangeFromToInclExpr"); |
| 1376 |
} |
| 1377 |
|
| 1378 |
void |
| 1379 |
Dump::visit (RangeToInclExpr &e) |
| 1380 |
{ |
| 1381 |
begin ("RangeToInclExpr"); |
| 1382 |
|
| 1383 |
visit_field ("to", e.get_to_expr ()); |
| 1384 |
|
| 1385 |
end ("RangeToInclExpr"); |
| 1386 |
} |
| 1387 |
|
| 1388 |
void |
| 1389 |
Dump::visit (ReturnExpr &e) |
| 1390 |
{ |
| 1391 |
begin ("ReturnExpr"); |
| 1392 |
do_mappings (e.get_mappings ()); |
| 1393 |
|
| 1394 |
if (e.has_return_expr ()) |
| 1395 |
visit_field ("return_expr", e.get_expr ()); |
| 1396 |
|
| 1397 |
end ("ReturnExpr"); |
| 1398 |
} |
| 1399 |
|
| 1400 |
void |
| 1401 |
Dump::visit (UnsafeBlockExpr &e) |
| 1402 |
{ |
| 1403 |
begin ("UnsafeBlockExpr"); |
| 1404 |
auto oa = e.get_outer_attrs (); |
| 1405 |
do_outer_attrs (oa); |
| 1406 |
|
| 1407 |
visit_field ("block_expr", e.get_block_expr ()); |
| 1408 |
|
| 1409 |
end ("UnsafeBlockExpr"); |
| 1410 |
} |
| 1411 |
|
| 1412 |
void |
| 1413 |
Dump::visit (LoopExpr &e) |
| 1414 |
{ |
| 1415 |
begin ("LoopExpr"); |
| 1416 |
do_baseloopexpr (e); |
| 1417 |
end ("LoopExpr"); |
| 1418 |
} |
| 1419 |
|
| 1420 |
void |
| 1421 |
Dump::visit (WhileLoopExpr &e) |
| 1422 |
{ |
| 1423 |
begin ("WhileLoopExpr"); |
| 1424 |
do_baseloopexpr (e); |
| 1425 |
|
| 1426 |
visit_field ("condition", e.get_predicate_expr ()); |
| 1427 |
|
| 1428 |
end ("WhileLoopExpr"); |
| 1429 |
} |
| 1430 |
|
| 1431 |
void |
| 1432 |
Dump::visit (WhileLetLoopExpr &e) |
| 1433 |
{ |
| 1434 |
begin ("WhileLetLoopExpr"); |
| 1435 |
do_baseloopexpr (e); |
| 1436 |
|
| 1437 |
visit_collection ("match_arm_patterns", e.get_patterns ()); |
| 1438 |
|
| 1439 |
visit_field ("condition", e.get_cond ()); |
| 1440 |
|
| 1441 |
end ("WhileLetLoopExpr"); |
| 1442 |
} |
| 1443 |
|
| 1444 |
void |
| 1445 |
Dump::visit (IfExpr &e) |
| 1446 |
{ |
| 1447 |
begin ("IfExpr"); |
| 1448 |
do_ifexpr (e); |
| 1449 |
end ("IfExpr"); |
| 1450 |
} |
| 1451 |
|
| 1452 |
void |
| 1453 |
Dump::visit (IfExprConseqElse &e) |
| 1454 |
{ |
| 1455 |
begin ("IfExprConseqElse"); |
| 1456 |
do_ifexpr (e); |
| 1457 |
visit_field ("else_block", e.get_else_block ()); |
| 1458 |
|
| 1459 |
end ("IfExprConseqElse"); |
| 1460 |
} |
| 1461 |
|
| 1462 |
void |
| 1463 |
Dump::visit (MatchExpr &e) |
| 1464 |
{ |
| 1465 |
begin ("MatchExpr"); |
| 1466 |
do_inner_attrs (e); |
| 1467 |
do_expr (e); |
| 1468 |
|
| 1469 |
visit_field ("branch_value", e.get_scrutinee_expr ()); |
| 1470 |
|
| 1471 |
if (!e.has_match_arms ()) |
| 1472 |
{ |
| 1473 |
put_field ("match_arms", "empty"); |
| 1474 |
} |
| 1475 |
else |
| 1476 |
{ |
| 1477 |
begin_field ("match_arms"); |
| 1478 |
for (auto &arm : e.get_match_cases ()) |
| 1479 |
do_matchcase (arm); |
| 1480 |
end_field ("match_arms"); |
| 1481 |
} |
| 1482 |
end ("MatchExpr"); |
| 1483 |
} |
| 1484 |
|
| 1485 |
void |
| 1486 |
Dump::visit (AwaitExpr &e) |
| 1487 |
{ |
| 1488 |
begin ("AwaitExpr"); |
| 1489 |
do_expr (e); |
| 1490 |
visit_field ("awaited_expr", e.get_awaited_expr ()); |
| 1491 |
end ("AwaitExpr"); |
| 1492 |
} |
| 1493 |
|
| 1494 |
void |
| 1495 |
Dump::visit (AsyncBlockExpr &e) |
| 1496 |
{ |
| 1497 |
begin ("AsyncBlockExpr"); |
| 1498 |
do_expr (e); |
| 1499 |
|
| 1500 |
put_field ("has move", std::to_string (e.get_has_move ())); |
| 1501 |
visit_field ("block_expr", e.get_block_expr ()); |
| 1502 |
|
| 1503 |
end ("AsyncBlockExpr"); |
| 1504 |
} |
| 1505 |
|
| 1506 |
void |
| 1507 |
Dump::visit (InlineAsm &e) |
| 1508 |
{} |
| 1509 |
|
| 1510 |
void |
| 1511 |
Dump::visit (TypeParam &e) |
| 1512 |
{ |
| 1513 |
begin ("TypeParam"); |
| 1514 |
auto &outer_attrs = e.get_outer_attrs (); |
| 1515 |
do_outer_attrs (outer_attrs); |
| 1516 |
|
| 1517 |
put_field ("type_representation", e.get_type_representation ().as_string ()); |
| 1518 |
|
| 1519 |
visit_collection ("type_param_bounds", e.get_type_param_bounds ()); |
| 1520 |
|
| 1521 |
if (e.has_type ()) |
| 1522 |
visit_field ("type", e.get_type ()); |
| 1523 |
|
| 1524 |
end ("TypeParam"); |
| 1525 |
} |
| 1526 |
|
| 1527 |
void |
| 1528 |
Dump::visit (ConstGenericParam &e) |
| 1529 |
{ |
| 1530 |
begin ("ConstGenericParam"); |
| 1531 |
do_mappings (e.get_mappings ()); |
| 1532 |
put_field ("name", e.get_name ()); |
| 1533 |
visit_field ("type", e.get_type ()); |
| 1534 |
visit_field ("default_expression", e.get_default_expression ()); |
| 1535 |
end ("ConstGenericParam"); |
| 1536 |
} |
| 1537 |
|
| 1538 |
void |
| 1539 |
Dump::visit (LifetimeWhereClauseItem &e) |
| 1540 |
{ |
| 1541 |
begin ("LifetimeWhereClauseItem"); |
| 1542 |
do_mappings (e.get_mappings ()); |
| 1543 |
|
| 1544 |
visit_field ("lifetime", e.get_lifetime ()); |
| 1545 |
visit_collection ("lifetime_bounds", e.get_lifetime_bounds ()); |
| 1546 |
|
| 1547 |
end ("LifetimeWhereClauseItem"); |
| 1548 |
} |
| 1549 |
|
| 1550 |
void |
| 1551 |
Dump::visit (TypeBoundWhereClauseItem &e) |
| 1552 |
{ |
| 1553 |
begin ("TypeBoundWhereClauseItem"); |
| 1554 |
do_mappings (e.get_mappings ()); |
| 1555 |
|
| 1556 |
visit_collection ("for_lifetime", e.get_for_lifetimes ()); |
| 1557 |
|
| 1558 |
visit_field ("bound_type", e.get_bound_type ()); |
| 1559 |
visit_collection ("type_param_bound", e.get_type_param_bounds ()); |
| 1560 |
end ("TypeBoundWhereClauseItem"); |
| 1561 |
} |
| 1562 |
|
| 1563 |
void |
| 1564 |
Dump::visit (Module &e) |
| 1565 |
{ |
| 1566 |
begin ("Module"); |
| 1567 |
do_inner_attrs (e); |
| 1568 |
put_field ("module_name", e.get_module_name ().as_string ()); |
| 1569 |
visit_collection ("items", e.get_items ()); |
| 1570 |
|
| 1571 |
end ("Module"); |
| 1572 |
} |
| 1573 |
|
| 1574 |
void |
| 1575 |
Dump::visit (ExternCrate &e) |
| 1576 |
{ |
| 1577 |
begin ("ExternCrate"); |
| 1578 |
do_vis_item (e); |
| 1579 |
put_field ("referenced_crate", e.get_referenced_crate ()); |
| 1580 |
put_field ("as_clause_name", e.get_as_clause_name ()); |
| 1581 |
|
| 1582 |
end ("ExternCrate"); |
| 1583 |
} |
| 1584 |
|
| 1585 |
void |
| 1586 |
Dump::visit (UseTreeGlob &e) |
| 1587 |
{ |
| 1588 |
begin ("UseTreeGlob"); |
| 1589 |
|
| 1590 |
std::string glob, path = "not applicable"; |
| 1591 |
switch (e.get_glob_type ()) |
| 1592 |
{ |
| 1593 |
case UseTreeGlob::PathType::NO_PATH: |
| 1594 |
glob = "*"; |
| 1595 |
break; |
| 1596 |
case UseTreeGlob::PathType::GLOBAL: |
| 1597 |
glob = "::*"; |
| 1598 |
break; |
| 1599 |
case UseTreeGlob::PathType::PATH_PREFIXED: { |
| 1600 |
path = e.get_path ().as_string (); |
| 1601 |
glob = "::*"; |
| 1602 |
break; |
| 1603 |
} |
| 1604 |
default: |
| 1605 |
gcc_unreachable (); |
| 1606 |
} |
| 1607 |
put_field ("glob", glob); |
| 1608 |
put_field ("path", path); |
| 1609 |
|
| 1610 |
end ("UseTreeGlob"); |
| 1611 |
} |
| 1612 |
|
| 1613 |
void |
| 1614 |
Dump::visit (UseTreeList &e) |
| 1615 |
{ |
| 1616 |
begin ("UseTreeList"); |
| 1617 |
|
| 1618 |
std::string path_type, path = "not applicable"; |
| 1619 |
switch (e.get_path_type ()) |
| 1620 |
{ |
| 1621 |
case UseTreeList::PathType::NO_PATH: |
| 1622 |
path_type = "*"; |
| 1623 |
break; |
| 1624 |
case UseTreeList::PathType::GLOBAL: |
| 1625 |
path_type = "::*"; |
| 1626 |
break; |
| 1627 |
case UseTreeList::PathType::PATH_PREFIXED: { |
| 1628 |
path = e.get_path ().as_string (); |
| 1629 |
path_type = "::*"; |
| 1630 |
break; |
| 1631 |
} |
| 1632 |
default: |
| 1633 |
gcc_unreachable (); |
| 1634 |
} |
| 1635 |
put_field ("path_type", path_type); |
| 1636 |
put_field ("path", path); |
| 1637 |
|
| 1638 |
visit_collection ("trees", e.get_trees ()); |
| 1639 |
|
| 1640 |
end ("UseTreeList"); |
| 1641 |
} |
| 1642 |
|
| 1643 |
void |
| 1644 |
Dump::visit (UseTreeRebind &e) |
| 1645 |
{ |
| 1646 |
begin ("UseTreeRebind"); |
| 1647 |
put_field ("path", e.get_path ().as_string ()); |
| 1648 |
put_field ("identifier", e.get_identifier ().as_string ()); |
| 1649 |
put_field ("bind_type", enum_to_str (e.get_bind_type ())); |
| 1650 |
end ("UseTreeRebind"); |
| 1651 |
} |
| 1652 |
|
| 1653 |
void |
| 1654 |
Dump::visit (UseDeclaration &e) |
| 1655 |
{ |
| 1656 |
begin ("UseDeclaration"); |
| 1657 |
do_vis_item (e); |
| 1658 |
|
| 1659 |
visit_field ("use_tree", e.get_use_tree ()); |
| 1660 |
|
| 1661 |
end ("UseDeclaration"); |
| 1662 |
} |
| 1663 |
|
| 1664 |
void |
| 1665 |
Dump::visit (Function &e) |
| 1666 |
{ |
| 1667 |
begin ("Function"); |
| 1668 |
do_vis_item (e); |
| 1669 |
|
| 1670 |
put_field ("function_qualifiers", e.get_qualifiers ().as_string ()); |
| 1671 |
|
| 1672 |
visit_collection ("generic_params", e.get_generic_params ()); |
| 1673 |
|
| 1674 |
put_field ("function_name", e.get_function_name ().as_string ()); |
| 1675 |
|
| 1676 |
if (e.has_function_params ()) |
| 1677 |
{ |
| 1678 |
begin_field ("function_params"); |
| 1679 |
for (auto &item : e.get_function_params ()) |
| 1680 |
do_functionparam (item); |
| 1681 |
end_field ("function_params"); |
| 1682 |
} |
| 1683 |
else |
| 1684 |
{ |
| 1685 |
put_field ("function_params", "empty"); |
| 1686 |
} |
| 1687 |
|
| 1688 |
if (e.has_function_return_type ()) |
| 1689 |
visit_field ("return_type", e.get_return_type ()); |
| 1690 |
|
| 1691 |
if (!e.has_where_clause ()) |
| 1692 |
put_field ("where_clause", "none"); |
| 1693 |
else |
| 1694 |
put_field ("where clause", e.get_where_clause ().as_string ()); |
| 1695 |
|
| 1696 |
visit_field ("function_body", e.get_definition ()); |
| 1697 |
if (e.is_method ()) |
| 1698 |
put_field ("self", e.get_self_param_unchecked ().as_string ()); |
| 1699 |
|
| 1700 |
end ("Function"); |
| 1701 |
} |
| 1702 |
|
| 1703 |
void |
| 1704 |
Dump::visit (TypeAlias &e) |
| 1705 |
{ |
| 1706 |
begin ("TypeAlias"); |
| 1707 |
|
| 1708 |
do_vis_item (e); |
| 1709 |
|
| 1710 |
put_field ("new_type_name", e.get_new_type_name ().as_string ()); |
| 1711 |
|
| 1712 |
visit_collection ("generic_params", e.get_generic_params ()); |
| 1713 |
|
| 1714 |
if (!e.has_where_clause ()) |
| 1715 |
put_field ("where_clause", "none"); |
| 1716 |
else |
| 1717 |
put_field ("where clause", e.get_where_clause ().as_string ()); |
| 1718 |
|
| 1719 |
put_field ("type", e.get_type_aliased ().as_string ()); |
| 1720 |
|
| 1721 |
end ("TypeAlias"); |
| 1722 |
} |
| 1723 |
|
| 1724 |
void |
| 1725 |
Dump::visit (StructStruct &e) |
| 1726 |
{ |
| 1727 |
begin ("StructStruct"); |
| 1728 |
do_struct (e); |
| 1729 |
|
| 1730 |
put_field ("is_unit", std::to_string (e.is_unit_struct ())); |
| 1731 |
|
| 1732 |
if (e.get_fields ().empty ()) |
| 1733 |
put_field ("fields", "empty"); |
| 1734 |
else |
| 1735 |
{ |
| 1736 |
begin_field ("fields"); |
| 1737 |
for (auto &field : e.get_fields ()) |
| 1738 |
{ |
| 1739 |
begin ("StructField"); |
| 1740 |
do_structfield (field); |
| 1741 |
end ("StructField"); |
| 1742 |
} |
| 1743 |
end_field ("fields"); |
| 1744 |
} |
| 1745 |
|
| 1746 |
end ("StructStruct"); |
| 1747 |
} |
| 1748 |
|
| 1749 |
void |
| 1750 |
Dump::visit (TupleStruct &e) |
| 1751 |
{ |
| 1752 |
begin ("TupleStruct"); |
| 1753 |
do_struct (e); |
| 1754 |
|
| 1755 |
if (e.get_fields ().empty ()) |
| 1756 |
put_field ("fields", "empty"); |
| 1757 |
else |
| 1758 |
{ |
| 1759 |
begin_field ("fields"); |
| 1760 |
for (auto &field : e.get_fields ()) |
| 1761 |
{ |
| 1762 |
begin ("TupleField"); |
| 1763 |
do_tuplefield (field); |
| 1764 |
end ("TupleField"); |
| 1765 |
} |
| 1766 |
end_field ("fields"); |
| 1767 |
} |
| 1768 |
|
| 1769 |
end ("TupleStruct"); |
| 1770 |
} |
| 1771 |
|
| 1772 |
void |
| 1773 |
Dump::visit (EnumItem &e) |
| 1774 |
{ |
| 1775 |
begin ("EnumItem"); |
| 1776 |
do_enumitem (e); |
| 1777 |
end ("EnumItem"); |
| 1778 |
} |
| 1779 |
|
| 1780 |
void |
| 1781 |
Dump::visit (EnumItemTuple &e) |
| 1782 |
{ |
| 1783 |
begin ("EnumItemTuple"); |
| 1784 |
do_enumitem (e); |
| 1785 |
|
| 1786 |
if (e.has_tuple_fields ()) |
| 1787 |
{ |
| 1788 |
begin_field ("tuple_fields"); |
| 1789 |
for (auto field : e.get_tuple_fields ()) |
| 1790 |
do_tuplefield (field); |
| 1791 |
end_field ("tuple_fields"); |
| 1792 |
} |
| 1793 |
else |
| 1794 |
put_field ("tuple_fields", "empty"); |
| 1795 |
|
| 1796 |
end ("EnumItemTuple"); |
| 1797 |
} |
| 1798 |
|
| 1799 |
void |
| 1800 |
Dump::visit (EnumItemStruct &e) |
| 1801 |
{ |
| 1802 |
begin ("EnumItemStruct"); |
| 1803 |
do_enumitem (e); |
| 1804 |
|
| 1805 |
if (e.has_struct_fields ()) |
| 1806 |
{ |
| 1807 |
begin_field ("struct_fields"); |
| 1808 |
for (auto field : e.get_struct_fields ()) |
| 1809 |
do_structfield (field); |
| 1810 |
end_field ("struct_fields"); |
| 1811 |
} |
| 1812 |
else |
| 1813 |
{ |
| 1814 |
put_field ("struct_fields", "empty"); |
| 1815 |
} |
| 1816 |
end ("EnumItemStruct"); |
| 1817 |
} |
| 1818 |
|
| 1819 |
void |
| 1820 |
Dump::visit (EnumItemDiscriminant &e) |
| 1821 |
{ |
| 1822 |
begin ("EnumItemDiscriminant"); |
| 1823 |
|
| 1824 |
do_enumitem (e); |
| 1825 |
|
| 1826 |
visit_field ("discriminant", e.get_discriminant_expression ()); |
| 1827 |
|
| 1828 |
end ("EnumItemDiscriminant"); |
| 1829 |
} |
| 1830 |
|
| 1831 |
void |
| 1832 |
Dump::visit (Enum &e) |
| 1833 |
{ |
| 1834 |
begin ("Enum"); |
| 1835 |
do_vis_item (e); |
| 1836 |
|
| 1837 |
put_field ("enum_name", e.get_identifier ().as_string ()); |
| 1838 |
|
| 1839 |
visit_collection ("generic_params", e.get_generic_params ()); |
| 1840 |
|
| 1841 |
std::string str = "none"; |
| 1842 |
if (e.has_where_clause ()) |
| 1843 |
str = e.get_where_clause ().as_string (); |
| 1844 |
put_field ("where clause", str); |
| 1845 |
|
| 1846 |
visit_collection ("items", e.get_variants ()); |
| 1847 |
|
| 1848 |
end ("Enum"); |
| 1849 |
} |
| 1850 |
|
| 1851 |
void |
| 1852 |
Dump::visit (Union &e) |
| 1853 |
{ |
| 1854 |
begin ("Union"); |
| 1855 |
do_vis_item (e); |
| 1856 |
|
| 1857 |
visit_collection ("generic_params", e.get_generic_params ()); |
| 1858 |
|
| 1859 |
std::string str; |
| 1860 |
if (e.has_where_clause ()) |
| 1861 |
str = e.get_where_clause ().as_string (); |
| 1862 |
else |
| 1863 |
str = "none"; |
| 1864 |
put_field ("where clause", str); |
| 1865 |
|
| 1866 |
if (e.get_variants ().empty ()) |
| 1867 |
{ |
| 1868 |
put_field ("variants", "empty"); |
| 1869 |
} |
| 1870 |
else |
| 1871 |
{ |
| 1872 |
begin_field ("variants"); |
| 1873 |
for (auto &elt : e.get_variants ()) |
| 1874 |
{ |
| 1875 |
begin ("StructField"); |
| 1876 |
auto oa = e.get_outer_attrs (); |
| 1877 |
do_outer_attrs (oa); |
| 1878 |
|
| 1879 |
std::string str = "none"; |
| 1880 |
if (elt.has_visibility ()) |
| 1881 |
str = elt.get_visibility ().as_string (); |
| 1882 |
put_field ("visibility", str); |
| 1883 |
put_field ("field_name", elt.get_field_name ().as_string ()); |
| 1884 |
visit_field ("field_type", elt.get_field_type ()); |
| 1885 |
end ("StructField"); |
| 1886 |
} |
| 1887 |
end_field ("variants"); |
| 1888 |
} |
| 1889 |
end ("Union"); |
| 1890 |
} |
| 1891 |
|
| 1892 |
void |
| 1893 |
Dump::visit (ConstantItem &e) |
| 1894 |
{ |
| 1895 |
begin ("ConstantItem"); |
| 1896 |
do_vis_item (e); |
| 1897 |
put_field ("identifier", e.get_identifier ().as_string ()); |
| 1898 |
visit_field ("type", e.get_type ()); |
| 1899 |
visit_field ("const_expr", e.get_expr ()); |
| 1900 |
end ("ConstantItem"); |
| 1901 |
} |
| 1902 |
|
| 1903 |
void |
| 1904 |
Dump::visit (StaticItem &e) |
| 1905 |
{ |
| 1906 |
begin ("StaticItem"); |
| 1907 |
do_vis_item (e); |
| 1908 |
put_field ("mut", std::to_string (e.is_mut ())); |
| 1909 |
put_field ("name", e.get_identifier ().as_string ()); |
| 1910 |
visit_field ("type", e.get_type ()); |
| 1911 |
visit_field ("expr", e.get_expr ()); |
| 1912 |
end ("StaticItem"); |
| 1913 |
} |
| 1914 |
|
| 1915 |
void |
| 1916 |
Dump::visit (TraitItemFunc &e) |
| 1917 |
{ |
| 1918 |
begin ("TraitItemFunc"); |
| 1919 |
do_traititem (e); |
| 1920 |
|
| 1921 |
do_traitfunctiondecl (e.get_decl ()); |
| 1922 |
|
| 1923 |
if (e.has_definition ()) |
| 1924 |
visit_field ("block_expr", e.get_block_expr ()); |
| 1925 |
|
| 1926 |
end ("TraitItemFunc"); |
| 1927 |
} |
| 1928 |
|
| 1929 |
void |
| 1930 |
Dump::visit (TraitItemConst &e) |
| 1931 |
{ |
| 1932 |
begin ("TraitItemConst"); |
| 1933 |
do_traititem (e); |
| 1934 |
|
| 1935 |
put_field ("name", e.get_name ().as_string ()); |
| 1936 |
visit_field ("type", e.get_type ()); |
| 1937 |
if (e.has_expr ()) |
| 1938 |
visit_field ("expr", e.get_expr ()); |
| 1939 |
|
| 1940 |
end ("TraitItemConst"); |
| 1941 |
} |
| 1942 |
|
| 1943 |
void |
| 1944 |
Dump::visit (TraitItemType &e) |
| 1945 |
{ |
| 1946 |
begin ("TraitItemType"); |
| 1947 |
do_traititem (e); |
| 1948 |
|
| 1949 |
put_field ("name", e.get_name ().as_string ()); |
| 1950 |
visit_collection ("type_param_bounds", e.get_type_param_bounds ()); |
| 1951 |
end ("TraitItemType"); |
| 1952 |
} |
| 1953 |
|
| 1954 |
void |
| 1955 |
Dump::visit (Trait &e) |
| 1956 |
{ |
| 1957 |
begin ("Trait"); |
| 1958 |
do_vis_item (e); |
| 1959 |
put_field ("unsafety", std::to_string (e.is_unsafe ())); |
| 1960 |
put_field ("name", e.get_name ().as_string ()); |
| 1961 |
|
| 1962 |
visit_collection ("generic_params", e.get_generic_params ()); |
| 1963 |
|
| 1964 |
visit_collection ("type_param_bounds", e.get_type_param_bounds ()); |
| 1965 |
|
| 1966 |
std::string str; |
| 1967 |
if (e.has_where_clause ()) |
| 1968 |
str = e.get_where_clause ().as_string (); |
| 1969 |
else |
| 1970 |
str = "none"; |
| 1971 |
put_field ("where clause", str); |
| 1972 |
|
| 1973 |
visit_collection ("trait_items", e.get_trait_items ()); |
| 1974 |
|
| 1975 |
end ("Trait"); |
| 1976 |
} |
| 1977 |
|
| 1978 |
void |
| 1979 |
Dump::visit (ImplBlock &e) |
| 1980 |
{ |
| 1981 |
begin ("ImplBlock"); |
| 1982 |
do_vis_item (e); |
| 1983 |
|
| 1984 |
visit_collection ("generic_params", e.get_generic_params ()); |
| 1985 |
|
| 1986 |
visit_field ("impl_type", e.get_type ()); |
| 1987 |
|
| 1988 |
std::string str; |
| 1989 |
if (e.has_where_clause ()) |
| 1990 |
str = e.get_where_clause ().as_string (); |
| 1991 |
else |
| 1992 |
str = "none"; |
| 1993 |
put_field ("where clause", str); |
| 1994 |
|
| 1995 |
do_inner_attrs (e); |
| 1996 |
|
| 1997 |
visit_collection ("impl_items", e.get_impl_items ()); |
| 1998 |
|
| 1999 |
end ("ImplBlock"); |
| 2000 |
} |
| 2001 |
|
| 2002 |
void |
| 2003 |
Dump::visit (ExternalStaticItem &e) |
| 2004 |
{ |
| 2005 |
begin ("ExternalStaticItem"); |
| 2006 |
|
| 2007 |
// FIXME do_vis_item... but not a VisItem... But could be? |
| 2008 |
auto oa = e.get_outer_attrs (); |
| 2009 |
do_outer_attrs (oa); |
| 2010 |
|
| 2011 |
std::string str = "none"; |
| 2012 |
if (e.has_visibility ()) |
| 2013 |
str = e.get_visibility ().as_string (); |
| 2014 |
put_field ("visibility", str); |
| 2015 |
// |
| 2016 |
|
| 2017 |
put_field ("mut", std::to_string (e.is_mut ())); |
| 2018 |
put_field ("name", e.get_item_name ().as_string ()); |
| 2019 |
visit_field ("type", e.get_item_type ()); |
| 2020 |
|
| 2021 |
end ("ExternalStaticItem"); |
| 2022 |
} |
| 2023 |
|
| 2024 |
void |
| 2025 |
Dump::visit (ExternalFunctionItem &e) |
| 2026 |
{ |
| 2027 |
begin ("ExternalFunctionItem"); |
| 2028 |
do_externalitem (e); |
| 2029 |
|
| 2030 |
visit_collection ("generic_params", e.get_generic_params ()); |
| 2031 |
|
| 2032 |
std::string str = "none"; |
| 2033 |
if (!e.get_function_params ().empty ()) |
| 2034 |
for (auto ¶m : e.get_function_params ()) |
| 2035 |
do_namefunctionparam (param); |
| 2036 |
else |
| 2037 |
put_field ("function_params", "none"); |
| 2038 |
|
| 2039 |
put_field ("has_variadics", std::to_string (e.is_variadic ())); |
| 2040 |
|
| 2041 |
if (e.has_return_type ()) |
| 2042 |
visit_field ("return_type", e.get_return_type ()); |
| 2043 |
|
| 2044 |
end ("ExternalFunctionItem"); |
| 2045 |
} |
| 2046 |
|
| 2047 |
void |
| 2048 |
Dump::visit (ExternalTypeItem &e) |
| 2049 |
{ |
| 2050 |
begin ("ExternalTypeItem"); |
| 2051 |
|
| 2052 |
do_externalitem (e); |
| 2053 |
|
| 2054 |
end ("ExternalTypeItem"); |
| 2055 |
} |
| 2056 |
|
| 2057 |
void |
| 2058 |
Dump::visit (ExternBlock &e) |
| 2059 |
{ |
| 2060 |
begin ("ExternBlock"); |
| 2061 |
do_vis_item (e); |
| 2062 |
do_inner_attrs (e); |
| 2063 |
|
| 2064 |
put_field ("abi", get_string_from_abi (e.get_abi ())); |
| 2065 |
|
| 2066 |
visit_collection ("extern_items", e.get_extern_items ()); |
| 2067 |
|
| 2068 |
end ("ExternBlock"); |
| 2069 |
} |
| 2070 |
|
| 2071 |
void |
| 2072 |
Dump::visit (LiteralPattern &e) |
| 2073 |
{ |
| 2074 |
begin ("LiteralPattern"); |
| 2075 |
put_field ("lit", e.get_literal ().as_string ()); |
| 2076 |
do_mappings (e.get_mappings ()); |
| 2077 |
end ("LiteralPattern"); |
| 2078 |
} |
| 2079 |
|
| 2080 |
void |
| 2081 |
Dump::visit (IdentifierPattern &e) |
| 2082 |
{ |
| 2083 |
begin ("IdentifierPattern"); |
| 2084 |
put_field ("variable_ident", e.get_identifier ().as_string ()); |
| 2085 |
put_field ("is_ref", std::to_string (e.get_is_ref ())); |
| 2086 |
put_field ("mut", std::to_string (e.is_mut ())); |
| 2087 |
|
| 2088 |
if (e.has_pattern_to_bind ()) |
| 2089 |
put_field ("to_bind", e.get_to_bind ().as_string ()); |
| 2090 |
else |
| 2091 |
put_field ("to_bind", "none"); |
| 2092 |
|
| 2093 |
end ("IdentifierPattern"); |
| 2094 |
} |
| 2095 |
void |
| 2096 |
Dump::visit (WildcardPattern &e) |
| 2097 |
{ |
| 2098 |
begin ("WildcardPattern"); |
| 2099 |
do_mappings (e.get_mappings ()); |
| 2100 |
end ("WildcardPattern"); |
| 2101 |
} |
| 2102 |
|
| 2103 |
void |
| 2104 |
Dump::visit (RangePatternBoundLiteral &e) |
| 2105 |
{ |
| 2106 |
begin ("RangePatternBoundLiteral"); |
| 2107 |
put_field ("literal", e.get_literal ().as_string ()); |
| 2108 |
put_field ("has_minus", std::to_string (e.get_has_minus ())); |
| 2109 |
end ("RangePatternBoundLiteral"); |
| 2110 |
} |
| 2111 |
|
| 2112 |
void |
| 2113 |
Dump::visit (RangePatternBoundPath &e) |
| 2114 |
{ |
| 2115 |
begin ("RangePatternBoundPath"); |
| 2116 |
put_field ("path", e.get_path ().as_string ()); |
| 2117 |
end ("RangePatternBoundPath"); |
| 2118 |
} |
| 2119 |
|
| 2120 |
void |
| 2121 |
Dump::visit (RangePatternBoundQualPath &e) |
| 2122 |
{ |
| 2123 |
begin ("RangePatternBoundQualPath"); |
| 2124 |
visit_field ("path", e.get_qualified_path ()); |
| 2125 |
end ("RangePatternBoundQualPath"); |
| 2126 |
} |
| 2127 |
|
| 2128 |
void |
| 2129 |
Dump::visit (RangePattern &e) |
| 2130 |
{ |
| 2131 |
begin ("RangePattern"); |
| 2132 |
do_mappings (e.get_mappings ()); |
| 2133 |
put_field ("lower", e.get_lower_bound ().as_string ()); |
| 2134 |
put_field ("upper", e.get_upper_bound ().as_string ()); |
| 2135 |
put_field ("has_ellipsis_syntax", |
| 2136 |
std::to_string (e.get_has_ellipsis_syntax ())); |
| 2137 |
end ("RangePattern"); |
| 2138 |
} |
| 2139 |
|
| 2140 |
void |
| 2141 |
Dump::visit (ReferencePattern &e) |
| 2142 |
{ |
| 2143 |
begin ("ReferencePattern"); |
| 2144 |
do_mappings (e.get_mappings ()); |
| 2145 |
put_field ("mut", std::to_string (e.is_mut ())); |
| 2146 |
put_field ("pattern", e.get_referenced_pattern ().as_string ()); |
| 2147 |
end ("ReferencePattern"); |
| 2148 |
} |
| 2149 |
|
| 2150 |
void |
| 2151 |
Dump::visit (StructPatternFieldTuplePat &e) |
| 2152 |
{ |
| 2153 |
begin ("StructPatternFieldTuplePat"); |
| 2154 |
do_mappings (e.get_mappings ()); |
| 2155 |
auto oa = e.get_outer_attrs (); |
| 2156 |
do_outer_attrs (oa); |
| 2157 |
put_field ("index", std::to_string (e.get_index ())); |
| 2158 |
put_field ("tuple_pattern", e.get_tuple_pattern ().as_string ()); |
| 2159 |
end ("StructPatternFieldTuplePat"); |
| 2160 |
} |
| 2161 |
|
| 2162 |
void |
| 2163 |
Dump::visit (StructPatternFieldIdentPat &e) |
| 2164 |
{ |
| 2165 |
begin ("StructPatternFieldIdentPat"); |
| 2166 |
auto oa = e.get_outer_attrs (); |
| 2167 |
do_outer_attrs (oa); |
| 2168 |
put_field ("ident", e.get_identifier ().as_string ()); |
| 2169 |
put_field ("ident_pattern", e.get_pattern ().as_string ()); |
| 2170 |
end ("StructPatternFieldIdentPat"); |
| 2171 |
} |
| 2172 |
|
| 2173 |
void |
| 2174 |
Dump::visit (StructPatternFieldIdent &e) |
| 2175 |
{ |
| 2176 |
begin ("StructPatternFieldIdent"); |
| 2177 |
auto oa = e.get_outer_attrs (); |
| 2178 |
do_outer_attrs (oa); |
| 2179 |
|
| 2180 |
put_field ("has_ref", std::to_string (e.get_has_ref ())); |
| 2181 |
put_field ("mut", std::to_string (e.is_mut ())); |
| 2182 |
put_field ("ident", e.get_identifier ().as_string ()); |
| 2183 |
end ("StructPatternFieldIdent"); |
| 2184 |
} |
| 2185 |
|
| 2186 |
void |
| 2187 |
Dump::visit (StructPattern &e) |
| 2188 |
{ |
| 2189 |
begin ("StructPattern"); |
| 2190 |
|
| 2191 |
visit_field ("path", e.get_path ()); |
| 2192 |
put_field ("elems", e.get_struct_pattern_elems ().as_string ()); |
| 2193 |
|
| 2194 |
end ("StructPattern"); |
| 2195 |
} |
| 2196 |
|
| 2197 |
void |
| 2198 |
Dump::visit (TupleStructItemsNoRange &e) |
| 2199 |
{ |
| 2200 |
begin ("TupleStructItemsNoRange"); |
| 2201 |
visit_collection ("patterns", e.get_patterns ()); |
| 2202 |
end ("TupleStructItemsNoRange"); |
| 2203 |
} |
| 2204 |
|
| 2205 |
void |
| 2206 |
Dump::visit (TupleStructItemsRange &e) |
| 2207 |
{ |
| 2208 |
begin ("TupleStructItemsRange"); |
| 2209 |
visit_collection ("lower_patterns", e.get_lower_patterns ()); |
| 2210 |
visit_collection ("upper_patterns", e.get_upper_patterns ()); |
| 2211 |
end ("TupleStructItemsRange"); |
| 2212 |
} |
| 2213 |
|
| 2214 |
void |
| 2215 |
Dump::visit (TupleStructPattern &e) |
| 2216 |
{ |
| 2217 |
begin ("TupleStructPattern"); |
| 2218 |
do_mappings (e.get_mappings ()); |
| 2219 |
|
| 2220 |
put_field ("path", e.get_path ().as_string ()); |
| 2221 |
|
| 2222 |
visit_field ("items", e.get_items ()); |
| 2223 |
|
| 2224 |
end ("TupleStructPattern"); |
| 2225 |
} |
| 2226 |
|
| 2227 |
void |
| 2228 |
Dump::visit (TuplePatternItemsMultiple &e) |
| 2229 |
{ |
| 2230 |
begin ("TuplePatternItemsMultiple"); |
| 2231 |
visit_collection ("patterns", e.get_patterns ()); |
| 2232 |
end ("TuplePatternItemsMultiple"); |
| 2233 |
} |
| 2234 |
|
| 2235 |
void |
| 2236 |
Dump::visit (TuplePatternItemsRanged &e) |
| 2237 |
{ |
| 2238 |
begin ("TuplePatternItemsRanged"); |
| 2239 |
visit_collection ("lower_patterns", e.get_lower_patterns ()); |
| 2240 |
visit_collection ("upper_patterns", e.get_upper_patterns ()); |
| 2241 |
end ("TuplePatternItemsRanged"); |
| 2242 |
} |
| 2243 |
|
| 2244 |
void |
| 2245 |
Dump::visit (TuplePattern &e) |
| 2246 |
{ |
| 2247 |
begin ("TuplePattern"); |
| 2248 |
do_mappings (e.get_mappings ()); |
| 2249 |
visit_field ("items", e.get_items ()); |
| 2250 |
end ("TuplePattern"); |
| 2251 |
} |
| 2252 |
|
| 2253 |
void |
| 2254 |
Dump::visit (SlicePattern &e) |
| 2255 |
{ |
| 2256 |
begin ("SlicePattern"); |
| 2257 |
do_mappings (e.get_mappings ()); |
| 2258 |
visit_collection ("items", e.get_items ()); |
| 2259 |
end ("SlicePattern"); |
| 2260 |
} |
| 2261 |
|
| 2262 |
void |
| 2263 |
Dump::visit (AltPattern &e) |
| 2264 |
{ |
| 2265 |
begin ("AltPattern"); |
| 2266 |
do_mappings (e.get_mappings ()); |
| 2267 |
visit_collection ("alts", e.get_alts ()); |
| 2268 |
end ("AltPattern"); |
| 2269 |
} |
| 2270 |
|
| 2271 |
void |
| 2272 |
Dump::visit (EmptyStmt &e) |
| 2273 |
{ |
| 2274 |
begin ("EmptyStmt"); |
| 2275 |
do_stmt (e); |
| 2276 |
end ("EmptyStmt"); |
| 2277 |
} |
| 2278 |
|
| 2279 |
void |
| 2280 |
Dump::visit (LetStmt &e) |
| 2281 |
{ |
| 2282 |
begin ("LetStmt"); |
| 2283 |
do_stmt (e); |
| 2284 |
auto oa = e.get_outer_attrs (); |
| 2285 |
do_outer_attrs (oa); |
| 2286 |
|
| 2287 |
put_field ("variable_pattern", e.get_pattern ().as_string ()); |
| 2288 |
|
| 2289 |
if (e.has_type ()) |
| 2290 |
visit_field ("type", e.get_type ()); |
| 2291 |
if (e.has_init_expr ()) |
| 2292 |
visit_field ("init_expr", e.get_init_expr ()); |
| 2293 |
|
| 2294 |
end ("LetStmt"); |
| 2295 |
} |
| 2296 |
|
| 2297 |
void |
| 2298 |
Dump::visit (ExprStmt &e) |
| 2299 |
{ |
| 2300 |
begin ("ExprStmt"); |
| 2301 |
do_stmt (e); |
| 2302 |
put_field ("must_be_unit", std::to_string (e.is_unit_check_needed ())); |
| 2303 |
visit_field ("expr", e.get_expr ()); |
| 2304 |
end ("ExprStmt"); |
| 2305 |
} |
| 2306 |
|
| 2307 |
void |
| 2308 |
Dump::visit (TraitBound &e) |
| 2309 |
{ |
| 2310 |
begin ("TraitBound"); |
| 2311 |
do_mappings (e.get_mappings ()); |
| 2312 |
put_field ("in_parens", std::to_string (e.get_in_parens ())); |
| 2313 |
put_field ("polarity", BoundPolarityString (e.get_polarity ())); |
| 2314 |
|
| 2315 |
visit_collection ("for_lifetime", e.get_for_lifetimes ()); |
| 2316 |
visit_field ("type_path", e.get_path ()); |
| 2317 |
|
| 2318 |
end ("TraitBound"); |
| 2319 |
} |
| 2320 |
|
| 2321 |
void |
| 2322 |
Dump::visit (ImplTraitType &e) |
| 2323 |
{ |
| 2324 |
begin ("ImplTraitType"); |
| 2325 |
do_type (e); |
| 2326 |
|
| 2327 |
visit_collection ("type_param_bounds", e.get_type_param_bounds ()); |
| 2328 |
|
| 2329 |
end ("ImplTraitType"); |
| 2330 |
} |
| 2331 |
|
| 2332 |
void |
| 2333 |
Dump::visit (TraitObjectType &e) |
| 2334 |
{ |
| 2335 |
begin ("TraitObjectType"); |
| 2336 |
do_type (e); |
| 2337 |
|
| 2338 |
put_field ("has_dyn", std::to_string (e.get_has_dyn ())); |
| 2339 |
|
| 2340 |
visit_collection ("type_param_bounds", e.get_type_param_bounds ()); |
| 2341 |
|
| 2342 |
end ("TraitObjectType"); |
| 2343 |
} |
| 2344 |
|
| 2345 |
void |
| 2346 |
Dump::visit (ParenthesisedType &e) |
| 2347 |
{ |
| 2348 |
begin ("ParenthesisedType"); |
| 2349 |
do_type (e); |
| 2350 |
put_field ("type_in_parens", e.get_type_in_parens ().as_string ()); |
| 2351 |
end ("ParenthesisedType"); |
| 2352 |
} |
| 2353 |
|
| 2354 |
void |
| 2355 |
Dump::visit (TupleType &e) |
| 2356 |
{ |
| 2357 |
begin ("TupleType"); |
| 2358 |
do_type (e); |
| 2359 |
visit_collection ("elems", e.get_elems ()); |
| 2360 |
end ("TupleType"); |
| 2361 |
} |
| 2362 |
|
| 2363 |
void |
| 2364 |
Dump::visit (NeverType &e) |
| 2365 |
{ |
| 2366 |
begin ("NeverType"); |
| 2367 |
do_type (e); |
| 2368 |
end ("NeverType"); |
| 2369 |
} |
| 2370 |
|
| 2371 |
void |
| 2372 |
Dump::visit (RawPointerType &e) |
| 2373 |
{ |
| 2374 |
begin ("RawPointerType"); |
| 2375 |
do_type (e); |
| 2376 |
put_field ("mut", Rust::enum_to_str (e.get_mut ())); |
| 2377 |
put_field ("type", e.get_type ().as_string ()); |
| 2378 |
end ("RawPointerType"); |
| 2379 |
} |
| 2380 |
|
| 2381 |
void |
| 2382 |
Dump::visit (ReferenceType &e) |
| 2383 |
{ |
| 2384 |
begin ("ReferenceType"); |
| 2385 |
do_type (e); |
| 2386 |
put_field ("lifetime", e.get_lifetime ().as_string ()); |
| 2387 |
put_field ("mut", enum_to_str (e.get_mut ())); |
| 2388 |
put_field ("type", e.get_base_type ().as_string ()); |
| 2389 |
end ("ReferenceType"); |
| 2390 |
} |
| 2391 |
|
| 2392 |
void |
| 2393 |
Dump::visit (ArrayType &e) |
| 2394 |
{ |
| 2395 |
begin ("ArrayType"); |
| 2396 |
do_type (e); |
| 2397 |
visit_field ("type", e.get_element_type ()); |
| 2398 |
visit_field ("size", e.get_size_expr ()); |
| 2399 |
end ("ArrayType"); |
| 2400 |
} |
| 2401 |
|
| 2402 |
void |
| 2403 |
Dump::visit (SliceType &e) |
| 2404 |
{ |
| 2405 |
begin ("SliceType"); |
| 2406 |
do_type (e); |
| 2407 |
visit_field ("elem_type", e.get_element_type ()); |
| 2408 |
end ("SliceType"); |
| 2409 |
} |
| 2410 |
|
| 2411 |
void |
| 2412 |
Dump::visit (InferredType &e) |
| 2413 |
{ |
| 2414 |
begin ("InferredType"); |
| 2415 |
do_type (e); |
| 2416 |
end ("InferredType"); |
| 2417 |
} |
| 2418 |
|
| 2419 |
void |
| 2420 |
Dump::visit (BareFunctionType &e) |
| 2421 |
{ |
| 2422 |
begin ("BareFunctionType"); |
| 2423 |
do_type (e); |
| 2424 |
|
| 2425 |
visit_collection ("for_lifetimes", e.get_for_lifetimes ()); |
| 2426 |
|
| 2427 |
put_field ("function_qualifiers", e.get_function_qualifiers ().as_string ()); |
| 2428 |
|
| 2429 |
if (e.get_function_params ().empty ()) |
| 2430 |
{ |
| 2431 |
put_field ("params", "none"); |
| 2432 |
} |
| 2433 |
else |
| 2434 |
{ |
| 2435 |
begin_field ("params"); |
| 2436 |
for (auto ¶m : e.get_function_params ()) |
| 2437 |
{ |
| 2438 |
begin ("MaybeNamedParam"); |
| 2439 |
do_maybenamedparam (param); |
| 2440 |
end ("MaybeNamedParam"); |
| 2441 |
} |
| 2442 |
end_field ("params"); |
| 2443 |
} |
| 2444 |
|
| 2445 |
if (e.has_return_type ()) |
| 2446 |
visit_field ("return_type", e.get_return_type ()); |
| 2447 |
|
| 2448 |
put_field ("is_variadic", std::to_string (e.get_is_variadic ())); |
| 2449 |
end ("BareFunctionType"); |
| 2450 |
} |
| 2451 |
|
| 2452 |
} // namespace HIR |
| 2453 |
} // namespace Rust |
| 2454 |
|
| 2455 |
// In the global namespace to make it easier to call from debugger |
| 2456 |
void |
| 2457 |
debug (Rust::HIR::FullVisitable &v) |
| 2458 |
{ |
| 2459 |
Rust::HIR::Dump::debug (v); |
| 2460 |
} |