diff options
author | John Hodge <tpg@mutabah.net> | 2016-03-18 13:06:35 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-03-18 13:06:35 +0800 |
commit | 629fa5d38be99066f0fdb664796e9f7c6aea49ba (patch) | |
tree | 7c27ce31fcf97811ae3fde81f19f132009d51353 /src/ast/ast.cpp | |
parent | 28e67c7ed47e9b3891f5dc72de46edf3a3b94a6e (diff) | |
download | mrust-629fa5d38be99066f0fdb664796e9f7c6aea49ba.tar.gz |
AST - Switch impl blocks to contain `Item`s (merges code)
Diffstat (limited to 'src/ast/ast.cpp')
-rw-r--r-- | src/ast/ast.cpp | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/ast/ast.cpp b/src/ast/ast.cpp index 0739fde2..4229f1e8 100644 --- a/src/ast/ast.cpp +++ b/src/ast/ast.cpp @@ -140,9 +140,22 @@ SERIALISE_TYPE(ImplDef::, "AST_ImplDef", { s.item(m_type);
})
+void Impl::add_function(bool is_public, ::std::string name, Function fcn)
+{
+ m_items.push_back( Named<Item>( mv$(name), Item::make_Function({::std::move(fcn)}), is_public ) );
+}
+void Impl::add_type(bool is_public, ::std::string name, TypeRef type)
+{
+ m_items.push_back( Named<Item>( mv$(name), Item::make_Type({TypeAlias(GenericParams(), mv$(type))}), is_public ) );
+}
+void Impl::add_static(bool is_public, ::std::string name, Static v)
+{
+ m_items.push_back( Named<Item>( mv$(name), Item::make_Static({mv$(v)}), is_public ) );
+}
+
bool Impl::has_named_item(const ::std::string& name) const
{
- for( const auto& it : this->functions() )
+ for( const auto& it : this->items() )
{
if( it.name == name ) {
return true;
@@ -210,10 +223,10 @@ Impl Impl::make_concrete(const ::std::vector<TypeRef>& types) const }
SERIALISE_TYPE(Impl::, "AST_Impl", {
s << m_def;
- s << m_functions;
+ s << m_items;
},{
s.item(m_def);
- s.item(m_functions);
+ s.item(m_items);
})
::rust::option<char> ImplRef::find_named_item(const ::std::string& name) const
|