From cd2102b569eac16624c3a3091021ae1fb86b5d58 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Sat, 4 Apr 2015 11:24:03 +0800 Subject: (Minor) commenting on procedure for generic trait checking --- src/ast/ast.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/ast/ast.cpp b/src/ast/ast.cpp index 93ac87ea..f70f2ec5 100644 --- a/src/ast/ast.cpp +++ b/src/ast/ast.cpp @@ -342,9 +342,23 @@ bool Crate::check_impls_wildcard(const Path& trait, const TypeRef& type) ::rust::option Crate::find_impl(const Path& trait, const TypeRef& type) { - // TODO: Do a sort to allow a binary search DEBUG("trait = " << trait << ", type = " << type); + // 0. Handle generic bounds + // TODO: Handle more complex bounds like "[T]: Trait" + if( type.is_type_param() ) + { + // Obtain the relevant TypeParams structure + // - TODO: this structure should be pointed to by TypeRef + // Search bounds for type: trait + // If found, success! + // Else, failure + // TODO: What should be returned, kinda need to return a boolean + } + + // TODO: Do a sort to allow a binary search + // 1. Search for wildcard traits (i.e. ones like "impl Send for ..") + // - These require special handling, as negatives apply for( auto implptr : m_impl_index ) { Impl& impl = *implptr; @@ -363,6 +377,7 @@ bool Crate::check_impls_wildcard(const Path& trait, const TypeRef& type) } + // 2. Check real impls DEBUG("Not wildcard"); for( auto implptr : m_impl_index ) { -- cgit v1.2.3