Pass 'small_struct_ints'

This commit is contained in:
David Gonzalez Martin 2025-06-13 13:41:51 -06:00
parent 9e1856d4c5
commit 16cadd8498
2 changed files with 25 additions and 7 deletions

View File

@ -7172,7 +7172,26 @@ contains_no_user_data = fn (type: &Type, start: u64, end: u64) u1
.struct => .struct =>
{ {
result = 1; result = 1;
#trap();
>fields = type.content.struct.fields;
for (&field: fields)
{
>field_offset = field.offset;
if (field_offset >= end)
{
break;
}
>field_start = #select(field_offset < start, start - field_offset, 0);
if (!contains_no_user_data(field.type, field_start, end - field_offset))
{
result = 0;
break;
}
}
}, },
.array, .enum_array => .array, .enum_array =>
{ {
@ -13329,6 +13348,7 @@ names: [_][]u8 =
"return_u64_u64", "return_u64_u64",
"select", "select",
"slice", "slice",
"small_struct_ints",
]; ];
[export] main = fn [cc(c)] (argument_count: u32, argv: &&u8, envp: &&u8) s32 [export] main = fn [cc(c)] (argument_count: u32, argv: &&u8, envp: &&u8) s32

View File

@ -609,21 +609,19 @@ fn bool contains_no_user_data(Type* type, u64 start, u64 end)
{ {
case TypeId::structure: case TypeId::structure:
{ {
u64 offset = 0;
for (auto& field: type->structure.fields) for (auto& field: type->structure.fields)
{ {
if (offset >= end) auto field_offset = field.offset;
if (field_offset >= end)
{ {
break; break;
} }
auto field_start = offset < start ? start - offset : 0; auto field_start = field_offset < start ? start - field_offset : 0;
if (!contains_no_user_data(field.type, field_start, end - offset)) if (!contains_no_user_data(field.type, field_start, end - field_offset))
{ {
return false; return false;
} }
offset += get_byte_size(field.type);
} }
return true; return true;