diff options
Diffstat (limited to 'src/ast/ast.cpp')
-rw-r--r-- | src/ast/ast.cpp | 44 |
1 files changed, 19 insertions, 25 deletions
diff --git a/src/ast/ast.cpp b/src/ast/ast.cpp index a4825a89..641bd633 100644 --- a/src/ast/ast.cpp +++ b/src/ast/ast.cpp @@ -14,8 +14,8 @@ namespace AST { namespace { - ::std::vector<MetaItem> clone_mivec(const ::std::vector<MetaItem>& v) { - ::std::vector<MetaItem> ri; + ::std::vector<Attribute> clone_mivec(const ::std::vector<Attribute>& v) { + ::std::vector<Attribute> ri; ri.reserve(v.size()); for(const auto& i : v) ri.push_back( i.clone() ); @@ -23,19 +23,16 @@ namespace { } } -MetaItems::~MetaItems() +AttributeList AttributeList::clone() const { -} -MetaItems MetaItems::clone() const -{ - return MetaItems( m_span, clone_mivec(m_items) ); + return AttributeList( clone_mivec(m_items) ); } -void MetaItems::push_back(MetaItem i) +void AttributeList::push_back(Attribute i) { m_items.push_back( ::std::move(i) ); } -const MetaItem* MetaItems::get(const char *name) const +const Attribute* AttributeList::get(const char *name) const { for( auto& i : m_items ) { if(i.name() == name) { @@ -46,23 +43,20 @@ const MetaItem* MetaItems::get(const char *name) const return 0; } -MetaItem::~MetaItem() +Attribute Attribute::clone() const { -} -MetaItem MetaItem::clone() const -{ - TU_MATCH(MetaItemData, (m_data), (e), + TU_MATCHA( (m_data), (e), (None, - return MetaItem(m_name); + return Attribute(m_span, m_name); ), (String, - return MetaItem(m_name, e.val); + return Attribute(m_span, m_name, e.val); ), (List, - return MetaItem(m_name, clone_mivec(e.sub_items)); + return Attribute(m_span, m_name, clone_mivec(e.sub_items)); ) ) - throw ::std::runtime_error("MetaItem::clone - Fell off end"); + throw ::std::runtime_error("Attribute::clone - Fell off end"); } StructItem StructItem::clone() const @@ -109,16 +103,16 @@ Function Function::clone() const return rv; } -void Trait::add_type(::std::string name, MetaItems attrs, TypeRef type) { +void Trait::add_type(::std::string name, AttributeList attrs, TypeRef type) { m_items.push_back( Named<Item>(mv$(name), Item::make_Type({TypeAlias(GenericParams(), mv$(type))}), true) ); m_items.back().data.attrs = mv$(attrs); } -void Trait::add_function(::std::string name, MetaItems attrs, Function fcn) { +void Trait::add_function(::std::string name, AttributeList attrs, Function fcn) { DEBUG("trait fn " << name); m_items.push_back( Named<Item>(mv$(name), Item::make_Function({mv$(fcn)}), true) ); m_items.back().data.attrs = mv$(attrs); } -void Trait::add_static(::std::string name, MetaItems attrs, Static v) { +void Trait::add_static(::std::string name, AttributeList attrs, Static v) { m_items.push_back( Named<Item>(mv$(name), Item::make_Static({mv$(v)}), true) ); m_items.back().data.attrs = mv$(attrs); } @@ -301,18 +295,18 @@ void Module::add_item( Named<Item> named_item ) { DEBUG(m_my_path << "::" << i.name << " = " << i.data.tag_str() << ", attrs = " << i.data.attrs); } } -void Module::add_item(bool is_pub, ::std::string name, Item it, MetaItems attrs) { +void Module::add_item(bool is_pub, ::std::string name, Item it, AttributeList attrs) { it.attrs = mv$(attrs); add_item( Named<Item>( mv$(name), mv$(it), is_pub ) ); } -void Module::add_ext_crate(bool is_public, ::std::string ext_name, ::std::string imp_name, MetaItems attrs) { +void Module::add_ext_crate(bool is_public, ::std::string ext_name, ::std::string imp_name, AttributeList attrs) { this->add_item( is_public, imp_name, Item::make_Crate({mv$(ext_name)}), mv$(attrs) ); } -void Module::add_alias(bool is_public, UseStmt us, ::std::string name, MetaItems attrs) { +void Module::add_alias(bool is_public, UseStmt us, ::std::string name, AttributeList attrs) { this->add_item( is_public, mv$(name), Item(mv$(us)), mv$(attrs) ); } void Module::add_macro_invocation(MacroInvocation item) { - this->add_item( false, "", Item( mv$(item) ), ::AST::MetaItems {} ); + this->add_item( false, "", Item( mv$(item) ), ::AST::AttributeList {} ); } void Module::add_macro(bool is_exported, ::std::string name, MacroRulesPtr macro) { m_macros.push_back( Named<MacroRulesPtr>( mv$(name), mv$(macro), is_exported ) ); |