diff options
author | John Hodge <tpg@mutabah.net> | 2016-10-21 11:22:30 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-10-21 11:22:30 +0800 |
commit | e9dbfca9c3cfbbfa1b018434dc88dbdea4727715 (patch) | |
tree | ae39db59a2b97421debcda2b4cad9c4c8f7fc99c /src/mir/from_hir.cpp | |
parent | d260219e365bd20300c1db7c9d984902eb20c253 (diff) | |
download | mrust-e9dbfca9c3cfbbfa1b018434dc88dbdea4727715.tar.gz |
HIR - Associated constant typecheck and MIR support
Diffstat (limited to 'src/mir/from_hir.cpp')
-rw-r--r-- | src/mir/from_hir.cpp | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/src/mir/from_hir.cpp b/src/mir/from_hir.cpp index 00b2f507..e5e11404 100644 --- a/src/mir/from_hir.cpp +++ b/src/mir/from_hir.cpp @@ -1553,15 +1553,22 @@ namespace { auto rv = m_builder.crate().find_type_impls(*pe.type, [&](const auto& ty)->const auto& { return ty; }, [&](const auto& impl) { DEBUG("- impl" << impl.m_params.fmt_args() << " " << impl.m_type); - auto it = impl.m_methods.find(pe.item); - if( it != impl.m_methods.end() ) { - // Function! - auto tmp = m_builder.new_temporary( node.m_res_type ); - m_builder.push_stmt_assign( sp, tmp.clone(), ::MIR::Constant::make_ItemAddr(node.m_path.clone()) ); - m_builder.set_result( sp, mv$(tmp) ); - return true; + // Associated functions + { + auto it = impl.m_methods.find(pe.item); + if( it != impl.m_methods.end() ) { + m_builder.set_result( sp, ::MIR::Constant::make_ItemAddr(node.m_path.clone()) ); + return true; + } + } + // Associated consts + { + auto it = impl.m_constants.find(pe.item); + if( it != impl.m_constants.end() ) { + m_builder.set_result( sp, ::MIR::Constant::make_Const({node.m_path.clone()}) ); + return true; + } } - // Associated consts (unimpl) // Associated static (undef) return false; }); |