aboutsummaryrefslogtreecommitdiff
path: root/boot/symbol.cc
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2026-07-21 01:55:56 +0200
committerEugen Wissner <belka@caraus.de>2026-07-21 01:55:56 +0200
commit44d6e8a27294e5ca7300ab11900011b73d9336d4 (patch)
treed21addb0dec93fa8fa376bbd11076b17f3412173 /boot/symbol.cc
parent6b131c925dee7a5f97516edd581e051e08bb52d8 (diff)
downloadelna-44d6e8a27294e5ca7300ab11900011b73d9336d4.tar.gz
Implement slices
Diffstat (limited to 'boot/symbol.cc')
-rw-r--r--boot/symbol.cc21
1 files changed, 21 insertions, 0 deletions
diff --git a/boot/symbol.cc b/boot/symbol.cc
index d7a1cae..738e4e1 100644
--- a/boot/symbol.cc
+++ b/boot/symbol.cc
@@ -51,6 +51,11 @@ namespace elna::boot
{
}
+ type::type(std::shared_ptr<slice_type> slice)
+ : payload(slice)
+ {
+ }
+
type::type(std::shared_ptr<procedure_type> procedure)
: payload(procedure)
{
@@ -86,6 +91,7 @@ namespace elna::boot
template std::shared_ptr<record_type> type::get<record_type>() const;
template std::shared_ptr<pointer_type> type::get<pointer_type>() const;
template std::shared_ptr<array_type> type::get<array_type>() const;
+ template std::shared_ptr<slice_type> type::get<slice_type>() const;
template std::shared_ptr<constant_type> type::get<constant_type>() const;
template std::shared_ptr<procedure_type> type::get<procedure_type>() const;
template std::shared_ptr<enumeration_type> type::get<enumeration_type>() const;
@@ -133,6 +139,12 @@ namespace elna::boot
return right_array != nullptr && left_array->size == right_array->size
&& left_array->base == right_array->base;
}
+ if (auto left_slice = resolved_this.get<slice_type>())
+ {
+ auto right_slice = resolved_that.get<slice_type>();
+
+ return right_slice != nullptr && left_slice->base == right_slice->base;
+ }
if (auto left_procedure = resolved_this.get<procedure_type>())
{
auto right_procedure = resolved_that.get<procedure_type>();
@@ -176,6 +188,10 @@ namespace elna::boot
{
return "[" + std::to_string(payload->size) + "]" + payload->base.to_string();
}
+ else if constexpr (std::is_same_v<T, std::shared_ptr<slice_type>>)
+ {
+ return "[]" + payload->base.to_string();
+ }
else if constexpr (std::is_same_v<T, std::shared_ptr<record_type>>)
{
return payload->base.empty()
@@ -226,6 +242,11 @@ namespace elna::boot
{
}
+ slice_type::slice_type(type base)
+ : base(std::move(base))
+ {
+ }
+
primitive_type::primitive_type(const std::string& identifier)
: identifier(identifier)
{