public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Arthur Cohen <cohenarthur@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r13-6182] gccrs: ast: dump: various simple Exprs
Date: Tue, 21 Feb 2023 11:57:40 +0000 (GMT)	[thread overview]
Message-ID: <20230221115740.F245F385B539@sourceware.org> (raw)

https://gcc.gnu.org/g:d1db46191ea5f3ef44833c21f7680f67e4701f7f

commit r13-6182-gd1db46191ea5f3ef44833c21f7680f67e4701f7f
Author: David Faust <david.faust@oracle.com>
Date:   Thu Oct 13 10:15:05 2022 -0700

    gccrs: ast: dump: various simple Exprs
    
    Adds dump for:
    - BorrowExpr
    - DereferenceExpr
    - ErrorPropagationExpr
    - NegationExpr
    - TypeCastExpr
    - GroupedExpr
    
    gcc/rust/ChangeLog:
    
            * ast/rust-ast-dump.cc (Dump::visit): Add dump for, BorrowExpr, DereferenceExpr,
            ErrorPropagationExpr, NegationExpr, TypeCastExpr and GroupedExpr.

Diff:
---
 gcc/rust/ast/rust-ast-dump.cc | 45 +++++++++++++++++++++++++++++++++++++------
 1 file changed, 39 insertions(+), 6 deletions(-)

diff --git a/gcc/rust/ast/rust-ast-dump.cc b/gcc/rust/ast/rust-ast-dump.cc
index 91e540a1ee8..b9e08b59554 100644
--- a/gcc/rust/ast/rust-ast-dump.cc
+++ b/gcc/rust/ast/rust-ast-dump.cc
@@ -259,19 +259,44 @@ Dump::visit (MetaItemPathLit &meta_item)
 
 void
 Dump::visit (BorrowExpr &expr)
-{}
+{
+  stream << '&';
+  if (expr.get_is_double_borrow ())
+    stream << '&';
+  if (expr.get_is_mut ())
+    stream << "mut ";
+
+  expr.get_borrowed_expr ()->accept_vis (*this);
+}
 
 void
 Dump::visit (DereferenceExpr &expr)
-{}
+{
+  stream << '*';
+  expr.get_dereferenced_expr ()->accept_vis (*this);
+}
 
 void
 Dump::visit (ErrorPropagationExpr &expr)
-{}
+{
+  expr.get_propagating_expr ()->accept_vis (*this);
+  stream << '?';
+}
 
 void
 Dump::visit (NegationExpr &expr)
-{}
+{
+  switch (expr.get_expr_type ())
+    {
+    case NegationOperator::NEGATE:
+      stream << '-';
+      break;
+    case NegationOperator::NOT:
+      stream << '!';
+      break;
+    }
+  expr.get_negated_expr ()->accept_vis (*this);
+}
 
 void
 Dump::visit (ArithmeticOrLogicalExpr &expr)
@@ -381,7 +406,11 @@ Dump::visit (LazyBooleanExpr &expr)
 
 void
 Dump::visit (TypeCastExpr &expr)
-{}
+{
+  expr.get_casted_expr ()->accept_vis (*this);
+  stream << " as ";
+  expr.get_type_to_cast_to ()->accept_vis (*this);
+}
 
 void
 Dump::visit (AssignmentExpr &expr)
@@ -445,7 +474,11 @@ Dump::visit (CompoundAssignmentExpr &expr)
 
 void
 Dump::visit (GroupedExpr &expr)
-{}
+{
+  stream << '(';
+  expr.get_expr_in_parens ()->accept_vis (*this);
+  stream << ')';
+}
 
 void
 Dump::visit (ArrayElemsValues &elems)

                 reply	other threads:[~2023-02-21 11:57 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230221115740.F245F385B539@sourceware.org \
    --to=cohenarthur@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).