From 4326517b27cc4492aed4145c4c855e4991740e33 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Mon, 1 Aug 2016 10:54:04 +0800 Subject: AST - Add specialisable tag to impl items --- src/ast/ast.cpp | 40 ++++++---------------------------------- 1 file changed, 6 insertions(+), 34 deletions(-) (limited to 'src/ast/ast.cpp') diff --git a/src/ast/ast.cpp b/src/ast/ast.cpp index 00c4b39b..1da79f33 100644 --- a/src/ast/ast.cpp +++ b/src/ast/ast.cpp @@ -103,18 +103,18 @@ SERIALISE_TYPE(ImplDef::, "AST_ImplDef", { s.item(m_type); }) -void Impl::add_function(bool is_public, ::std::string name, Function fcn) +void Impl::add_function(bool is_public, bool is_specialisable, ::std::string name, Function fcn) { DEBUG("impl fn " << name); - m_items.push_back( Named( mv$(name), Item::make_Function({::std::move(fcn)}), is_public ) ); + m_items.push_back( ImplItem { is_public, is_specialisable, mv$(name), box$( Item::make_Function(mv$(fcn)) ) } ); } -void Impl::add_type(bool is_public, ::std::string name, TypeRef type) +void Impl::add_type(bool is_public, bool is_specialisable, ::std::string name, TypeRef type) { - m_items.push_back( Named( mv$(name), Item::make_Type({TypeAlias(GenericParams(), mv$(type))}), is_public ) ); + m_items.push_back( ImplItem { is_public, is_specialisable, mv$(name), box$( Item::make_Type(TypeAlias(GenericParams(), mv$(type))) ) } ); } -void Impl::add_static(bool is_public, ::std::string name, Static v) +void Impl::add_static(bool is_public, bool is_specialisable, ::std::string name, Static v) { - m_items.push_back( Named( mv$(name), Item::make_Static({mv$(v)}), is_public ) ); + m_items.push_back( ImplItem { is_public, is_specialisable, mv$(name), box$( Item::make_Static(mv$(v)) ) } ); } bool Impl::has_named_item(const ::std::string& name) const @@ -128,42 +128,14 @@ bool Impl::has_named_item(const ::std::string& name) const return false; } -Impl& Impl::get_concrete(const ::std::vector& param_types) -{ - if( param_types.size() > 0 ) - { - for( auto& i : m_concrete_impls ) - { - if( i.first == param_types ) - { - return i.second; - } - } - - m_concrete_impls.push_back( make_pair(param_types, this->make_concrete(param_types)) ); - return m_concrete_impls.back().second; - } - else - { - return *this; - } -} - -Impl Impl::make_concrete(const ::std::vector& types) const -{ - throw ParseError::Todo("Impl::make_concrete"); -} - ::std::ostream& operator<<(::std::ostream& os, const Impl& impl) { return os << impl.m_def; } SERIALISE_TYPE(Impl::, "AST_Impl", { s << m_def; - s << m_items; },{ s.item(m_def); - s.item(m_items); }) ::rust::option ImplRef::find_named_item(const ::std::string& name) const -- cgit v1.2.3