diff options
author | John Hodge <tpg@mutabah.net> | 2016-11-20 10:48:19 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-11-20 10:48:19 +0800 |
commit | 2248931ac65ad72736c203aa7ce327113e282440 (patch) | |
tree | 80da5e5fc27d709fa228544ed0086696d7155746 /src | |
parent | 4dd28709d6dde4230b6c83be66137c0e194ba449 (diff) | |
download | mrust-2248931ac65ad72736c203aa7ce327113e282440.tar.gz |
MIR Gen - Treat a loop as a split scope
Diffstat (limited to 'src')
-rw-r--r-- | src/mir/mir_builder.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/mir/mir_builder.cpp b/src/mir/mir_builder.cpp index 73867918..9c241339 100644 --- a/src/mir/mir_builder.cpp +++ b/src/mir/mir_builder.cpp @@ -411,9 +411,9 @@ void MirBuilder::terminate_scope(const Span& sp, ScopeHandle scope, bool emit_cl { DEBUG("DONE scope " << scope.idx); // 1. Check that this is the current scope (at the top of the stack) - if( m_scope_stack.back() != scope.idx ) + if( m_scope_stack.empty() || m_scope_stack.back() != scope.idx ) { - DEBUG("m_scope_stack = " << m_scope_stack); + DEBUG("- m_scope_stack = [" << m_scope_stack << "]"); auto it = ::std::find( m_scope_stack.begin(), m_scope_stack.end(), scope.idx ); if( it == m_scope_stack.end() ) BUG(sp, "Terminating scope not on the stack - scope " << scope.idx); @@ -504,16 +504,17 @@ void MirBuilder::end_split_arm(const Span& sp, const ScopeHandle& handle, bool r 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() ) + while( ! m_scope_stack.empty() && ! (m_scopes.at( m_scope_stack.back() ).data.is_Split() || m_scopes.at( m_scope_stack.back() ).data.is_Loop()) ) { auto& scope_def = m_scopes[m_scope_stack.back()]; // Fully drop the scope + DEBUG("Complete scope " << m_scope_stack.size()-1); drop_scope_values(scope_def); m_scope_stack.pop_back(); complete_scope(scope_def); } - if( !m_scope_stack.empty() ) + if( !m_scope_stack.empty() && m_scopes.at( m_scope_stack.back() ).data.is_Split() ) { auto& sd = m_scopes[ m_scope_stack.back() ]; auto& sd_split = sd.data.as_Split(); |