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/evaluator.cc | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'boot/evaluator.cc') 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), -- cgit v1.2.3