diff options
Diffstat (limited to 'gcc/rust/backend/rust-compile-expr.h')
-rw-r--r-- | gcc/rust/backend/rust-compile-expr.h | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/gcc/rust/backend/rust-compile-expr.h b/gcc/rust/backend/rust-compile-expr.h index c63479c..842804d 100644 --- a/gcc/rust/backend/rust-compile-expr.h +++ b/gcc/rust/backend/rust-compile-expr.h @@ -816,6 +816,37 @@ public: ctx->add_statement (goto_label); } + void visit (HIR::BorrowExpr &expr) + { + Bexpression *main_expr + = CompileExpr::Compile (expr.get_expr ().get (), ctx); + + translated + = ctx->get_backend ()->address_expression (main_expr, expr.get_locus ()); + } + + void visit (HIR::DereferenceExpr &expr) + { + Bexpression *main_expr + = CompileExpr::Compile (expr.get_expr ().get (), ctx); + + TyTy::TyBase *tyty = nullptr; + if (!ctx->get_tyctx ()->lookup_type (expr.get_mappings ().get_hirid (), + &tyty)) + { + rust_fatal_error (expr.get_locus (), + "did not resolve type for this TupleExpr"); + return; + } + + Btype *expected_type = TyTyResolveCompile::compile (ctx, tyty); + bool known_valid = true; + translated + = ctx->get_backend ()->indirect_expression (expected_type, main_expr, + known_valid, + expr.get_locus ()); + } + private: CompileExpr (Context *ctx) : HIRCompileBase (ctx), translated (nullptr) {} |