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:
agra
2026-06-12 09:31:53 +03:00
parent 515ecebea7
commit d8076b9333
1054 changed files with 6836 additions and 6839 deletions

View File

@@ -176,10 +176,10 @@ pub fn lowerPackToSlice(self: *Lowering, pack_name: []const u8, slice_ty: TypeId
};
const slice_slot = self.builder.alloca(slice_ty);
const ptr_gep = self.builder.structGepTyped(slice_slot, 0, self.module.types.ptrTo(elem_ty), slice_ty);
const len_gep = self.builder.structGepTyped(slice_slot, 1, .s64, slice_ty);
const len_gep = self.builder.structGepTyped(slice_slot, 1, .i64, slice_ty);
if (arg_nodes.len == 0) {
self.builder.store(ptr_gep, self.builder.constNull(self.module.types.ptrTo(elem_ty)));
self.builder.store(len_gep, self.builder.constInt(0, .s64));
self.builder.store(len_gep, self.builder.constInt(0, .i64));
return self.builder.load(slice_slot, slice_ty);
}
const array_ty = self.module.types.arrayOf(elem_ty, @intCast(arg_nodes.len));
@@ -193,12 +193,12 @@ pub fn lowerPackToSlice(self: *Lowering, pack_name: []const u8, slice_ty: TypeId
} else if (elem_is_protocol) {
if (source_ty != elem_ty) val = self.buildProtocolErasure(val, arg, source_ty, elem_ty);
}
const ep = self.builder.emit(.{ .index_gep = .{ .lhs = array_slot, .rhs = self.builder.constInt(@intCast(i), .s64) } }, self.module.types.ptrTo(elem_ty));
const ep = self.builder.emit(.{ .index_gep = .{ .lhs = array_slot, .rhs = self.builder.constInt(@intCast(i), .i64) } }, self.module.types.ptrTo(elem_ty));
self.builder.store(ep, val);
}
const data_ptr = self.builder.emit(.{ .index_gep = .{ .lhs = array_slot, .rhs = self.builder.constInt(0, .s64) } }, self.module.types.ptrTo(elem_ty));
const data_ptr = self.builder.emit(.{ .index_gep = .{ .lhs = array_slot, .rhs = self.builder.constInt(0, .i64) } }, self.module.types.ptrTo(elem_ty));
self.builder.store(ptr_gep, data_ptr);
self.builder.store(len_gep, self.builder.constInt(@intCast(arg_nodes.len), .s64));
self.builder.store(len_gep, self.builder.constInt(@intCast(arg_nodes.len), .i64));
return self.builder.load(slice_slot, slice_ty);
}
@@ -211,12 +211,12 @@ pub fn lowerVariadicArgs(self: *Lowering, param_name: []const u8, call_args: []c
if (n == 0) {
// Empty slice: {null, 0}
const null_ptr = self.builder.constNull(self.module.types.ptrTo(.any));
const zero_len = self.builder.constInt(0, .s64);
const zero_len = self.builder.constInt(0, .i64);
const slice_slot = self.builder.alloca(any_slice_ty);
// Store ptr (field 0) and len (field 1) into the slice alloca
const ptr_gep = self.builder.structGepTyped(slice_slot, 0, self.module.types.ptrTo(.any), any_slice_ty);
self.builder.store(ptr_gep, null_ptr);
const len_gep = self.builder.structGepTyped(slice_slot, 1, .s64, any_slice_ty);
const len_gep = self.builder.structGepTyped(slice_slot, 1, .i64, any_slice_ty);
self.builder.store(len_gep, zero_len);
if (self.scope) |scope| {
scope.put(param_name, .{ .ref = slice_slot, .ty = any_slice_ty, .is_alloca = true });
@@ -232,7 +232,7 @@ pub fn lowerVariadicArgs(self: *Lowering, param_name: []const u8, call_args: []c
for (call_args[start_idx..], 0..) |arg, i| {
var val = self.lowerExpr(arg);
var source_ty = self.inferExprType(arg);
// If AST-based inference falls back to .s64 but the lowered ref is a string/struct, use that
// If AST-based inference falls back to .i64 but the lowered ref is a string/struct, use that
if (source_ty == .unresolved) {
const ref_ty = self.builder.getRefType(val);
if (ref_ty == .string or ref_ty == .f32 or ref_ty == .f64 or ref_ty == .bool) {
@@ -270,7 +270,7 @@ pub fn lowerVariadicArgs(self: *Lowering, param_name: []const u8, call_args: []c
}
const boxed = if (source_ty == .any) val else self.builder.boxAny(val, source_ty);
// GEP to array[i] and store
const idx_ref = self.builder.constInt(@intCast(i), .s64);
const idx_ref = self.builder.constInt(@intCast(i), .i64);
const elem_ptr = self.builder.emit(.{ .index_gep = .{ .lhs = array_slot, .rhs = idx_ref } }, self.module.types.ptrTo(.any));
self.builder.store(elem_ptr, boxed);
}
@@ -278,13 +278,13 @@ pub fn lowerVariadicArgs(self: *Lowering, param_name: []const u8, call_args: []c
// Build slice {ptr_to_first_element, len}
const slice_slot = self.builder.alloca(any_slice_ty);
// Get pointer to first element (array_slot is *[N x Any], GEP to element 0 gives *Any)
const zero = self.builder.constInt(0, .s64);
const zero = self.builder.constInt(0, .i64);
const data_ptr = self.builder.emit(.{ .index_gep = .{ .lhs = array_slot, .rhs = zero } }, self.module.types.ptrTo(.any));
const len_ref = self.builder.constInt(@intCast(n), .s64);
const len_ref = self.builder.constInt(@intCast(n), .i64);
// Store into slice fields
const ptr_gep = self.builder.structGepTyped(slice_slot, 0, self.module.types.ptrTo(.any), any_slice_ty);
self.builder.store(ptr_gep, data_ptr);
const len_gep = self.builder.structGepTyped(slice_slot, 1, .s64, any_slice_ty);
const len_gep = self.builder.structGepTyped(slice_slot, 1, .i64, any_slice_ty);
self.builder.store(len_gep, len_ref);
if (self.scope) |scope| {
@@ -351,11 +351,11 @@ pub fn packVariadicCallArgs(self: *Lowering, fd: *const ast.FnDecl, c: *const as
if (variadic_count == 0) {
// Empty slice
const null_ptr = self.builder.constNull(self.module.types.ptrTo(elem_ty));
const zero_len = self.builder.constInt(0, .s64);
const zero_len = self.builder.constInt(0, .i64);
const slice_slot = self.builder.alloca(slice_ty);
const ptr_gep = self.builder.structGepTyped(slice_slot, 0, self.module.types.ptrTo(elem_ty), slice_ty);
self.builder.store(ptr_gep, null_ptr);
const len_gep = self.builder.structGepTyped(slice_slot, 1, .s64, slice_ty);
const len_gep = self.builder.structGepTyped(slice_slot, 1, .i64, slice_ty);
self.builder.store(len_gep, zero_len);
const slice_val = self.builder.load(slice_slot, slice_ty);
// Replace args: keep fixed args, append slice
@@ -385,7 +385,7 @@ pub fn packVariadicCallArgs(self: *Lowering, fd: *const ast.FnDecl, c: *const as
var val = args.items[fixed_count + i];
if (is_any) {
var source_ty = self.inferExprType(c.args[fixed_count + i]);
// If AST-based inference falls back to .s64 but the lowered ref has a richer type, use that
// If AST-based inference falls back to .i64 but the lowered ref has a richer type, use that
if (source_ty == .unresolved) {
const ref_ty = self.builder.getRefType(val);
if (ref_ty != .unresolved and ref_ty != .void) source_ty = ref_ty;
@@ -432,19 +432,19 @@ pub fn packVariadicCallArgs(self: *Lowering, fd: *const ast.FnDecl, c: *const as
val = self.buildProtocolErasure(val, arg_node, source_ty, elem_ty);
}
}
const idx_ref = self.builder.constInt(@intCast(i), .s64);
const idx_ref = self.builder.constInt(@intCast(i), .i64);
const elem_ptr = self.builder.emit(.{ .index_gep = .{ .lhs = array_slot, .rhs = idx_ref } }, self.module.types.ptrTo(array_elem));
self.builder.store(elem_ptr, val);
}
// Build slice {ptr, len}
const slice_slot = self.builder.alloca(slice_ty);
const zero = self.builder.constInt(0, .s64);
const zero = self.builder.constInt(0, .i64);
const data_ptr = self.builder.emit(.{ .index_gep = .{ .lhs = array_slot, .rhs = zero } }, self.module.types.ptrTo(array_elem));
const len_ref = self.builder.constInt(@intCast(variadic_count), .s64);
const len_ref = self.builder.constInt(@intCast(variadic_count), .i64);
const ptr_gep = self.builder.structGepTyped(slice_slot, 0, self.module.types.ptrTo(array_elem), slice_ty);
self.builder.store(ptr_gep, data_ptr);
const len_gep = self.builder.structGepTyped(slice_slot, 1, .s64, slice_ty);
const len_gep = self.builder.structGepTyped(slice_slot, 1, .i64, slice_ty);
self.builder.store(len_gep, len_ref);
const slice_val = self.builder.load(slice_slot, slice_ty);
@@ -476,11 +476,11 @@ pub fn buildPackSliceValue(self: *Lowering, arg_types: []const TypeId) Ref {
if (arg_types.len == 0) {
const null_ptr = self.builder.constNull(any_ptr_ty);
const zero_len = self.builder.constInt(0, .s64);
const zero_len = self.builder.constInt(0, .i64);
const slice_slot = self.builder.alloca(any_slice_ty);
const ptr_gep = self.builder.structGepTyped(slice_slot, 0, any_ptr_ty, any_slice_ty);
self.builder.store(ptr_gep, null_ptr);
const len_gep = self.builder.structGepTyped(slice_slot, 1, .s64, any_slice_ty);
const len_gep = self.builder.structGepTyped(slice_slot, 1, .i64, any_slice_ty);
self.builder.store(len_gep, zero_len);
return self.builder.load(slice_slot, any_slice_ty);
}
@@ -493,18 +493,18 @@ pub fn buildPackSliceValue(self: *Lowering, arg_types: []const TypeId) Ref {
// (`{tag=.any, value=tid}`) — already the canonical Any
// shape, so no re-box needed.
const type_val = self.builder.constType(ty);
const idx_ref = self.builder.constInt(@intCast(i), .s64);
const idx_ref = self.builder.constInt(@intCast(i), .i64);
const elem_ptr = self.builder.emit(.{ .index_gep = .{ .lhs = array_slot, .rhs = idx_ref } }, any_ptr_ty);
self.builder.store(elem_ptr, type_val);
}
const slice_slot = self.builder.alloca(any_slice_ty);
const zero = self.builder.constInt(0, .s64);
const zero = self.builder.constInt(0, .i64);
const data_ptr = self.builder.emit(.{ .index_gep = .{ .lhs = array_slot, .rhs = zero } }, any_ptr_ty);
const len_ref = self.builder.constInt(@intCast(arg_types.len), .s64);
const len_ref = self.builder.constInt(@intCast(arg_types.len), .i64);
const ptr_gep = self.builder.structGepTyped(slice_slot, 0, any_ptr_ty, any_slice_ty);
self.builder.store(ptr_gep, data_ptr);
const len_gep = self.builder.structGepTyped(slice_slot, 1, .s64, any_slice_ty);
const len_gep = self.builder.structGepTyped(slice_slot, 1, .i64, any_slice_ty);
self.builder.store(len_gep, len_ref);
return self.builder.load(slice_slot, any_slice_ty);
}
@@ -521,11 +521,11 @@ pub fn materialisePackSlice(
if (arg_types.len == 0) {
const null_ptr = self.builder.constNull(any_ptr_ty);
const zero_len = self.builder.constInt(0, .s64);
const zero_len = self.builder.constInt(0, .i64);
const slice_slot = self.builder.alloca(any_slice_ty);
const ptr_gep = self.builder.structGepTyped(slice_slot, 0, any_ptr_ty, any_slice_ty);
self.builder.store(ptr_gep, null_ptr);
const len_gep = self.builder.structGepTyped(slice_slot, 1, .s64, any_slice_ty);
const len_gep = self.builder.structGepTyped(slice_slot, 1, .i64, any_slice_ty);
self.builder.store(len_gep, zero_len);
scope.put(pack_name, .{ .ref = slice_slot, .ty = any_slice_ty, .is_alloca = true });
return;
@@ -537,18 +537,18 @@ pub fn materialisePackSlice(
for (slot_refs, arg_types, 0..) |slot, ty, i| {
const val = self.builder.load(slot, ty);
const boxed = if (ty == .any) val else self.builder.boxAny(val, ty);
const idx_ref = self.builder.constInt(@intCast(i), .s64);
const idx_ref = self.builder.constInt(@intCast(i), .i64);
const elem_ptr = self.builder.emit(.{ .index_gep = .{ .lhs = array_slot, .rhs = idx_ref } }, any_ptr_ty);
self.builder.store(elem_ptr, boxed);
}
const slice_slot = self.builder.alloca(any_slice_ty);
const zero = self.builder.constInt(0, .s64);
const zero = self.builder.constInt(0, .i64);
const data_ptr = self.builder.emit(.{ .index_gep = .{ .lhs = array_slot, .rhs = zero } }, any_ptr_ty);
const len_ref = self.builder.constInt(@intCast(arg_types.len), .s64);
const len_ref = self.builder.constInt(@intCast(arg_types.len), .i64);
const ptr_gep = self.builder.structGepTyped(slice_slot, 0, any_ptr_ty, any_slice_ty);
self.builder.store(ptr_gep, data_ptr);
const len_gep = self.builder.structGepTyped(slice_slot, 1, .s64, any_slice_ty);
const len_gep = self.builder.structGepTyped(slice_slot, 1, .i64, any_slice_ty);
self.builder.store(len_gep, len_ref);
scope.put(pack_name, .{ .ref = slice_slot, .ty = any_slice_ty, .is_alloca = true });
}
@@ -558,8 +558,8 @@ pub fn materialisePackSlice(
/// type: a `return X;` statement's value type, or — failing that —
/// the tail expression of an arrow-form body. Caller must have
/// `pack_arg_nodes` installed so `args[<lit>]` substitutes during
/// inference. Falls back to `.s64` if nothing concrete is found
/// (matches the broader "default to .s64" convention elsewhere).
/// inference. Falls back to `.i64` if nothing concrete is found
/// (matches the broader "default to .i64" convention elsewhere).
pub fn inferPackBodyReturnType(self: *Lowering, body: *const Node) TypeId {
// First try explicit `return X;` — walks past structured
// control flow but stops at nested fn / lambda bodies.