gccrs: ast: dump If expressions
authorDavid Faust <david.faust@oracle.com>
Wed, 5 Oct 2022 17:11:38 +0000 (10:11 -0700)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 21 Feb 2023 11:36:32 +0000 (12:36 +0100)
gcc/rust/ChangeLog:

* ast/rust-ast-dump.cc (Dump::visit): Implement visitor for If
expressions.

gcc/rust/ast/rust-ast-dump.cc

index f3d0e2d..bc4f7a3 100644 (file)
@@ -534,15 +534,31 @@ Dump::visit (ForLoopExpr &expr)
 
 void
 Dump::visit (IfExpr &expr)
-{}
+{
+  stream << "if ";
+  expr.vis_if_condition (*this);
+  expr.vis_if_block (*this);
+}
 
 void
 Dump::visit (IfExprConseqElse &expr)
-{}
+{
+  stream << "if ";
+  expr.vis_if_condition (*this);
+  expr.vis_if_block (*this);
+  stream << indentation << "else ";
+  expr.vis_else_block (*this);
+}
 
 void
 Dump::visit (IfExprConseqIf &expr)
-{}
+{
+  stream << "if ";
+  expr.vis_if_condition (*this);
+  expr.vis_if_block (*this);
+  stream << indentation << "else if ";
+  expr.vis_conseq_if_expr (*this);
+}
 
 void
 Dump::visit (IfExprConseqIfLet &expr)