From ba61031285402285e88a16f3788c20f455acc8e3 Mon Sep 17 00:00:00 2001 From: "John Hodge (sonata)" Date: Sun, 18 Jan 2015 12:56:30 +0800 Subject: Added support for associated types in impl blocks --- src/ast/ast.hpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/ast/ast.hpp') 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 > m_functions; + ItemList m_types; + ItemList 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( ::std::move(name), ::std::move(fcn), is_public ) ); } + void add_type(bool is_public, ::std::string name, TypeRef type) { + m_types.push_back( Item( ::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& functions() const { return m_functions; } + const ItemList& types() const { return m_types; } TypeParams& params() { return m_params; } TypeRef& trait() { return m_trait; } TypeRef& type() { return m_type; } - ::std::vector >& functions() { return m_functions; } + ItemList& functions() { return m_functions; } + ItemList& types() { return m_types; } friend ::std::ostream& operator<<(::std::ostream& os, const Impl& impl); SERIALISABLE_PROTOTYPES(); -- cgit v1.2.3