From: David Faust Date: Wed, 5 Oct 2022 17:10:18 +0000 (-0700) Subject: gccrs: ast: dump assignment and compound assignment expr X-Git-Tag: upstream/13.1.0~1085 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=980bd25e25600b438680bc8ff69afc42d9718d94;p=platform%2Fupstream%2Fgcc.git gccrs: ast: dump assignment and compound assignment expr gcc/rust/ChangeLog: * ast/rust-ast-dump.cc (Dump::visit): Dump assignment and compound assignment expressions. --- diff --git a/gcc/rust/ast/rust-ast-dump.cc b/gcc/rust/ast/rust-ast-dump.cc index 3d1b42d..f3d0e2d 100644 --- a/gcc/rust/ast/rust-ast-dump.cc +++ b/gcc/rust/ast/rust-ast-dump.cc @@ -306,11 +306,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)