diff options
author | John Hodge <tpg@ucc.asn.au> | 2017-06-23 11:32:46 +0800 |
---|---|---|
committer | John Hodge <tpg@ucc.asn.au> | 2017-06-23 11:32:46 +0800 |
commit | d514aee4850933e3d3d5529453aa2c8af250d4ce (patch) | |
tree | 8e80b82dc8598b97d844f7d6c562afe07cbf7dd4 | |
parent | 239b7826470dab3effc703b33d4d7a2a761c461e (diff) | |
download | mrust-d514aee4850933e3d3d5529453aa2c8af250d4ce.tar.gz |
MIR Gen - Disable argument replacement until argument states are tracked fully
-rw-r--r-- | src/mir/from_hir.hpp | 3 | ||||
-rw-r--r-- | src/mir/mir_builder.cpp | 18 |
2 files changed, 18 insertions, 3 deletions
diff --git a/src/mir/from_hir.hpp b/src/mir/from_hir.hpp index ce310945..f8834d98 100644 --- a/src/mir/from_hir.hpp +++ b/src/mir/from_hir.hpp @@ -175,9 +175,12 @@ public: // - Values ::MIR::LValue get_variable(const Span& sp, unsigned idx) const { + // DIASBLED: State tracking doesn't support arguments in loops/splits +#if 0 auto it = m_var_arg_mappings.find(idx); if(it != m_var_arg_mappings.end()) return ::MIR::LValue::make_Argument({ it->second }); +#endif return ::MIR::LValue::make_Local( idx ); } ::MIR::LValue new_temporary(const ::HIR::TypeRef& ty); diff --git a/src/mir/mir_builder.cpp b/src/mir/mir_builder.cpp index 1549d39a..0d5641ff 100644 --- a/src/mir/mir_builder.cpp +++ b/src/mir/mir_builder.cpp @@ -60,8 +60,9 @@ MirBuilder::~MirBuilder() { push_stmt_assign( sp, ::MIR::LValue::make_Return({}), get_result(sp) ); } - terminate_scope( sp, ScopeHandle { *this, 1 } ); - terminate_scope( sp, mv$(m_fcn_scope) ); + + terminate_scope_early(sp, fcn_scope()); + end_block( ::MIR::Terminator::make_Return({}) ); } } @@ -83,7 +84,7 @@ const ::HIR::TypeRef* MirBuilder::is_type_owned_box(const ::HIR::TypeRef& ty) co if( pe.m_path != *m_lang_Box ) { return nullptr; } - // TODO: Properly assert? + // TODO: Properly assert the size? return &pe.m_params.m_types.at(0); } else @@ -939,6 +940,17 @@ void MirBuilder::terminate_scope_early(const Span& sp, const ScopeHandle& scope, ) } } + + + // Index 0 is the function scope, this only happens when about to return/panic + if( scope.idx == 0 ) + { + // Ensure that all arguments are dropped if they were not moved + for(size_t i = 0; i < m_arg_states.size(); i ++) + { + this->drop_value_from_state(sp, m_arg_states[i], ::MIR::LValue::make_Argument({ static_cast<unsigned>(i) })); + } + } } namespace |