summaryrefslogtreecommitdiff
path: root/src/convert/resolve.cpp
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2016-03-18 13:58:11 +0800
committerJohn Hodge <tpg@mutabah.net>2016-03-18 13:58:11 +0800
commit485dfcb3fe4ddfeb7c0342ec288807fde3ef9504 (patch)
treee027424cbe73fd799ac524bf82ddebc201fde8f8 /src/convert/resolve.cpp
parent629fa5d38be99066f0fdb664796e9f7c6aea49ba (diff)
downloadmrust-485dfcb3fe4ddfeb7c0342ec288807fde3ef9504.tar.gz
AST - Switch traits to contain items
Diffstat (limited to 'src/convert/resolve.cpp')
-rw-r--r--src/convert/resolve.cpp47
1 files changed, 26 insertions, 21 deletions
diff --git a/src/convert/resolve.cpp b/src/convert/resolve.cpp
index ff3aa05a..f9115e0b 100644
--- a/src/convert/resolve.cpp
+++ b/src/convert/resolve.cpp
@@ -1377,28 +1377,33 @@ bool CPathResolver::find_trait_item(const Span& span, const AST::Path& path, AST
{
TRACE_FUNCTION_F("path=" << path << ", trait=..., item_name=" << item_name);
{
- const auto& fcns = trait.functions();
- //DEBUG("fcns = " << fcns);
- auto it = ::std::find_if( fcns.begin(), fcns.end(), [&](const AST::Named<AST::Function>& a) { DEBUG("fcn " << a.name); return a.name == item_name; } );
- if( it != fcns.end() ) {
+ const auto& items = trait.items();
+ auto it = ::std::find_if( items.begin(), items.end(), [&](const auto& a) { DEBUG("fcn " << a.name); return a.name == item_name; } );
+ if( it != items.end() ) {
// Found it.
- out_is_method = true;
- out_ptr = &it->data;
- out_trait_path = AST::Path(path);
- DEBUG("Fcn, out_trait_path = " << out_trait_path);
- return true;
- }
- }
- {
- const auto& types = trait.types();
- auto it = ::std::find_if( types.begin(), types.end(), [&](const AST::Named<AST::TypeAlias>& a) { DEBUG("type " << a.name); return a.name == item_name; } );
- if( it != types.end() ) {
- // Found it.
- out_is_method = false;
- out_ptr = &it->data;
- out_trait_path = AST::Path(path);
- DEBUG("Ty, out_trait_path = " << out_trait_path << " path=" << path);
- return true;
+ const auto& i = *it;
+ TU_MATCH_DEF(AST::Item, (i.data), (e),
+ (
+ BUG(Span(), "Unknown item type in trait");
+ ),
+ (Function,
+ out_is_method = true;
+ out_ptr = &e.e;
+ out_trait_path = AST::Path(path);
+ DEBUG("Fcn, out_trait_path = " << out_trait_path);
+ return true;
+ ),
+ (Type,
+ out_is_method = false;
+ out_ptr = &it->data;
+ out_trait_path = AST::Path(path);
+ DEBUG("Ty, out_trait_path = " << out_trait_path << " path=" << path);
+ return true;
+ ),
+ (Static,
+ TODO(Span(), "Handle resolving associated statics/consts in traits (CPathResolver::find_trait_item)");
+ )
+ )
}
}