summaryrefslogtreecommitdiff
path: root/src/mir/mir_builder.cpp
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2016-09-06 18:36:56 +0800
committerJohn Hodge <tpg@mutabah.net>2016-09-06 18:36:56 +0800
commit84f82d42a8bd56f1f9dbd62d9d0255554002d315 (patch)
treefa9c5f2c49136f2ec7e793420e265c1a9c4c990a /src/mir/mir_builder.cpp
parentde087df3045bb802fe0de3cbb7859ca63d097d50 (diff)
downloadmrust-84f82d42a8bd56f1f9dbd62d9d0255554002d315.tar.gz
MIR Gen - Rough support for Box
Diffstat (limited to 'src/mir/mir_builder.cpp')
-rw-r--r--src/mir/mir_builder.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/mir/mir_builder.cpp b/src/mir/mir_builder.cpp
index 89141042..eb40f58b 100644
--- a/src/mir/mir_builder.cpp
+++ b/src/mir/mir_builder.cpp
@@ -16,10 +16,15 @@ MirBuilder::MirBuilder(const Span& sp, const StaticTraitResolve& resolve, const
m_resolve(resolve),
m_args(args),
m_output(output),
+ m_lang_Box(nullptr),
m_block_active(false),
m_result_valid(false),
m_fcn_scope(*this, 0)
{
+ if( resolve.m_crate.m_lang_items.count("owned_box") > 0 ) {
+ m_lang_Box = &resolve.m_crate.m_lang_items.at("owned_box");
+ }
+
set_cur_block( new_bb_unlinked() );
m_scopes.push_back( ScopeDef { sp } );
m_scope_stack.push_back( 0 );
@@ -652,6 +657,25 @@ void MirBuilder::with_val_type(const Span& sp, const ::MIR::LValue& val, ::std::
(
BUG(sp, "Deref on unexpected type - " << ty);
),
+ (Path,
+ if( m_lang_Box )
+ {
+ TU_IFLET( ::HIR::Path::Data, te.path.m_data, Generic, e,
+ if( e.m_path == *m_lang_Box ) {
+ cb( e.m_params.m_types.at(0) );
+ }
+ else {
+ BUG(sp, "Deref on unexpected type - " << ty);
+ }
+ )
+ else {
+ BUG(sp, "Deref on unexpected type - " << ty);
+ }
+ }
+ else {
+ BUG(sp, "Deref on unexpected type - " << ty);
+ }
+ ),
(Pointer,
cb(*te.inner);
),
@@ -910,6 +934,7 @@ void MirBuilder::moved_lvalue(const Span& sp, const ::MIR::LValue& lv)
if( lvalue_is_copy(sp, lv) ) {
}
else {
+ // TODO: Move out of owned_box _is_ valid, and marks the box slot for shallow drop
BUG(sp, "Move out of deref with non-Copy values - &move? - " << lv);
moved_lvalue(sp, *e.val);
}