From e9dbfca9c3cfbbfa1b018434dc88dbdea4727715 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Fri, 21 Oct 2016 11:22:30 +0800 Subject: HIR - Associated constant typecheck and MIR support --- src/mir/from_hir.cpp | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'src/mir/from_hir.cpp') 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; }); -- cgit v1.2.3