summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2019-11-09 20:00:01 +0800
committerJohn Hodge <tpg@mutabah.net>2019-11-09 20:00:01 +0800
commit77537e2059497acb2bbcf5b49dacd43160717b88 (patch)
tree26d6cdfc69f0715a797e2354d060324cdd1ad61a
parent30a09a8c7cf08b03b3d11229c5eb20467f296ce5 (diff)
downloadmrust-77537e2059497acb2bbcf5b49dacd43160717b88.tar.gz
MIR Gen - Delete HIR once MIR is created (replace with a small node)
-rw-r--r--src/mir/from_hir.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/mir/from_hir.cpp b/src/mir/from_hir.cpp
index 697f8141..1c1a9c69 100644
--- a/src/mir/from_hir.cpp
+++ b/src/mir/from_hir.cpp
@@ -2597,12 +2597,21 @@ void HIR_GenerateMIR_Expr(const ::HIR::Crate& crate, const ::HIR::ItemPath& path
void HIR_GenerateMIR(::HIR::Crate& crate)
{
- ::MIR::OuterVisitor ov { crate, [&](const auto& res, const auto& p, auto& expr_ptr, const auto& args, const auto& ty){
+ ::MIR::OuterVisitor ov { crate, [&](const auto& res, const auto& p, ::HIR::ExprPtr& expr_ptr, const auto& args, const auto& ty){
if( !expr_ptr.get_mir_opt() )
{
expr_ptr.set_mir( LowerMIR(res, p, expr_ptr, ty, args) );
}
} };
ov.visit_crate(crate);
+
+ // Once MIR is generated, free the HIR expression tree (replace each node with an empty tuple node)
+ ::MIR::OuterVisitor ov_free(crate, [&](const auto& res, const auto& p, ::HIR::ExprPtr& expr_ptr, const auto& args, const auto& ty){
+ if( expr_ptr )
+ {
+ expr_ptr.reset(new ::HIR::ExprNode_Tuple(expr_ptr->m_span, {}));
+ }
+ });
+ ov_free.visit_crate(crate);
}