diff options
Diffstat (limited to 'gcc/rust/backend/rust-compile-expr.h')
-rw-r--r-- | gcc/rust/backend/rust-compile-expr.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/gcc/rust/backend/rust-compile-expr.h b/gcc/rust/backend/rust-compile-expr.h index c9d3c30..8ed84c7 100644 --- a/gcc/rust/backend/rust-compile-expr.h +++ b/gcc/rust/backend/rust-compile-expr.h @@ -388,6 +388,23 @@ public: ctx->add_statement (assignment); } + void visit (HIR::CompoundAssignmentExpr &expr) override + { + fncontext fn = ctx->peek_fn (); + auto lvalue = CompileExpr::Compile (expr.get_left_expr ().get (), ctx); + auto rvalue = CompileExpr::Compile (expr.get_right_expr ().get (), ctx); + + auto op = expr.get_expr_type (); + auto operator_expr = ctx->get_backend ()->arithmetic_or_logical_expression ( + op, lvalue, rvalue, expr.get_locus ()); + + Bstatement *assignment + = ctx->get_backend ()->assignment_statement (fn.fndecl, lvalue, + operator_expr, + expr.get_locus ()); + ctx->add_statement (assignment); + } + void visit (HIR::ArrayIndexExpr &expr) override { Bexpression *array = CompileExpr::Compile (expr.get_array_expr (), ctx); |