[committed,028/103] gccrs: ast: dump: ArrayExpr

Message ID 20230221120230.596966-29-arthur.cohen@embecosm.com
State Unresolved
Headers
Series [committed,001/103] gccrs: Fix missing dead code analysis ICE on local enum definition |

Checks

Context Check Description
snail/gcc-patch-check warning Git am fail log

Commit Message

Arthur Cohen Feb. 21, 2023, 12:01 p.m. UTC
  From: David Faust <david.faust@oracle.com>

gcc/rust/ChangeLog:

	* ast/rust-ast-dump.cc (Dump::visit): Add dump code for ArrayExpr.
---
 gcc/rust/ast/rust-ast-dump.cc | 32 ++++++++++++++++++++++++++++----
 1 file changed, 28 insertions(+), 4 deletions(-)
  

Patch

diff --git a/gcc/rust/ast/rust-ast-dump.cc b/gcc/rust/ast/rust-ast-dump.cc
index ddc43b33512..91e540a1ee8 100644
--- a/gcc/rust/ast/rust-ast-dump.cc
+++ b/gcc/rust/ast/rust-ast-dump.cc
@@ -449,19 +449,43 @@  Dump::visit (GroupedExpr &expr)
 
 void
 Dump::visit (ArrayElemsValues &elems)
-{}
+{
+  auto &vals = elems.get_values ();
+  if (vals.size () >= 1)
+    {
+      vals[0]->accept_vis (*this);
+      for (size_t i = 1; i < vals.size (); i++)
+	{
+	  stream << ", ";
+	  vals[i]->accept_vis (*this);
+	}
+    }
+}
 
 void
 Dump::visit (ArrayElemsCopied &elems)
-{}
+{
+  elems.get_elem_to_copy ()->accept_vis (*this);
+  stream << "; ";
+  elems.get_num_copies ()->accept_vis (*this);
+}
 
 void
 Dump::visit (ArrayExpr &expr)
-{}
+{
+  stream << '[';
+  expr.get_array_elems ()->accept_vis (*this);
+  stream << ']';
+}
 
 void
 Dump::visit (ArrayIndexExpr &expr)
-{}
+{
+  expr.get_array_expr ()->accept_vis (*this);
+  stream << '[';
+  expr.get_index_expr ()->accept_vis (*this);
+  stream << ']';
+}
 
 void
 Dump::visit (TupleExpr &expr)