Rework value type analysis and remove slice coerce
All checks were successful
CI / ci (ReleaseFast, ubuntu-latest) (push) Successful in 2m23s
CI / ci (ReleaseSmall, ubuntu-latest) (push) Successful in 2m22s
CI / ci (ReleaseSafe, ubuntu-latest) (push) Successful in 2m30s
CI / ci (Debug, ubuntu-latest) (push) Successful in 3m35s

This commit is contained in:
David Gonzalez Martin 2025-04-19 19:58:43 -06:00
parent c09715b2d0
commit c7c5b509f2
5 changed files with 646 additions and 646 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,5 @@
[extern] memcmp = fn [cc(c)] (a: &u8, b: &u8, byte_count: u64) s32;
[extern] memcpy = fn [cc(c)] (destination: &u8, source: &u8, byte_count: u64) &u8;
[extern] exit = fn [cc(c)] (exit_code: s32) noreturn;
assert = fn (ok: u1) void
@ -257,6 +258,26 @@ arena_allocate_bytes = fn (arena: &Arena, size: u64, alignment: u64) &u8
arena_join_string = fn (arena: &Arena, pieces: [][]u8) []u8
{
>size: u64 = 0;
for (piece: pieces)
{
size += pieces.length;
}
>pointer = arena_allocate_bytes(arena, size + 1, 1);
>i: u64 = 0;
for (piece: pieces)
{
memcpy(pointer + i, piece.pointer, piece.length);
i += piece.length;
}
assert(i == size);
pointer[i] = 0;
return pointer[0..size];
}
GlobalState = struct

View File

@ -317,4 +317,5 @@ const names = &[_][]const u8{
"shortcircuiting_if",
"field_access_left_assign",
"for_each",
"pointer_decay",
};

View File

@ -17,6 +17,6 @@ slice_receiver = fn (slice: []u8) void
[export] main = fn [cc(c)] () s32
{
>a: [_]u8 = [0, 1, 2];
slice_receiver(&a);
slice_receiver(a[..]);
return 0;
}

8
tests/pointer_decay.bbb Normal file
View File

@ -0,0 +1,8 @@
[export] main = fn [cc(c)] () s32
{
>array: [_]s32 = [1, 3, 5];
>pointer: &s32 = &array[0];
>index: u64 = 0;
pointer[index] = 0;
return pointer[index];
}