diff options
author | John Hodge <tpg@ucc.asn.au> | 2019-01-28 15:39:24 +0800 |
---|---|---|
committer | John Hodge <tpg@ucc.asn.au> | 2019-01-28 15:39:24 +0800 |
commit | 2fc8e093a36a8b39d4937b1f863fe1d471350fdd (patch) | |
tree | fd1b76e230b02a3928821a3b14a5a48266d4ec35 /src/ast/path.cpp | |
parent | 28b71bb7098339085a85d6e4eb4813b4eee4b73d (diff) | |
download | mrust-2fc8e093a36a8b39d4937b1f863fe1d471350fdd.tar.gz |
Resolve Use - More correct handling of publicity in wildcard imports
Diffstat (limited to 'src/ast/path.cpp')
-rw-r--r-- | src/ast/path.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/ast/path.cpp b/src/ast/path.cpp index 092f5962..d156f465 100644 --- a/src/ast/path.cpp +++ b/src/ast/path.cpp @@ -230,6 +230,28 @@ AST::Path::Path(const Path& x): ) } +bool Path::is_parent_of(const Path& x) const +{ + if( !this->m_class.is_Absolute() || !x.m_class.is_Absolute() ) + return false; + const auto& te = this->m_class.as_Absolute(); + const auto& xe = x.m_class.as_Absolute(); + + if( te.crate != xe.crate ) + return false; + + if( te.nodes.size() > xe.nodes.size() ) + return false; + + for(size_t i = 0; i < te.nodes.size(); i ++) + { + if( te.nodes[i].name() != xe.nodes[i].name() ) + return false; + } + + return true; +} + void Path::bind_variable(unsigned int slot) { m_bindings.value = PathBinding_Value::make_Variable({slot}); |