summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ast/path.cpp5
-rw-r--r--src/ast/path.hpp2
-rw-r--r--src/convert/resolve.cpp4
-rw-r--r--src/main.cpp3
4 files changed, 13 insertions, 1 deletions
diff --git a/src/ast/path.cpp b/src/ast/path.cpp
index 2cfd6b98..686647a5 100644
--- a/src/ast/path.cpp
+++ b/src/ast/path.cpp
@@ -255,6 +255,7 @@ void Path::resolve(const Crate& root_crate)
*this = newpath;
DEBUG("Alias resolved, *this = " << *this);
+ return;
}
else
{
@@ -271,6 +272,7 @@ void Path::resolve(const Crate& root_crate)
*this = newpath;
DEBUG("Alias resolved, *this = " << *this);
+ return;
}
break; }
}
@@ -349,6 +351,8 @@ Path& Path::operator+=(const Path& other)
{
for(auto& node : other.m_nodes)
append(node);
+ // If the path is modified, clear the binding
+ m_binding = PathBinding();
return *this;
}
@@ -410,6 +414,7 @@ void Path::print_pretty(::std::ostream& os) const
#endif
os << n;
}
+ os << "/*" << path.m_binding << "*/";
break;
case Path::LOCAL:
os << path.m_nodes[0].name();
diff --git a/src/ast/path.hpp b/src/ast/path.hpp
index b3af8c52..027f8f35 100644
--- a/src/ast/path.hpp
+++ b/src/ast/path.hpp
@@ -218,6 +218,7 @@ public:
m_nodes.back().args() = b[0].args();
for(unsigned int i = 1; i < b.m_nodes.size(); i ++)
m_nodes.push_back(b.m_nodes[i]);
+ m_binding = PathBinding();
}
Path operator+(PathNode&& pn) const {
Path tmp;
@@ -236,6 +237,7 @@ public:
void append(PathNode node) {
m_nodes.push_back(node);
+ m_binding = PathBinding();
}
void resolve(const Crate& crate);
diff --git a/src/convert/resolve.cpp b/src/convert/resolve.cpp
index 2e97b11b..86c56578 100644
--- a/src/convert/resolve.cpp
+++ b/src/convert/resolve.cpp
@@ -283,6 +283,7 @@ bool lookup_path_in_module(const AST::Crate& crate, const AST::Module& module, c
DEBUG("Wildcard import found, " << imp.data << " + " << path);
// Wildcard path, prefix entirely with the path
path = imp.data + path;
+ path.resolve( crate );
return true;
}
else
@@ -361,6 +362,9 @@ void CPathResolver::handle_path(AST::Path& path, CASTIterator::PathMode mode)
if( !path.binding().is_bound() ) {
path.resolve(m_crate);
}
+ else {
+ DEBUG("- Path " << path << " already bound");
+ }
UNINDENT();
}
else if( path.is_relative() )
diff --git a/src/main.cpp b/src/main.cpp
index e0188012..bbe079fd 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -64,7 +64,8 @@ int main(int argc, char *argv[])
// Resolve names to be absolute names (include references to the relevant struct/global/function)
g_cur_phase = "Resolve";
ResolvePaths(crate);
- //s << crate;
+
+ g_cur_phase = "Temp output"; Dump_Rust( FMT(params.outfile << ".rs").c_str(), crate );
// Typecheck / type propagate module (type annotations of all values)
// - Check all generic conditions (ensure referenced trait is valid)