diff options
author | John Hodge (sonata) <tpg@mutabah.net> | 2015-01-18 12:56:30 +0800 |
---|---|---|
committer | John Hodge (sonata) <tpg@mutabah.net> | 2015-01-18 12:56:30 +0800 |
commit | ba61031285402285e88a16f3788c20f455acc8e3 (patch) | |
tree | 8407f6ea4cbe1e5a2aed163ef5a4ebb22b5ddad4 /src/ast/ast.hpp | |
parent | 0390dc8a92c3c8d12421d529915ab350234301c3 (diff) | |
download | mrust-ba61031285402285e88a16f3788c20f455acc8e3.tar.gz |
Added support for associated types in impl blocks
Diffstat (limited to 'src/ast/ast.hpp')
-rw-r--r-- | src/ast/ast.hpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/ast/ast.hpp b/src/ast/ast.hpp index a57b4308..20d28467 100644 --- a/src/ast/ast.hpp +++ b/src/ast/ast.hpp @@ -315,7 +315,8 @@ class Impl: TypeRef m_trait;
TypeRef m_type;
- ::std::vector<Item<Function> > m_functions;
+ ItemList<TypeRef> m_types;
+ ItemList<Function> m_functions;
public:
Impl() {}
Impl(TypeParams params, TypeRef impl_type, TypeRef trait_type):
@@ -327,15 +328,21 @@ public: void add_function(bool is_public, ::std::string name, Function fcn) {
m_functions.push_back( Item<Function>( ::std::move(name), ::std::move(fcn), is_public ) );
}
+ void add_type(bool is_public, ::std::string name, TypeRef type) {
+ m_types.push_back( Item<TypeRef>( ::std::move(name), ::std::move(type), is_public ) );
+ }
const TypeParams& params() const { return m_params; }
const TypeRef& trait() const { return m_trait; }
const TypeRef& type() const { return m_type; }
+ const ItemList<Function>& functions() const { return m_functions; }
+ const ItemList<TypeRef>& types() const { return m_types; }
TypeParams& params() { return m_params; }
TypeRef& trait() { return m_trait; }
TypeRef& type() { return m_type; }
- ::std::vector<Item<Function> >& functions() { return m_functions; }
+ ItemList<Function>& functions() { return m_functions; }
+ ItemList<TypeRef>& types() { return m_types; }
friend ::std::ostream& operator<<(::std::ostream& os, const Impl& impl);
SERIALISABLE_PROTOTYPES();
|