diff options
author | John Hodge <tpg@mutabah.net> | 2016-12-28 14:39:59 +1100 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-12-28 14:39:59 +1100 |
commit | 583686bd2ebef786e1396ecaff4c61a984135b74 (patch) | |
tree | 713480e2d3e1eb34419bcb29e59166a878e1f2fe /src | |
parent | 45eaa2b6b40a501c4eea7e3c3e04ba9de2dd7f5d (diff) | |
download | mrust-583686bd2ebef786e1396ecaff4c61a984135b74.tar.gz |
MIR Gen - Spaces removed, misc thinking
Diffstat (limited to 'src')
-rw-r--r-- | src/mir/from_hir.cpp | 8 | ||||
-rw-r--r-- | src/mir/from_hir.hpp | 19 | ||||
-rw-r--r-- | src/mir/from_hir_match.cpp | 8 | ||||
-rw-r--r-- | src/mir/mir_builder.cpp | 2 |
4 files changed, 20 insertions, 17 deletions
diff --git a/src/mir/from_hir.cpp b/src/mir/from_hir.cpp index 40b5a848..9f44df41 100644 --- a/src/mir/from_hir.cpp +++ b/src/mir/from_hir.cpp @@ -547,7 +547,9 @@ namespace { target_block = &*it; } - // TODO: Insert drop of all active scopes within the loop + // TODO: Add the current variable state (of variables above the loop scope) to the loop scope + // - Allowing the state after the loop is complete to be known. + m_builder.terminate_scope_early( node.span(), target_block->scope ); if( node.m_continue ) { m_builder.end_block( ::MIR::Terminator::make_Goto(target_block->cur) ); @@ -1461,7 +1463,7 @@ namespace { for(auto& arg : node.m_args) { this->visit_node_ptr(arg); - + if( node.m_args.size() == 1 ) { values.push_back( m_builder.get_result_in_lvalue(arg->span(), arg->m_res_type) ); @@ -1473,7 +1475,7 @@ namespace { m_builder.push_stmt_assign( arg->span(), tmp.clone(), m_builder.get_result(arg->span()) ); values.push_back( mv$(tmp) ); } - + m_builder.moved_lvalue( arg->span(), values.back() ); } diff --git a/src/mir/from_hir.hpp b/src/mir/from_hir.hpp index aae19d97..b89e8750 100644 --- a/src/mir/from_hir.hpp +++ b/src/mir/from_hir.hpp @@ -46,15 +46,15 @@ enum class InvalidType { Descoped, }; TAGGED_UNION(VarState, Uninit, -// Currently invalid -(Invalid, InvalidType), -// Partially valid (Map of field states, Box is assumed to have one field) -(Partial, ::std::vector<VarState>), -// Optionally valid (integer indicates the drop flag index) -(Optional, unsigned int), -// Fully valid -(Valid, struct {}), -) + // Currently invalid + (Invalid, InvalidType), + // Partially valid (Map of field states, Box is assumed to have one field) + (Partial, ::std::vector<VarState>), + // Optionally valid (integer indicates the drop flag index) + (Optional, unsigned int), + // Fully valid + (Valid, struct {}), + ) #endif // TODO: Replace the first three states with just one (and flags for init/moved) @@ -91,6 +91,7 @@ TAGGED_UNION(ScopeType, Variables, ::std::vector<SplitArm> arms; }), (Loop, struct { + ::std::vector<SplitArm> exit_states; }) ); diff --git a/src/mir/from_hir_match.cpp b/src/mir/from_hir_match.cpp index a8752a73..183d6418 100644 --- a/src/mir/from_hir_match.cpp +++ b/src/mir/from_hir_match.cpp @@ -300,7 +300,7 @@ void MIR_LowerHIR_Match( MirBuilder& builder, MirConverter& conv, ::HIR::ExprNod // NOTE: Terminating the scope slightly early is safe, because the resulting boolean temp isn't invalidated. builder.terminate_scope( arm.m_code->span(), mv$(tmp_scope) ); ac.cond_end = builder.pause_cur_block(); - + // NOTE: Paused so that later code (which knows what the false branch will be) can end it correctly // TODO: What to do with contidionals in the fast model? @@ -314,12 +314,12 @@ void MIR_LowerHIR_Match( MirBuilder& builder, MirConverter& conv, ::HIR::ExprNod // Code DEBUG("-- Body Code"); - + ac.code = builder.new_bb_unlinked(); auto tmp_scope = builder.new_scope_temp(arm.m_code->span()); builder.set_cur_block( ac.code ); conv.visit_node_ptr( arm.m_code ); - + if( !builder.block_active() && !builder.has_result() ) { DEBUG("Arm diverged"); // Nothing need be done, as the block diverged. @@ -382,7 +382,7 @@ void MIR_LowerHIR_Match( MirBuilder& builder, MirConverter& conv, ::HIR::ExprNod { DEBUG("> (" << arm_rule.arm_idx << ", " << arm_rule.pat_idx << ") - " << arm_rule.m_rules); } - + // TODO: Don't generate inner code until decisions are generated (keeps MIR flow nice) // TODO: Detect if a rule is ordering-dependent. In this case we currently have to fall back on the simple match code diff --git a/src/mir/mir_builder.cpp b/src/mir/mir_builder.cpp index 92c21286..9af721a2 100644 --- a/src/mir/mir_builder.cpp +++ b/src/mir/mir_builder.cpp @@ -413,7 +413,7 @@ void MirBuilder::raise_variables(const Span& sp, const ::MIR::LValue& val, const break ; } ) - + // If the temporary was defined above the desired scope (i.e. this didn't find it), return if( *scope_it == scope.idx ) return ; |