summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2016-08-10 10:26:01 +0800
committerJohn Hodge <tpg@mutabah.net>2016-08-10 10:26:01 +0800
commit2f362de81877b09a568a02d1786e138dfd0c7710 (patch)
tree28c61c38f81cb45a3c8789ac05d51a1693c77c67
parent96db5a6bfca3900ad58ae0e9a7ff737da441f303 (diff)
downloadmrust-2f362de81877b09a568a02d1786e138dfd0c7710.tar.gz
MIR - Fix bad `if` codegen
-rw-r--r--src/mir/from_hir.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/mir/from_hir.cpp b/src/mir/from_hir.cpp
index a0dad18a..dcbeff0a 100644
--- a/src/mir/from_hir.cpp
+++ b/src/mir/from_hir.cpp
@@ -400,22 +400,24 @@ namespace {
this->set_cur_block(true_branch);
this->visit_node_ptr(node.m_true);
- this->end_block( ::MIR::Terminator::make_Goto(next_block) );
this->push_stmt_assign( ::MIR::LValue::make_Temporary({result_val.as_Temporary().idx}), this->get_result(node.m_true->span()) );
+ this->end_block( ::MIR::Terminator::make_Goto(next_block) );
this->set_cur_block(false_branch);
if( node.m_false )
{
this->visit_node_ptr(node.m_false);
+ this->push_stmt_assign( result_val.clone(), this->get_result(node.m_false->span()) );
this->end_block( ::MIR::Terminator::make_Goto(next_block) );
- this->push_stmt_assign( ::MIR::LValue::make_Temporary({result_val.as_Temporary().idx}), this->get_result(node.m_false->span()) );
}
else
{
// TODO: Assign `()` to the result
+ this->push_stmt_assign( result_val.clone(), ::MIR::RValue::make_Tuple({}) );
+ this->end_block( ::MIR::Terminator::make_Goto(next_block) );
}
-
this->set_cur_block(next_block);
+
this->set_result( node.span(), mv$(result_val) );
}
@@ -732,12 +734,12 @@ namespace {
}
void visit(::HIR::ExprNode_PathValue& node) override
{
- TRACE_FUNCTION_F("_PathValue");
+ TRACE_FUNCTION_F("_PathValue - " << node.m_path);
this->set_result( node.span(), ::MIR::LValue::make_Static(node.m_path.clone()) );
}
void visit(::HIR::ExprNode_Variable& node) override
{
- TRACE_FUNCTION_F("_Variable");
+ TRACE_FUNCTION_F("_Variable - " << node.m_name << " #" << node.m_slot);
this->set_result( node.span(), ::MIR::LValue::make_Variable(node.m_slot) );
}