aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/hir/rust-hir-dump.cc
diff options
context:
space:
mode:
authorMarc Poulhiès <dkm@kataplop.net>2023-08-10 22:45:38 +0200
committerPhilip Herron <philip.herron@embecosm.com>2023-08-11 10:46:39 +0000
commit5712d7d383b0597cd00466e5995c1e620c2fc809 (patch)
tree835eaa3d289d89f71182b0727d9f3d7301625b43 /gcc/rust/hir/rust-hir-dump.cc
parente55113ea2bf0cec2f8436a576ce6f2bcaacd1c27 (diff)
downloadgcc-5712d7d383b0597cd00466e5995c1e620c2fc809.zip
gcc-5712d7d383b0597cd00466e5995c1e620c2fc809.tar.gz
gcc-5712d7d383b0597cd00466e5995c1e620c2fc809.tar.bz2
gccrs: Adjust HIR dump for IfExpr and IfExprConseqElse
Adjust the HIR dump for IfExpr and IfExprConseqElse to use visit_field() and factor common part. gcc/rust/ChangeLog: * hir/rust-hir-dump.h (do_ifexpr): New. * hir/rust-hir-dump.cc (Dump::do_ifexpr): New. (Dump::visit): Use do_ifexpr and visit_field Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
Diffstat (limited to 'gcc/rust/hir/rust-hir-dump.cc')
-rw-r--r--gcc/rust/hir/rust-hir-dump.cc34
1 files changed, 12 insertions, 22 deletions
diff --git a/gcc/rust/hir/rust-hir-dump.cc b/gcc/rust/hir/rust-hir-dump.cc
index c134c80..fb6029f 100644
--- a/gcc/rust/hir/rust-hir-dump.cc
+++ b/gcc/rust/hir/rust-hir-dump.cc
@@ -323,6 +323,14 @@ Dump::do_structexprstruct (StructExprStruct &e)
}
void
+Dump::do_ifexpr (IfExpr &e)
+{
+ do_expr (e);
+ visit_field ("condition", e.get_if_condition ());
+ visit_field ("if_block", e.get_if_block ());
+}
+
+void
Dump::do_expr (Expr &e)
{
do_mappings (e.get_mappings ());
@@ -1404,18 +1412,10 @@ Dump::visit (ForLoopExpr &e)
}
void
-Dump::visit (IfExpr &if_expr)
+Dump::visit (IfExpr &e)
{
begin ("IfExpr");
- begin ("condition");
-
- if_expr.vis_if_condition (*this);
- end ("condition");
-
- begin ("if_block");
- if_expr.vis_if_block (*this);
- end ("if_block");
-
+ do_ifexpr (e);
end ("IfExpr");
}
@@ -1423,18 +1423,8 @@ void
Dump::visit (IfExprConseqElse &e)
{
begin ("IfExprConseqElse");
-
- begin ("condition");
- e.vis_if_condition (*this);
- end ("condition");
-
- begin ("if_block");
- e.vis_if_block (*this);
- end ("if_block");
-
- begin ("else_block");
- e.vis_else_block (*this);
- end ("else_block");
+ do_ifexpr (e);
+ visit_field ("else_block", e.get_else_block ());
end ("IfExprConseqElse");
}