[committed,027/103] gccrs: ast: dump: ComparisonExpr and LazyBooleanExpr

Message ID 20230221120230.596966-28-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 dumps for ComparisonExpr and
	LazyBooleanExpr.
---
 gcc/rust/ast/rust-ast-dump.cc | 50 +++++++++++++++++++++++++++++++++--
 1 file changed, 48 insertions(+), 2 deletions(-)
  

Patch

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)