// Phase 1.1 — the compiler-internal heap-copy that backs `xx value` // protocol erasure must dispatch through `context.allocator`, not call // libc malloc directly. So when a `push Context.{ allocator = tracer }` // block is active, a `xx struct_value` inside it MUST be allocated by // the tracker. #import "modules/std.sx"; Tracer :: struct { count: s64; init :: () -> *Tracer { t : *Tracer = xx malloc(size_of(Tracer)); t.count = 0; t; } } impl Allocator for Tracer { alloc :: (self: *Tracer, size: s64) -> *void { self.count += 1; return malloc(size); } dealloc :: (self: *Tracer, ptr: *void) { free(ptr); } } ByValue :: struct { x: s64; y: s64; } main :: () -> s32 { tracer := Tracer.init(); push Context.{ allocator = xx tracer, data = null } { bv : ByValue = .{ x = 1, y = 2 }; ignore : Allocator = xx bv; _ = ignore; } print("Tracer.count = {}\n", tracer.count); 0; }