diff options
author | John Hodge <tpg@mutabah.net> | 2016-09-24 22:58:28 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-09-24 22:58:28 +0800 |
commit | 7fa72647893f4661b701da4344e8b40645fbb0e6 (patch) | |
tree | 5c63ee2080db7251583ac8f805a6190ab933dc10 /src/mir/mir_builder.cpp | |
parent | 8d8dcfa8484a134cace25983ae8682da464d3ca8 (diff) | |
download | mrust-7fa72647893f4661b701da4344e8b40645fbb0e6.tar.gz |
MIR Gen - Support zero-arm matches - Since they can never be reached, emit a Diverge
Diffstat (limited to 'src/mir/mir_builder.cpp')
-rw-r--r-- | src/mir/mir_builder.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/mir/mir_builder.cpp b/src/mir/mir_builder.cpp index f4f9db7e..c5564045 100644 --- a/src/mir/mir_builder.cpp +++ b/src/mir/mir_builder.cpp @@ -480,6 +480,25 @@ void MirBuilder::end_split_arm(const Span& sp, const ScopeHandle& handle, bool r // TODO: Undo moves from within the other scope sd_split.arms.push_back( {} ); } +void MirBuilder::end_split_arm_early(const Span& sp) +{ + // Terminate all scopes until a split is found. + while( ! m_scope_stack.empty() && ! m_scopes.at( m_scope_stack.back() ).data.is_Split() ) + { + auto& scope_def = m_scopes[m_scope_stack.back()]; + // Fully drop the scope + drop_scope_values(scope_def); + m_scope_stack.pop_back(); + complete_scope(scope_def); + } + + if( !m_scope_stack.empty() ) + { + auto& sd = m_scopes[ m_scope_stack.back() ]; + auto& sd_split = sd.data.as_Split(); + sd_split.arms.back().has_early_terminated = true; + } +} void MirBuilder::complete_scope(ScopeDef& sd) { sd.complete = true; |