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.
28 lines
1.1 KiB
Plaintext
28 lines
1.1 KiB
Plaintext
// Option 3 — `xx <lvalue>` borrows the operand's storage instead of
|
|
// heap-copying. The protocol value's `ctx` points directly at the local;
|
|
// mutations through the protocol are visible to the original.
|
|
//
|
|
// The witness is TrackingAllocator: incrementing the parent allocator's
|
|
// counter happens through the Allocator protocol value. If `xx tracker`
|
|
// heap-copied the Tracker, the parent counter would land in the copy
|
|
// and the local would stay at zero. With Option 3 the local sees the
|
|
// increments because they ARE the local.
|
|
#import "modules/std.sx";
|
|
#import "modules/std/mem.sx";
|
|
|
|
main :: () -> i32 {
|
|
gpa := GPA.init();
|
|
tracker := TrackingAllocator.init(xx gpa); // value, stack-local
|
|
|
|
// xx tracker — operand is an identifier (lvalue), so the protocol
|
|
// borrows tracker's storage. No heap copy. Mutations propagate.
|
|
push Context.{ allocator = xx tracker, data = null } {
|
|
p := context.allocator.alloc_bytes(128);
|
|
context.allocator.dealloc_bytes(p);
|
|
}
|
|
|
|
print("alloc_count = {}\n", tracker.alloc_count);
|
|
print("dealloc_count = {}\n", tracker.dealloc_count);
|
|
return 0;
|
|
}
|