Rework value type analysis and remove slice coerce
All checks were successful
All checks were successful
This commit is contained in:
parent
c09715b2d0
commit
c7c5b509f2
1260
src/bootstrap.zig
1260
src/bootstrap.zig
File diff suppressed because it is too large
Load Diff
@ -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
|
||||
|
@ -317,4 +317,5 @@ const names = &[_][]const u8{
|
||||
"shortcircuiting_if",
|
||||
"field_access_left_assign",
|
||||
"for_each",
|
||||
"pointer_decay",
|
||||
};
|
||||
|
@ -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
8
tests/pointer_decay.bbb
Normal 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];
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user