lang: rename signed integer types sN -> iN
Surface rename of the signed integer family: s1..s64 become i1..i64
(u1..u64, usize, isize unchanged). 'string' keeps the s-prefix arm in
name classification; width parsing moves to the i-prefix arm next to
isize.
Internal TypeId tags follow the surface (.s8/.s16/.s32/.s64 ->
.i8/.i16/.i32/.i64), as do mono-key mangle fragments (ptr_i64,
tu_i64_bool) and all display/diagnostic formatting (i{d}).
Migrated in the same sweep: stdlib + examples + issue repros + FFI C
companions (shared symbol names like ffi_id_i64), expected
stdout/stderr/ir snapshots, specs.md, readme.md, CLAUDE.md/AGENTS.md,
implementation_plan.md, docs/, issue writeups. Vendored stb_image and
historical flow state left untouched.
zig build test: 426/426; examples suite: 595/595.
This commit is contained in:
@@ -31,7 +31,7 @@ destroy :: ufcs (a: Allocator, ptr: *$T) {
|
||||
}
|
||||
|
||||
// Allocate a []T of `count` elements. Contents are UNINITIALISED.
|
||||
alloc :: ufcs (a: Allocator, $T: Type, count: s64) -> []T {
|
||||
alloc :: ufcs (a: Allocator, $T: Type, count: i64) -> []T {
|
||||
raw := a.alloc_bytes(count * size_of(T));
|
||||
s : []T = ---;
|
||||
s.ptr = xx raw;
|
||||
@@ -57,7 +57,7 @@ clone :: ufcs (src: []$T, a: Allocator) -> []T {
|
||||
// Reallocate a slice to `new_count` elements: fresh storage, contents
|
||||
// copied up to min(len, new_count), old backing freed. The returned
|
||||
// slice replaces the operand — the old slice is dangling after this.
|
||||
resize :: ufcs (slice: []$T, a: Allocator, new_count: s64) -> []T {
|
||||
resize :: ufcs (slice: []$T, a: Allocator, new_count: i64) -> []T {
|
||||
raw := a.alloc_bytes(new_count * size_of(T));
|
||||
n := if slice.len < new_count then slice.len else new_count;
|
||||
memcpy(raw, xx slice.ptr, n * size_of(T));
|
||||
@@ -72,7 +72,7 @@ resize :: ufcs (slice: []$T, a: Allocator, new_count: s64) -> []T {
|
||||
// dealloc — there is no in-place grow primitive to try yet, and
|
||||
// `align` beyond the heap's natural 8 is not honored until the
|
||||
// protocol carries alignment.
|
||||
mem_realloc :: ufcs (a: Allocator, ptr: *void, old: s64, new: s64, align: s64) -> *void {
|
||||
mem_realloc :: ufcs (a: Allocator, ptr: *void, old: i64, new: i64, align: i64) -> *void {
|
||||
raw := a.alloc_bytes(new);
|
||||
n := if old < new then old else new;
|
||||
memcpy(raw, ptr, n);
|
||||
@@ -91,7 +91,7 @@ mem_realloc :: ufcs (a: Allocator, ptr: *void, old: s64, new: s64, align: s64) -
|
||||
CAllocator :: struct {}
|
||||
|
||||
impl Allocator for CAllocator {
|
||||
alloc_bytes :: (self: *CAllocator, size: s64) -> *void {
|
||||
alloc_bytes :: (self: *CAllocator, size: i64) -> *void {
|
||||
return libc_malloc(size);
|
||||
}
|
||||
dealloc_bytes :: (self: *CAllocator, ptr: *void) {
|
||||
@@ -112,7 +112,7 @@ impl Allocator for CAllocator {
|
||||
// print("alloc count: {}\n", gpa.alloc_count);
|
||||
|
||||
GPA :: struct {
|
||||
alloc_count: s64;
|
||||
alloc_count: i64;
|
||||
|
||||
init :: () -> GPA {
|
||||
GPA.{ alloc_count = 0 }
|
||||
@@ -120,7 +120,7 @@ GPA :: struct {
|
||||
}
|
||||
|
||||
impl Allocator for GPA {
|
||||
alloc_bytes :: (self: *GPA, size: s64) -> *void {
|
||||
alloc_bytes :: (self: *GPA, size: i64) -> *void {
|
||||
self.alloc_count += 1;
|
||||
return libc_malloc(size);
|
||||
}
|
||||
@@ -146,15 +146,15 @@ impl Allocator for GPA {
|
||||
|
||||
ArenaChunk :: struct {
|
||||
next: *ArenaChunk;
|
||||
cap: s64;
|
||||
cap: i64;
|
||||
}
|
||||
|
||||
Arena :: struct {
|
||||
first: *ArenaChunk;
|
||||
end_index: s64;
|
||||
end_index: i64;
|
||||
parent: Allocator;
|
||||
|
||||
add_chunk :: (a: *Arena, min_size: s64) {
|
||||
add_chunk :: (a: *Arena, min_size: i64) {
|
||||
prev_cap := if a.first != null then a.first.cap else 0;
|
||||
needed := min_size + 16 + 16;
|
||||
len := (prev_cap + needed) * 3 / 2;
|
||||
@@ -166,7 +166,7 @@ Arena :: struct {
|
||||
a.end_index = 0;
|
||||
}
|
||||
|
||||
init :: (parent_alloc: Allocator, size: s64) -> Arena {
|
||||
init :: (parent_alloc: Allocator, size: i64) -> Arena {
|
||||
self : Arena = .{ first = null, end_index = 0, parent = parent_alloc };
|
||||
self.add_chunk(size);
|
||||
self
|
||||
@@ -198,7 +198,7 @@ Arena :: struct {
|
||||
}
|
||||
|
||||
impl Allocator for Arena {
|
||||
alloc_bytes :: (self: *Arena, size: s64) -> *void {
|
||||
alloc_bytes :: (self: *Arena, size: i64) -> *void {
|
||||
aligned := (size + 7) & (0 - 8);
|
||||
if self.first != null {
|
||||
usable := self.first.cap - 16;
|
||||
@@ -232,10 +232,10 @@ impl Allocator for Arena {
|
||||
|
||||
BufAlloc :: struct {
|
||||
buf: [*]u8;
|
||||
len: s64;
|
||||
pos: s64;
|
||||
len: i64;
|
||||
pos: i64;
|
||||
|
||||
init :: (buf: [*]u8, len: s64) -> BufAlloc {
|
||||
init :: (buf: [*]u8, len: i64) -> BufAlloc {
|
||||
BufAlloc.{ buf = buf, len = len, pos = 0 }
|
||||
}
|
||||
|
||||
@@ -245,7 +245,7 @@ BufAlloc :: struct {
|
||||
}
|
||||
|
||||
impl Allocator for BufAlloc {
|
||||
alloc_bytes :: (self: *BufAlloc, size: s64) -> *void {
|
||||
alloc_bytes :: (self: *BufAlloc, size: i64) -> *void {
|
||||
aligned := (size + 7) & (0 - 8);
|
||||
if self.pos + aligned > self.len {
|
||||
return null;
|
||||
@@ -282,9 +282,9 @@ impl Allocator for BufAlloc {
|
||||
|
||||
TrackingAllocator :: struct {
|
||||
parent: Allocator;
|
||||
alloc_count: s64;
|
||||
dealloc_count: s64;
|
||||
total_alloc_bytes: s64;
|
||||
alloc_count: i64;
|
||||
dealloc_count: i64;
|
||||
total_alloc_bytes: i64;
|
||||
|
||||
init :: (parent_alloc: Allocator) -> TrackingAllocator {
|
||||
TrackingAllocator.{
|
||||
@@ -295,7 +295,7 @@ TrackingAllocator :: struct {
|
||||
}
|
||||
}
|
||||
|
||||
leak_count :: (t: *TrackingAllocator) -> s64 {
|
||||
leak_count :: (t: *TrackingAllocator) -> i64 {
|
||||
t.alloc_count - t.dealloc_count
|
||||
}
|
||||
|
||||
@@ -306,7 +306,7 @@ TrackingAllocator :: struct {
|
||||
}
|
||||
|
||||
impl Allocator for TrackingAllocator {
|
||||
alloc_bytes :: (self: *TrackingAllocator, size: s64) -> *void {
|
||||
alloc_bytes :: (self: *TrackingAllocator, size: i64) -> *void {
|
||||
ptr := self.parent.alloc_bytes(size);
|
||||
if ptr != null {
|
||||
self.alloc_count += 1;
|
||||
|
||||
Reference in New Issue
Block a user