public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Thomas Schwinge <tschwinge@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc/devel/rust/master] ast: dump: ComparisonExpr and LazyBooleanExpr
Date: Sat, 15 Oct 2022 09:15:48 +0000 (GMT)	[thread overview]
Message-ID: <20221015091548.43A503858298@sourceware.org> (raw)

https://gcc.gnu.org/g:191907df1fd4d09567cc1e05835564df727cfb13

commit 191907df1fd4d09567cc1e05835564df727cfb13
Author: David Faust <david.faust@oracle.com>
Date:   Thu Oct 13 09:28:33 2022 -0700

    ast: dump: ComparisonExpr and LazyBooleanExpr

Diff:
---
 gcc/rust/ast/rust-ast-dump.cc | 50 +++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 48 insertions(+), 2 deletions(-)

diff --git a/gcc/rust/ast/rust-ast-dump.cc b/gcc/rust/ast/rust-ast-dump.cc
index 1ba84b8efa1..ddc43b33512 100644
--- a/gcc/rust/ast/rust-ast-dump.cc
+++ b/gcc/rust/ast/rust-ast-dump.cc
@@ -327,11 +327,57 @@ Dump::visit (ArithmeticOrLogicalExpr &expr)
 
 void
 Dump::visit (ComparisonExpr &expr)
-{}
+{
+  auto op = "";
+  switch (expr.get_expr_type ())
+    {
+    case ComparisonOperator::EQUAL:
+      op = "==";
+      break;
+    case ComparisonOperator::NOT_EQUAL:
+      op = "!=";
+      break;
+
+    case ComparisonOperator::GREATER_THAN:
+      op = ">";
+      break;
+
+    case ComparisonOperator::LESS_THAN:
+      op = "<";
+      break;
+
+    case ComparisonOperator::GREATER_OR_EQUAL:
+      op = ">=";
+      break;
+
+    case ComparisonOperator::LESS_OR_EQUAL:
+      op = "<=";
+      break;
+    }
+
+  expr.get_left_expr ()->accept_vis (*this);
+  stream << " " << op << " ";
+  expr.get_right_expr ()->accept_vis (*this);
+}
 
 void
 Dump::visit (LazyBooleanExpr &expr)
-{}
+{
+  auto op = "";
+  switch (expr.get_expr_type ())
+    {
+    case LazyBooleanOperator::LOGICAL_AND:
+      op = "&&";
+      break;
+    case LazyBooleanOperator::LOGICAL_OR:
+      op = "||";
+      break;
+    }
+
+  expr.get_left_expr ()->accept_vis (*this);
+  stream << " " << op << " ";
+  expr.get_right_expr ()->accept_vis (*this);
+}
 
 void
 Dump::visit (TypeCastExpr &expr)

                 reply	other threads:[~2022-10-15  9:15 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=20221015091548.43A503858298@sourceware.org \
    --to=tschwinge@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).