aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2022-10-06 09:11:43 +0000
committerGitHub <noreply@github.com>2022-10-06 09:11:43 +0000
commit82971d968b02eedf8e21bda681a27c9e5a3547fe (patch)
tree12a1ae474caaefc7df006e253ee62a46fa8743db
parent8ff035ddc55079161d24941785114aa0f5056260 (diff)
parente9e5288a303df10829d1f34e3d2ebff793a74ea0 (diff)
downloadgcc-82971d968b02eedf8e21bda681a27c9e5a3547fe.zip
gcc-82971d968b02eedf8e21bda681a27c9e5a3547fe.tar.gz
gcc-82971d968b02eedf8e21bda681a27c9e5a3547fe.tar.bz2
Merge #1563
1563: ast: dump assignment and if expressions r=CohenArthur a=dafaust Co-authored-by: David Faust <david.faust@oracle.com>
-rw-r--r--gcc/rust/ast/rust-ast-dump.cc78
1 files changed, 73 insertions, 5 deletions
diff --git a/gcc/rust/ast/rust-ast-dump.cc b/gcc/rust/ast/rust-ast-dump.cc
index 8ad00b5..48497b7 100644
--- a/gcc/rust/ast/rust-ast-dump.cc
+++ b/gcc/rust/ast/rust-ast-dump.cc
@@ -281,11 +281,63 @@ Dump::visit (TypeCastExpr &expr)
void
Dump::visit (AssignmentExpr &expr)
-{}
+{
+ expr.visit_lhs (*this);
+ stream << " = ";
+ expr.visit_rhs (*this);
+}
void
Dump::visit (CompoundAssignmentExpr &expr)
-{}
+{
+ auto op = "";
+ switch (expr.get_expr_type ())
+ {
+ case CompoundAssignmentOperator::ADD:
+ op = "+";
+ break;
+
+ case CompoundAssignmentOperator::SUBTRACT:
+ op = "-";
+ break;
+
+ case CompoundAssignmentOperator::MULTIPLY:
+ op = "*";
+ break;
+
+ case CompoundAssignmentOperator::DIVIDE:
+ op = "/";
+ break;
+
+ case CompoundAssignmentOperator::MODULUS:
+ op = "%";
+ break;
+
+ case CompoundAssignmentOperator::BITWISE_AND:
+ op = "&";
+ break;
+
+ case CompoundAssignmentOperator::BITWISE_OR:
+ op = "|";
+ break;
+
+ case CompoundAssignmentOperator::BITWISE_XOR:
+ op = "^";
+ break;
+
+ case CompoundAssignmentOperator::LEFT_SHIFT:
+ op = "<<";
+ break;
+
+ case CompoundAssignmentOperator::RIGHT_SHIFT:
+ op = ">>";
+ break;
+ }
+
+ expr.get_left_expr ()->accept_vis (*this);
+ stream << " " << op << "= ";
+ expr.get_right_expr ()->accept_vis (*this);
+}
void
Dump::visit (GroupedExpr &expr)
@@ -457,15 +509,31 @@ Dump::visit (ForLoopExpr &expr)
void
Dump::visit (IfExpr &expr)
-{}
+{
+ stream << "if ";
+ expr.vis_if_condition (*this);
+ expr.vis_if_block (*this);
+}
void
Dump::visit (IfExprConseqElse &expr)
-{}
+{
+ stream << "if ";
+ expr.vis_if_condition (*this);
+ expr.vis_if_block (*this);
+ stream << indentation << "else ";
+ expr.vis_else_block (*this);
+}
void
Dump::visit (IfExprConseqIf &expr)
-{}
+{
+ stream << "if ";
+ expr.vis_if_condition (*this);
+ expr.vis_if_block (*this);
+ stream << indentation << "else if ";
+ expr.vis_conseq_if_expr (*this);
+}
void
Dump::visit (IfExprConseqIfLet &expr)