summaryrefslogtreecommitdiff
path: root/src/mir/mir_builder.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mir/mir_builder.cpp')
-rw-r--r--src/mir/mir_builder.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/mir/mir_builder.cpp b/src/mir/mir_builder.cpp
index cd7ddbcd..c0bf34a1 100644
--- a/src/mir/mir_builder.cpp
+++ b/src/mir/mir_builder.cpp
@@ -263,6 +263,7 @@ void MirBuilder::push_stmt_drop(const Span& sp, ::MIR::LValue val)
return ;
}
+ DEBUG("DROP " << val);
m_output.blocks.at(m_current_block).statements.push_back( ::MIR::Statement::make_Drop({ ::MIR::eDropKind::DEEP, mv$(val) }) );
}
void MirBuilder::push_stmt_drop_shallow(const Span& sp, ::MIR::LValue val)
@@ -276,6 +277,7 @@ void MirBuilder::push_stmt_drop_shallow(const Span& sp, ::MIR::LValue val)
// return ;
//}
+ DEBUG("DROP shallow " << val);
m_output.blocks.at(m_current_block).statements.push_back( ::MIR::Statement::make_Drop({ ::MIR::eDropKind::SHALLOW, mv$(val) }) );
}
@@ -341,9 +343,15 @@ void MirBuilder::raise_variables(const Span& sp, const ::MIR::LValue& val)
TU_MATCH_DEF(::MIR::LValue, (val), (e),
(
),
+ // TODO: This may not be correct, because it can change the drop points and ordering
+ // HACK: Working around cases where values are dropped while the result is not yet used.
(Deref,
- // TODO: This may not be correct, because it can change the drop points and ordering
- // HACK: Working around cases where values are dropped while the result is not yet used.
+ raise_variables(sp, *e.val);
+ ),
+ (Field,
+ raise_variables(sp, *e.val);
+ ),
+ (Downcast,
raise_variables(sp, *e.val);
),
// Actual value types
@@ -821,6 +829,7 @@ void MirBuilder::complete_scope(ScopeDef& sd)
DEBUG(i << " (_,"<<new_state<<")");
m_changed[i] = true;
m_new_states[i] = new_state;
+ // TODO: Store the original state for comparison?
}
else
{
@@ -1223,6 +1232,7 @@ void MirBuilder::drop_scope_values(const ScopeDef& sd)
break;
case VarState::InnerMoved:
push_stmt_drop_shallow( sd.span, ::MIR::LValue::make_Variable(var_idx) );
+ set_variable_state(sd.span, var_idx, VarState::Dropped);
break;
case VarState::MaybeMoved:
//TODO(sd.span, "Include drop flags");