diff options
| author | Eugen Wissner <belka@caraus.de> | 2026-09-11 09:11:47 +0200 |
|---|---|---|
| committer | Eugen Wissner <belka@caraus.de> | 2026-09-11 09:11:47 +0200 |
| commit | bd2b80d6ac582b9f0bcd96c86d4b79bfdb64eca1 (patch) | |
| tree | a835a5cfe5a9cf48720b9255261e065fd7978849 /boot/ast.cc | |
| parent | b27872d5c5bfecae74195771f5c1f4e73385b6d6 (diff) | |
| download | elna-bd2b80d6ac582b9f0bcd96c86d4b79bfdb64eca1.tar.gz | |
Implement aligned attribute
Diffstat (limited to 'boot/ast.cc')
| -rw-r--r-- | boot/ast.cc | 69 |
1 files changed, 69 insertions, 0 deletions
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 <algorithm> #include <utility> namespace elna::boot @@ -588,6 +589,74 @@ namespace elna::boot return nullptr; } + attribute::attribute(identifier&& name, std::vector<expression *> 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<expression *>& attribute::arguments() const + { + return this->m_arguments; + } + + identifier_definition::identifier_definition(const std::string& name, + const source_position& position, const bool exported, std::vector<attribute>&& 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<identifier> extract_identifiers(const std::vector<identifier_definition>& identifiers) + { + std::vector<identifier> 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; |
