aboutsummaryrefslogtreecommitdiff
path: root/boot/ast.cc
diff options
context:
space:
mode:
Diffstat (limited to 'boot/ast.cc')
-rw-r--r--boot/ast.cc69
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;