From bd2b80d6ac582b9f0bcd96c86d4b79bfdb64eca1 Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Fri, 11 Sep 2026 09:11:47 +0200 Subject: Implement aligned attribute --- boot/ast.cc | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) (limited to 'boot/ast.cc') diff --git a/boot/ast.cc b/boot/ast.cc index 9dbcf7f..08d3a78 100644 --- a/boot/ast.cc +++ b/boot/ast.cc @@ -17,6 +17,7 @@ along with GCC; see the file COPYING3. If not see #include "elna/boot/ast.h" +#include #include namespace elna::boot @@ -588,6 +589,74 @@ namespace elna::boot return nullptr; } + attribute::attribute(identifier&& name, std::vector arguments) + : m_name(std::move(name)), m_arguments(std::move(arguments)) + { + } + + attribute::attribute(attribute&& that) noexcept + : m_name(std::move(that.m_name)), m_arguments(std::move(that.m_arguments)) + { + } + + attribute::~attribute() + { + for (const expression *argument : this->arguments()) + { + delete argument; + } + } + + attribute& attribute::operator=(attribute&& that) noexcept + { + std::swap(this->m_name, that.m_name); + std::swap(this->m_arguments, that.m_arguments); + + return *this; + } + + const identifier& attribute::name() const + { + return this->m_name; + } + + const std::vector& attribute::arguments() const + { + return this->m_arguments; + } + + identifier_definition::identifier_definition(const std::string& name, + const source_position& position, const bool exported, std::vector&& attributes) + : attributes(std::move(attributes)), m_identifier(name, position), m_exported(exported) + { + } + + const std::string& identifier_definition::name() const + { + return this->m_identifier.name(); + } + + const identifier& identifier_definition::id() const + { + return this->m_identifier; + } + + bool identifier_definition::exported() const + { + return this->m_exported; + } + + std::vector extract_identifiers(const std::vector& identifiers) + { + std::vector result; + result.reserve(identifiers.size()); + + std::ranges::transform(identifiers, std::back_inserter(result), + [](const auto& identifier) { return identifier.id(); }); + + return result; + } + named_expression *type_expression::is_named() { return nullptr; -- cgit v1.2.3