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

@@ -24,7 +24,7 @@ pub fn lowerXX(self: *Lowering, operand: Ref, operand_node: *const Node) Ref {
// Use the operand's *actual* lowered Ref type rather than reaching
// back through inferExprType — the latter doesn't cover every
// expression shape (notably lambdas), and a wrong src_ty here can
// route the cast through coerceToType (e.g. a bogus s64→ptr bitcast)
// route the cast through coerceToType (e.g. a bogus i64→ptr bitcast)
// and silently skip the user-space Into fallback.
const src_ty = self.builder.getRefType(operand);
const target_explicit = self.target_type != null;
@@ -83,7 +83,7 @@ pub fn lowerXX(self: *Lowering, operand: Ref, operand_node: *const Node) Ref {
const result = self.coerceExplicit(operand, src_ty, dst_ty);
// User-space fallback via `impl Into(Target) for Source`. Only fires
// when the target was explicitly named (not the .s64 default), src and
// when the target was explicitly named (not the .i64 default), src and
// dst differ, and the built-in ladder made no progress. Built-ins
// always win.
if (target_explicit and src_ty != dst_ty and result == operand) {
@@ -445,14 +445,14 @@ pub fn lowerAnyToF64Dispatch(self: *Lowering, any_val: Ref) Ref {
const result_slot = self.builder.alloca(.f64);
// Extract type tag from Any
const tag = self.builder.structGet(any_val, 0, .s64);
const tag = self.builder.structGet(any_val, 0, .i64);
const f32_bb = self.freshBlock("f32.unbox");
const f64_bb = self.freshBlock("f64.unbox");
const merge_bb = self.freshBlock("float.merge");
// Branch: tag == f32_tag ? f32_bb : f64_bb
const f32_tag = self.builder.constInt(TypeId.f32.index(), .s64);
const f32_tag = self.builder.constInt(TypeId.f32.index(), .i64);
const cond = self.builder.emit(.{ .cmp_eq = .{ .lhs = tag, .rhs = f32_tag } }, .bool);
self.builder.condBr(cond, f32_bb, &.{}, f64_bb, &.{});
@@ -479,7 +479,7 @@ pub fn lowerAnyToF64Dispatch(self: *Lowering, any_val: Ref) Ref {
}
/// Produce a default value for a type, applying struct field defaults.
/// For structs with defaults (e.g., `b: s32 = 99`), creates a struct_literal with defaults applied.
/// For structs with defaults (e.g., `b: i32 = 99`), creates a struct_literal with defaults applied.
/// For other types, returns a zero value.
pub fn buildDefaultValue(self: *Lowering, ty: TypeId) Ref {
if (ty.isBuiltin()) return self.builder.constInt(0, ty);
@@ -534,7 +534,7 @@ pub fn zeroValue(self: *Lowering, ty: TypeId) Ref {
if (ty.isBuiltin()) return self.builder.constInt(0, ty);
const info = self.module.types.get(ty);
return switch (info) {
// Arbitrary-width integer types (u1, u2, s4, ...) interned as
// Arbitrary-width integer types (u1, u2, i4, ...) interned as
// `.signed`/`.unsigned` variants — fall through `isBuiltin()`.
.signed, .unsigned => self.builder.constInt(0, ty),
.pointer, .tuple, .optional => self.builder.constNull(ty),
@@ -610,8 +610,8 @@ pub fn coerceMode(self: *Lowering, val: Ref, src_ty: TypeId, dst_ty: TypeId, mod
}
return val;
},
// Tuple → Tuple element-wise coercion (e.g. a `(s64, s64)` literal
// flowing into a `(s32, s32)` slot — the multi-value failable success
// Tuple → Tuple element-wise coercion (e.g. a `(i64, i64)` literal
// flowing into a `(i32, i32)` slot — the multi-value failable success
// tuple). Same arity: extract each slot, coerce it, rebuild.
.tuple_elementwise => {
const si = self.module.types.get(src_ty);
@@ -693,14 +693,14 @@ pub fn coerceMode(self: *Lowering, val: Ref, src_ty: TypeId, dst_ty: TypeId, mod
}
/// Apply C default argument promotion to variadic-tail args. These rules
/// (bool/s8/s16/u8/u16 → s32, f32 → f64) match the C calling convention's
/// (bool/i8/i16/u8/u16 → i32, f32 → f64) match the C calling convention's
/// implicit promotions when an argument is passed through `...`.
pub fn promoteCVariadicArgs(self: *Lowering, args: []Ref, fixed_count: usize) void {
if (args.len <= fixed_count) return;
for (args[fixed_count..]) |*arg| {
const src_ty = self.builder.getRefType(arg.*);
const promoted: TypeId = switch (src_ty) {
.bool, .s8, .s16, .u8, .u16 => .s32,
.bool, .i8, .i16, .u8, .u16 => .i32,
.f32 => .f64,
else => continue,
};
@@ -720,7 +720,7 @@ pub fn coerceCallArgs(self: *Lowering, args: []Ref, params: []const Function.Par
if (src_info == .array and dst_info == .many_pointer) {
const slot = self.builder.alloca(src_ty);
self.builder.store(slot, args[i]);
const zero = self.builder.constInt(0, .s64);
const zero = self.builder.constInt(0, .i64);
args[i] = self.builder.emit(.{ .index_gep = .{ .lhs = slot, .rhs = zero } }, dst_ty);
continue;
}