diff options
author | John Hodge (sonata) <tpg@mutabah.net> | 2015-01-22 14:51:07 +0800 |
---|---|---|
committer | John Hodge (sonata) <tpg@mutabah.net> | 2015-01-22 14:51:07 +0800 |
commit | 76d70d4cbfbdf09082d35a224a4c7f2d2b501974 (patch) | |
tree | a0b3ce0ea0f624e56e57edc6850542e9f4081eae /src/types.hpp | |
parent | 8d1acfa3993e64b0266365379602799350855f3f (diff) | |
download | mrust-76d70d4cbfbdf09082d35a224a4c7f2d2b501974.tar.gz |
Added bounds to _ types, propagating type params further (and replacing when needed)
Diffstat (limited to 'src/types.hpp')
-rw-r--r-- | src/types.hpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/types.hpp b/src/types.hpp index 27d74662..b40c9424 100644 --- a/src/types.hpp +++ b/src/types.hpp @@ -53,6 +53,11 @@ public: TypeRef():
m_class(ANY)
{}
+ struct TagBoundedAny {};
+ TypeRef(TagBoundedAny, ::std::vector<TypeRef> traits):
+ m_class(ANY),
+ m_inner_types( ::std::move(traits) )
+ {}
struct TagUnit {}; // unit maps to a zero-length tuple, just easier to type
TypeRef(TagUnit):
@@ -138,8 +143,13 @@ public: bool is_reference() const { return m_class == REFERENCE; }
const ::std::string& type_param() const { assert(is_type_param()); return m_path[0].name(); }
AST::Path& path() { assert(is_path() || m_class == ASSOCIATED); return m_path; }
+ const AST::Path& path() const { assert(is_path() || m_class == ASSOCIATED); return m_path; }
::std::vector<TypeRef>& sub_types() { return m_inner_types; }
-
+ const ::std::vector<TypeRef>& sub_types() const { return m_inner_types; }
+
+ void add_trait(TypeRef trait) { assert(is_wildcard()); m_inner_types.push_back( ::std::move(trait) ); }
+ const ::std::vector<TypeRef>& traits() const { assert(is_wildcard()); return m_inner_types; }
+
bool operator==(const TypeRef& x) const;
bool operator!=(const TypeRef& x) const { return !(*this == x); }
|