diff options
author | John Hodge <tpg@mutabah.net> | 2016-05-02 12:51:05 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-05-02 12:51:05 +0800 |
commit | 809ac4b7f439a6f5b0fe97d3215ad79e510f4c10 (patch) | |
tree | 8cf11a34fd0c92d9a2a3e0aea3e2ade1a1df1d49 /src/resolve/absolute.cpp | |
parent | a87c8d9ce4b789ba26146f2f574937558687789a (diff) | |
download | mrust-809ac4b7f439a6f5b0fe97d3215ad79e510f4c10.tar.gz |
AST - Make trait in UFCS paths be an optional Path
Diffstat (limited to 'src/resolve/absolute.cpp')
-rw-r--r-- | src/resolve/absolute.cpp | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/src/resolve/absolute.cpp b/src/resolve/absolute.cpp index 7d11c85e..b3df1a0e 100644 --- a/src/resolve/absolute.cpp +++ b/src/resolve/absolute.cpp @@ -227,7 +227,7 @@ struct Context -void Resolve_Absolute_Path(const Context& context, const Span& sp, bool is_type, ::AST::Path& path); +void Resolve_Absolute_Path(/*const*/ Context& context, const Span& sp, bool is_type, ::AST::Path& path); void Resolve_Absolute_Type(Context& context, TypeRef& type); void Resolve_Absolute_Expr(Context& context, ::AST::Expr& expr); void Resolve_Absolute_Expr(Context& context, ::AST::ExprNode& node); @@ -235,9 +235,20 @@ void Resolve_Absolute_Pattern(Context& context, bool allow_refutable, ::AST::Pat void Resolve_Absolute_Mod(const ::AST::Crate& crate, ::AST::Module& mod); -void Resolve_Absolute_Path(const Context& context, const Span& sp, bool is_type, ::AST::Path& path) +void Resolve_Absolute_PathNodes(/*const*/ Context& context, const Span& sp, bool is_type, ::std::vector< ::AST::PathNode >& nodes) +{ + for(auto& node : nodes) + { + for(auto& arg : node.args()) + { + Resolve_Absolute_Type(context, arg); + } + } +} +void Resolve_Absolute_Path(/*const*/ Context& context, const Span& sp, bool is_type, ::AST::Path& path) { DEBUG("is_type = " << is_type << ", path = " << path); + TU_MATCH(::AST::Path::Class, (path.m_class), (e), (Invalid, BUG(sp, "Encountered invalid path"); @@ -287,8 +298,12 @@ void Resolve_Absolute_Path(const Context& context, const Span& sp, bool is_type, // Nothing to do (TODO: Bind?) ), (UFCS, - Resolve_Absolute_Type(context, e.type); - TODO(sp, "Resolve_Absolute_Path - UFCS"); + Resolve_Absolute_Type(context, *e.type); + if( e.trait ) { + Resolve_Absolute_Path(context, Span(), true, *e.trait); + } + + Resolve_Absolute_PathNodes(context, Span(), is_type, e.nodes); ) ) } @@ -463,7 +478,7 @@ void Resolve_Absolute_Generic(Context& context, ::AST::GenericParams& params) } // Locals shouldn't be possible, as they'd end up as MaybeBind. Will assert the path class. -void Resolve_Absolute_PatternValue(const Context& context, ::AST::Pattern::Value& val) +void Resolve_Absolute_PatternValue(/*const*/ Context& context, ::AST::Pattern::Value& val) { TU_MATCH(::AST::Pattern::Value, (val), (e), (Invalid, ), |