From 2fc8e093a36a8b39d4937b1f863fe1d471350fdd Mon Sep 17 00:00:00 2001 From: John Hodge Date: Mon, 28 Jan 2019 15:39:24 +0800 Subject: Resolve Use - More correct handling of publicity in wildcard imports --- src/ast/path.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/ast/path.cpp') 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}); -- cgit v1.2.3