mappings->get_next_hir_id (crate_num),
UNKNOWN_LOCAL_DEFID);
- translated = new HIR::BorrowExpr (
- mapping, std::unique_ptr<HIR::Expr> (borrow_lvalue),
- expr.get_is_mut () ? Mutability::Mut : Mutability::Imm,
- expr.get_is_double_borrow (), expr.get_outer_attrs (), expr.get_locus ());
+ HIR::BorrowExpr *borrow_expr
+ = new HIR::BorrowExpr (mapping,
+ std::unique_ptr<HIR::Expr> (borrow_lvalue),
+ expr.get_is_mut () ? Mutability::Mut
+ : Mutability::Imm,
+ expr.get_outer_attrs (), expr.get_locus ());
+
+ if (expr.get_is_double_borrow ())
+ {
+ NodeId artifical_bouble_borrow_id = mappings->get_next_node_id ();
+ Analysis::NodeMapping mapping (crate_num, artifical_bouble_borrow_id,
+ mappings->get_next_hir_id (crate_num),
+ UNKNOWN_LOCAL_DEFID);
+
+ borrow_expr
+ = new HIR::BorrowExpr (mapping,
+ std::unique_ptr<HIR::Expr> (borrow_expr),
+ expr.get_is_mut () ? Mutability::Mut
+ : Mutability::Imm,
+ expr.get_outer_attrs (), expr.get_locus ());
+ }
+
+ translated = borrow_expr;
}
void visit (AST::DereferenceExpr &expr) override
BorrowExpr (Analysis::NodeMapping mappings,
std::unique_ptr<Expr> borrow_lvalue, Mutability mut,
- bool is_double_borrow, AST::AttrVec outer_attribs, Location locus)
+ AST::AttrVec outer_attribs, Location locus)
: OperatorExpr (std::move (mappings), std::move (borrow_lvalue),
std::move (outer_attribs), locus),
- mut (mut), double_borrow (is_double_borrow)
+ mut (mut)
{}
void accept_vis (HIRFullVisitor &vis) override;
Mutability get_mut () const { return mut; }
bool is_mut () const { return mut == Mutability::Mut; }
- bool get_is_double_borrow () const { return double_borrow; }
protected:
/* Use covariance to implement clone function as returning this object rather