From a98cb27dedfe3b5005ac2d7b6d876ced4b4b6fc7 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Sun, 11 Sep 2016 18:07:43 +0800 Subject: Resolve - Include binding for struct constructors/values --- src/resolve/index.cpp | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'src/resolve/index.cpp') diff --git a/src/resolve/index.cpp b/src/resolve/index.cpp index 70c25187..4e1766c6 100644 --- a/src/resolve/index.cpp +++ b/src/resolve/index.cpp @@ -172,10 +172,17 @@ void Resolve_Index_Module_Base(const AST::Crate& crate, AST::Module& mod) (Struct, _add_item_type(sp, mod, i.name, i.is_pub, i.data.path, !allow_collide); - // TODO: Items from extern crates don't populate e.struct_ correctly // - If the struct is a tuple-like struct, it presents in the value namespace - if( e.struct_ && e.struct_->m_data.is_Tuple() ) { - _add_item_value(sp, mod, i.name, i.is_pub, i.data.path, !allow_collide); + assert(e.struct_ || e.hir); + if( e.struct_ ) { + if( e.struct_->m_data.is_Tuple() ) { + _add_item_value(sp, mod, i.name, i.is_pub, i.data.path, !allow_collide); + } + } + else { + if( ! e.hir->m_data.is_Named() ) { + _add_item_value(sp, mod, i.name, i.is_pub, i.data.path, !allow_collide); + } } ), (Static , _add_item_value(sp, mod, i.name, i.is_pub, i.data.path, !allow_collide); ), @@ -282,10 +289,10 @@ void Resolve_Index_Module_Wildcard(AST::Crate& crate, AST::Module& mod, bool han p.bind( ::AST::PathBinding::make_Module({nullptr, &e}) ); ), (Trait, - p.bind( ::AST::PathBinding::make_Trait({nullptr/*, &e*/}) ); + p.bind( ::AST::PathBinding::make_Trait({nullptr, &e}) ); ), (Struct, - p.bind( ::AST::PathBinding::make_Struct({nullptr}) ); + p.bind( ::AST::PathBinding::make_Struct({nullptr, &e}) ); ), (Enum, p.bind( ::AST::PathBinding::make_Enum({nullptr}) ); @@ -337,11 +344,12 @@ void Resolve_Index_Module_Wildcard(AST::Crate& crate, AST::Module& mod, bool han (Static, p.bind( ::AST::PathBinding::make_Static({nullptr}) ); ), + // TODO: What if these refer to an enum variant? (StructConstant, - p.bind( ::AST::PathBinding::make_Struct({nullptr}) ); + p.bind( ::AST::PathBinding::make_Struct({ nullptr, &crate.m_extern_crates.at(e.ty.m_crate_name).m_hir->get_typeitem_by_path(sp, e.ty, true).as_Struct() }) ); ), (StructConstructor, - p.bind( ::AST::PathBinding::make_Struct({nullptr}) ); + p.bind( ::AST::PathBinding::make_Struct({ nullptr, &crate.m_extern_crates.at(e.ty.m_crate_name).m_hir->get_typeitem_by_path(sp, e.ty, true).as_Struct() }) ); ), (Function, p.bind( ::AST::PathBinding::make_Function({nullptr}) ); -- cgit v1.2.3