aboutsummaryrefslogtreecommitdiff
path: root/boot/evaluator.cc
diff options
context:
space:
mode:
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),