diff options
author | John Hodge <tpg@mutabah.net> | 2015-06-04 16:57:16 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2015-06-04 16:57:16 +0800 |
commit | f2c96d7c448934baec49c91b5cb2ac7c05562437 (patch) | |
tree | d0b3ebedb6754d7aaf0b49265371d80066a8942b /src/convert/resolve.cpp | |
parent | f15fcf3c440e3c9c40fa606b0904fb85a8510464 (diff) | |
download | mrust-f2c96d7c448934baec49c91b5cb2ac7c05562437.tar.gz |
Resolve running once more, seems to be good
Diffstat (limited to 'src/convert/resolve.cpp')
-rw-r--r-- | src/convert/resolve.cpp | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/convert/resolve.cpp b/src/convert/resolve.cpp index 54b0ab39..68633dc8 100644 --- a/src/convert/resolve.cpp +++ b/src/convert/resolve.cpp @@ -579,9 +579,17 @@ bool CPathResolver::find_mod_item(AST::Path& path) { bool CPathResolver::find_super_mod_item(AST::Path& path) {
if( m_module->name() == "" )
throw ParseError::Todo("Correct handling of 'super' in anon modules");
- // 1.
- // TODO: lookup_path_in_module
- throw ParseError::Todo("Handle 'super'");
+
+ // 1. Construct path to parent module
+ AST::Path super_path = m_module_path;
+ super_path.nodes().pop_back();
+ assert( super_path.nodes().size() > 0 );
+ if( super_path.nodes().back().name()[0] == '#' )
+ throw ParseError::Todo("Correct handling of 'super' in anon modules (parent is anon)");
+ // 2. Resolve that path
+ super_path.resolve(m_crate);
+ // 3. Call lookup_path_in_module
+ return lookup_path_in_module(m_crate, super_path.binding().bound_module(), super_path, path);
}
bool CPathResolver::find_type_param(const ::std::string& name) {
for( auto it = m_locals.end(); it -- != m_locals.begin(); )
@@ -628,11 +636,14 @@ void CPathResolver::handle_type(TypeRef& type) {
const auto& name = type.type_param();
auto opt_local = lookup_local(LocalItem::TYPE, name);
- /*if( name == "Self" )
+ if( name == "Self" )
{
// Good as it is
+ // - TODO: Allow replacing this with the real Self (e.g. in an impl block)
+ // - NEED to annotate with the relevant impl block, and with other bounds
+ // > So that you can handle 'where Self: Sized' etc
}
- else*/ if( opt_local.is_some() )
+ else if( opt_local.is_some() )
{
type = opt_local.unwrap().tr;
}
|