aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Faust <david.faust@oracle.com>2022-10-13 10:15:05 -0700
committerDavid Faust <david.faust@oracle.com>2022-10-13 13:35:56 -0700
commit53e2df36a23e6f1ec820c5ef51bb07842c2ba0b7 (patch)
tree9e853a24560baf5dbf5d2869de3667af93f123c8
parent6927e3ee00d22bca1ef2d3e5e58a0705a7578067 (diff)
downloadgcc-53e2df36a23e6f1ec820c5ef51bb07842c2ba0b7.zip
gcc-53e2df36a23e6f1ec820c5ef51bb07842c2ba0b7.tar.gz
gcc-53e2df36a23e6f1ec820c5ef51bb07842c2ba0b7.tar.bz2
ast: dump: various simple Exprs
Adds dump for: - BorrowExpr - DereferenceExpr - ErrorPropagationExpr - NegationExpr - TypeCastExpr - GroupedExpr
-rw-r--r--gcc/rust/ast/rust-ast-dump.cc45
1 files changed, 39 insertions, 6 deletions
diff --git a/gcc/rust/ast/rust-ast-dump.cc b/gcc/rust/ast/rust-ast-dump.cc
index 91e540a..b9e08b5 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)