summaryrefslogtreecommitdiff
path: root/src/hir_expand/vtable.cpp
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2018-02-25 20:06:11 +0800
committerJohn Hodge <tpg@mutabah.net>2018-02-25 20:06:11 +0800
commitefc32154cf37aaec675eb0031c030e3032f94c10 (patch)
tree813c148ce1f165cc0896435c4635d1a6f192ccde /src/hir_expand/vtable.cpp
parentfdd7f1974bfccd9831ea273529866a57433750ee (diff)
downloadmrust-efc32154cf37aaec675eb0031c030e3032f94c10.tar.gz
HIR+Codegen C - Encode drop/size/align in VTables at HIR level, working on MSVC compilation
Diffstat (limited to 'src/hir_expand/vtable.cpp')
-rw-r--r--src/hir_expand/vtable.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/hir_expand/vtable.cpp b/src/hir_expand/vtable.cpp
index 45e531b8..81c0de00 100644
--- a/src/hir_expand/vtable.cpp
+++ b/src/hir_expand/vtable.cpp
@@ -186,6 +186,18 @@ namespace {
};
VtableConstruct vtc { this, &tr, {} };
+ // - Drop glue pointer
+ ::HIR::FunctionType ft;
+ ft.is_unsafe = false;
+ ft.m_abi = ABI_RUST;
+ ft.m_rettype.reset( new ::HIR::TypeRef(::HIR::TypeRef::new_unit()) );
+ ft.m_arg_types.push_back( ::HIR::TypeRef::new_pointer(::HIR::BorrowType::Owned, ::HIR::TypeRef::new_unit()) );
+ vtc.fields.push_back(::std::make_pair( "#drop_glue", ::HIR::VisEnt<::HIR::TypeRef> { false, ::HIR::TypeRef(mv$(ft)) } ));
+ // - Size of data
+ vtc.fields.push_back(::std::make_pair( "#size", ::HIR::VisEnt<::HIR::TypeRef> { false, ::HIR::CoreType::Usize } ));
+ // - Alignment of data
+ vtc.fields.push_back(::std::make_pair( "#align", ::HIR::VisEnt<::HIR::TypeRef> { false, ::HIR::CoreType::Usize } ));
+ // - Add methods
if( ! vtc.add_ents_from_trait(tr, trait_path) )
{
tr.m_value_indexes.clear();