diff options
author | John Hodge <tpg@mutabah.net> | 2016-10-15 10:49:58 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-10-15 10:49:58 +0800 |
commit | 843ef4abc659b3816e2a9f20622fef1a75240ecf (patch) | |
tree | f804abf08d8a6cbee4dc9fed43d7508127af03a6 /src/hir/from_ast.cpp | |
parent | f6c60250561ab65f15a8453fe5b137cee6ad92a5 (diff) | |
download | mrust-843ef4abc659b3816e2a9f20622fef1a75240ecf.tar.gz |
HIR - Rough support for associated consts
Diffstat (limited to 'src/hir/from_ast.cpp')
-rw-r--r-- | src/hir/from_ast.cpp | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/hir/from_ast.cpp b/src/hir/from_ast.cpp index 3fc9e7ee..3c7215f4 100644 --- a/src/hir/from_ast.cpp +++ b/src/hir/from_ast.cpp @@ -1168,7 +1168,7 @@ void LowerHIR_Module_Impls(const ::AST::Module& ast_mod, ::HIR::Crate& hir_crat DEBUG(path); ::std::map< ::std::string, ::HIR::TraitImpl::ImplEnt< ::HIR::Function> > methods; - ::std::map< ::std::string, ::HIR::TraitImpl::ImplEnt< ::HIR::ExprPtr> > constants; + ::std::map< ::std::string, ::HIR::TraitImpl::ImplEnt< ::HIR::Constant> > constants; ::std::map< ::std::string, ::HIR::TraitImpl::ImplEnt< ::HIR::TypeRef> > types; for(const auto& item : impl.items()) @@ -1184,7 +1184,11 @@ void LowerHIR_Module_Impls(const ::AST::Module& ast_mod, ::HIR::Crate& hir_crat ), (Static, 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()) }) ); + constants.insert( ::std::make_pair(item.name, ::HIR::TraitImpl::ImplEnt< ::HIR::Constant> { item.is_specialisable, ::HIR::Constant { + ::HIR::GenericParams {}, + LowerHIR_Type( e.type() ), + LowerHIR_Expr( e.value() ) + } }) ); } else { TODO(item.data->span, "Associated statics in trait impl"); @@ -1237,7 +1241,7 @@ void LowerHIR_Module_Impls(const ::AST::Module& ast_mod, ::HIR::Crate& hir_crat ::HIR::ItemPath path(type); ::std::map< ::std::string, ::HIR::TypeImpl::VisImplEnt< ::HIR::Function> > methods; - ::std::map< ::std::string, ::HIR::TypeImpl::VisImplEnt< ::HIR::ExprPtr> > constants; + ::std::map< ::std::string, ::HIR::TypeImpl::VisImplEnt< ::HIR::Constant> > constants; for(const auto& item : impl.items()) { @@ -1252,8 +1256,11 @@ void LowerHIR_Module_Impls(const ::AST::Module& ast_mod, ::HIR::Crate& hir_crat ), (Static, 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"); + constants.insert( ::std::make_pair(item.name, ::HIR::TypeImpl::VisImplEnt< ::HIR::Constant> { item.is_pub, item.is_specialisable, ::HIR::Constant { + ::HIR::GenericParams {}, + LowerHIR_Type( e.type() ), + LowerHIR_Expr( e.value() ) + } }) ); } else { TODO(item.data->span, "Associated statics in inherent impl"); @@ -1269,6 +1276,7 @@ void LowerHIR_Module_Impls(const ::AST::Module& ast_mod, ::HIR::Crate& hir_crat mv$(params), mv$(type), mv$(methods), + mv$(constants), LowerHIR_SimplePath(Span(), ast_mod.path()) } ); |