aboutsummaryrefslogtreecommitdiff
path: root/boot/evaluator.cc
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2026-09-11 09:11:47 +0200
committerEugen Wissner <belka@caraus.de>2026-09-11 09:11:47 +0200
commitbd2b80d6ac582b9f0bcd96c86d4b79bfdb64eca1 (patch)
treea835a5cfe5a9cf48720b9255261e065fd7978849 /boot/evaluator.cc
parentb27872d5c5bfecae74195771f5c1f4e73385b6d6 (diff)
downloadelna-bd2b80d6ac582b9f0bcd96c86d4b79bfdb64eca1.tar.gz
Implement aligned attribute
Diffstat (limited to 'boot/evaluator.cc')
-rw-r--r--boot/evaluator.cc14
1 files changed, 10 insertions, 4 deletions
diff --git a/boot/evaluator.cc b/boot/evaluator.cc
index 0a6ebe5..0085c62 100644
--- a/boot/evaluator.cc
+++ b/boot/evaluator.cc
@@ -139,20 +139,26 @@ namespace elna::boot
{
for (auto const& field : current_record->fields)
{
- auto props = get_type_properties(field.second, target);
+ auto props = get_type_properties(field.second.field_type, target);
if (!props.has_value())
{
return std::nullopt;
}
- size = (size + props->alignment - 1) & ~(props->alignment - 1);
+ // #aligned replaces the field's own alignment outright, so that
+ // a smaller value packs it.
+ const std::size_t field_alignment = field.second.alignment.value_or(props->alignment);
+
+ size = (size + field_alignment - 1) & ~(field_alignment - 1);
size += props->size;
- alignment = std::max(alignment, props->alignment);
- current_offset = (current_offset + props->alignment - 1) & ~(props->alignment - 1);
+ alignment = std::max(alignment, field_alignment);
+ current_offset = (current_offset + field_alignment - 1) & ~(field_alignment - 1);
result_map.insert(field.first, current_offset);
current_offset += props->size;
}
}
+ alignment = subject->alignment.value_or(alignment);
+
return record_properties{
.offset_map = std::move(result_map),
.size = (size + alignment - 1) & ~(alignment - 1),