diff options
author | John Hodge <tpg@mutabah.net> | 2016-10-14 19:04:28 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-10-14 19:04:28 +0800 |
commit | f6c60250561ab65f15a8453fe5b137cee6ad92a5 (patch) | |
tree | 7586de43d420abcb408bf774a64c689b988dc250 /src | |
parent | 0b7fec11f46ee3fcbe3726855c89029ebff884cf (diff) | |
download | mrust-f6c60250561ab65f15a8453fe5b137cee6ad92a5.tar.gz |
HIR From AST - Convert associated consts in trait impls
Diffstat (limited to 'src')
-rw-r--r-- | src/hir/from_ast.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/hir/from_ast.cpp b/src/hir/from_ast.cpp index 834c09b8..3fc9e7ee 100644 --- a/src/hir/from_ast.cpp +++ b/src/hir/from_ast.cpp @@ -1183,7 +1183,12 @@ void LowerHIR_Module_Impls(const ::AST::Module& ast_mod, ::HIR::Crate& hir_crat (MacroInv, ), (Static, - TODO(item.data->span, "Associated statics/constants in trait impl"); + if( e.s_class() == ::AST::Static::CONST ) { + constants.insert( ::std::make_pair(item.name, ::HIR::TraitImpl::ImplEnt< ::HIR::ExprPtr> { item.is_specialisable, LowerHIR_Expr(e.value()) }) ); + } + else { + TODO(item.data->span, "Associated statics in trait impl"); + } ), (Type, DEBUG("- type " << item.name); @@ -1230,7 +1235,9 @@ void LowerHIR_Module_Impls(const ::AST::Module& ast_mod, ::HIR::Crate& hir_crat // Inherent impls auto type = LowerHIR_Type(impl.def().type()); ::HIR::ItemPath path(type); + ::std::map< ::std::string, ::HIR::TypeImpl::VisImplEnt< ::HIR::Function> > methods; + ::std::map< ::std::string, ::HIR::TypeImpl::VisImplEnt< ::HIR::ExprPtr> > constants; for(const auto& item : impl.items()) { @@ -1244,7 +1251,13 @@ void LowerHIR_Module_Impls(const ::AST::Module& ast_mod, ::HIR::Crate& hir_crat (MacroInv, ), (Static, - TODO(item.data->span, "Associated statics/constants in inherent impl"); + if( e.s_class() == ::AST::Static::CONST ) { + constants.insert( ::std::make_pair(item.name, ::HIR::TypeImpl::VisImplEnt< ::HIR::ExprPtr> { item.is_pub, item.is_specialisable, LowerHIR_Expr(e.value()) }) ); + TODO(item.data->span, "Associated constants in inherent impl"); + } + else { + TODO(item.data->span, "Associated statics in inherent impl"); + } ), (Function, methods.insert( ::std::make_pair(item.name, ::HIR::TypeImpl::VisImplEnt< ::HIR::Function> { item.is_pub, item.is_specialisable, LowerHIR_Function(item_path, e, type) } ) ); |