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

@@ -29,7 +29,7 @@ const hasComptimeParams = Lowering.hasComptimeParams;
pub fn lowerCall(self: *Lowering, c_in: *const ast.Call) Ref {
var c = c_in;
// A bare reserved-type-name spelling in call position parses as a
// `.type_expr` (e.g. `s2(4)`), but if a function of that name is in
// `.type_expr` (e.g. `i2(4)`), but if a function of that name is in
// scope — a backtick-declared sx fn or a `#import c` foreign fn whose C
// name collides with a reserved type spelling — it is a CALL to that
// function. `TypeName(val)` is not a cast (casts are `cast(T, val)`), so
@@ -411,7 +411,7 @@ pub fn lowerCall(self: *Lowering, c_in: *const ast.Call) Ref {
// Check builtins first (these are handled natively by interpreter and emitter)
if (resolveBuiltin(id.name)) |bid| {
const ret_ty: TypeId = switch (bid) {
.size_of, .align_of => .s64,
.size_of, .align_of => .i64,
.sqrt, .sin, .cos, .floor => blk: {
// Math builtins: return type matches argument type ($T -> T)
if (c.args.len > 0) {
@@ -530,8 +530,8 @@ pub fn lowerCall(self: *Lowering, c_in: *const ast.Call) Ref {
const callee_ref = if (binding.is_alloca) self.builder.load(binding.ref, binding.ty) else binding.ref;
const ret_ty = if (!binding.ty.isBuiltin()) blk: {
const bti = self.module.types.get(binding.ty);
break :blk if (bti == .function) bti.function.ret else .s64;
} else .s64;
break :blk if (bti == .function) bti.function.ret else .i64;
} else .i64;
var final_args = std.ArrayList(Ref).empty;
defer final_args.deinit(self.alloc);
if (self.fnPtrTypeWantsCtx(binding.ty)) {
@@ -623,8 +623,8 @@ pub fn lowerCall(self: *Lowering, c_in: *const ast.Call) Ref {
// Type constructor call: Sx(f32).user(0.5) — obj is a call that returns a type
if (fa.object.data == .call) {
const inner_call = &fa.object.data.call;
// Generic struct STATIC-METHOD head (`Box(s64).make(..)` or the
// qualified `a.Box(s64).make(..)`): the layout author is chosen
// Generic struct STATIC-METHOD head (`Box(i64).make(..)` or the
// qualified `a.Box(i64).make(..)`): the layout author is chosen
// by the single head choke-point (CP-1) and the method body by
// the instance's STAMPED author (CP-4), so layout-author ≡
// body-author for BOTH bare and qualified heads (E4 #1 / #2).
@@ -1025,7 +1025,7 @@ pub fn lowerCall(self: *Lowering, c_in: *const ast.Call) Ref {
// call PLAN selected for the receiver's source — the SAME author
// plan typed the call's result as, so dispatch and typing can't
// disagree (without this, a string-typed winner over
// an s64 shadow boxes a raw int as a string pointer → segfault).
// an i64 shadow boxes a raw int as a string pointer → segfault).
// The plan is the single producer; lowering consumes its verdict
// (`sel_author` / `cplan.ambiguous_collision`, computed once above)
// rather than re-resolving the field name. `.ambiguous` → loud
@@ -1189,7 +1189,7 @@ pub fn lowerCall(self: *Lowering, c_in: *const ast.Call) Ref {
// Indirect call through expression
const callee_ref = self.lowerExpr(c.callee);
const owned = self.alloc.dupe(Ref, args.items) catch unreachable;
return self.builder.emit(.{ .call_indirect = .{ .callee = callee_ref, .args = owned } }, .s64);
return self.builder.emit(.{ .call_indirect = .{ .callee = callee_ref, .args = owned } }, .i64);
},
}
}
@@ -1426,7 +1426,7 @@ pub fn lowerRuntimeDispatchCall(
const type_tag_raw = self.lowerExpr(type_tag_node orelse return self.emitError("dispatch", call_node.callee.span));
const type_tag_node_ty = self.inferExprType(type_tag_node.?);
const type_tag = if (type_tag_node_ty == .any)
self.builder.emit(.{ .unbox_any = .{ .operand = type_tag_raw } }, .s64)
self.builder.emit(.{ .unbox_any = .{ .operand = type_tag_raw } }, .i64)
else
type_tag_raw;
const any_val = self.lowerExpr(any_val_node orelse return self.emitError("dispatch", call_node.callee.span));
@@ -1630,13 +1630,13 @@ pub fn lowerRuntimeDispatchCall(
@memcpy(final_call_args[1..], call_args.items);
}
}
// Coerce non-cast args (source type unknown, use s64 default).
// Coerce non-cast args (source type unknown, use i64 default).
// cast_arg_idx is in user-space (skips __sx_ctx); offset by ctx_slots.
const ctx_slots: usize = if (callee_has_ctx) 1 else 0;
for (0..@min(final_call_args.len, callee_params.len)) |ci| {
if (ci < ctx_slots) continue; // skip __sx_ctx slot
if ((ci - ctx_slots) != cast_arg_idx) {
final_call_args[ci] = self.coerceToType(final_call_args[ci], .s64, callee_params[ci].ty);
final_call_args[ci] = self.coerceToType(final_call_args[ci], .i64, callee_params[ci].ty);
}
}
const result = self.builder.call(fid, final_call_args, callee_ret);
@@ -1680,12 +1680,12 @@ pub fn tryLowerReflectionCall(self: *Lowering, name: []const u8, c: *const ast.C
// size_of(T) → const_int(sizeof(T))
const ty = self.resolveTypeArg(c.args[0]);
const size: i64 = @intCast(self.typeSizeBytes(ty));
return self.builder.constInt(size, .s64);
return self.builder.constInt(size, .i64);
}
if (std.mem.eql(u8, name, "align_of")) {
const ty = self.resolveTypeArg(c.args[0]);
const a: i64 = @intCast(self.module.types.typeAlignBytes(ty));
return self.builder.constInt(a, .s64);
return self.builder.constInt(a, .i64);
}
if (std.mem.eql(u8, name, "field_count")) {
// field_count(T) → const_int(N)
@@ -1700,7 +1700,7 @@ pub fn tryLowerReflectionCall(self: *Lowering, name: []const u8, c: *const ast.C
.vector => |v| @intCast(v.length),
else => 0,
};
return self.builder.constInt(count, .s64);
return self.builder.constInt(count, .i64);
}
if (std.mem.eql(u8, name, "type_name")) {
// type_name(T):
@@ -1712,8 +1712,8 @@ pub fn tryLowerReflectionCall(self: *Lowering, name: []const u8, c: *const ast.C
// `callBuiltin(.type_name, [arg_ref])`. The interp's
// arm (commit 9600ba5) reads the runtime `.type_tag`
// and returns the per-position name. Without this
// split, the catch-all `else => .s64` in
// `resolveTypeArg` silently returns "s64" for every
// split, the catch-all `else => .i64` in
// `resolveTypeArg` silently returns "i64" for every
// dynamic call — exactly the silent-arm pattern the
// project's REJECTED PATTERNS forbid.
if (self.isStaticTypeArg(c.args[0])) {
@@ -1729,8 +1729,8 @@ pub fn tryLowerReflectionCall(self: *Lowering, name: []const u8, c: *const ast.C
if (std.mem.eql(u8, name, "type_eq")) {
// type_eq(T1, T2) → const_bool — comptime TypeId equality.
// TypeIds are interned per structural shape so equality on
// them matches the user's intuition: `type_eq(s64, s64)` is
// true, `type_eq(*s64, *s64)` is true, distinct shapes are
// them matches the user's intuition: `type_eq(i64, i64)` is
// true, `type_eq(*i64, *i64)` is true, distinct shapes are
// false. Pack-indexed types (`$args[0]`) resolve through
// `resolveTypeArg` → `resolveTypeWithBindings`.
if (c.args.len < 2) return self.builder.constBool(false);
@@ -1745,7 +1745,7 @@ pub fn tryLowerReflectionCall(self: *Lowering, name: []const u8, c: *const ast.C
// `any_to_string` — emits a `callBuiltin`: the interp reads
// the boxed TypeId, LLVM GEPs a per-type signedness table.
// Mirrors `type_name`'s static/dynamic split; the same split
// avoids `resolveTypeArg`'s silent `.s64` default lying about
// avoids `resolveTypeArg`'s silent `.i64` default lying about
// a runtime Type value.
if (c.args.len < 1) return self.builder.constBool(false);
if (self.isStaticTypeArg(c.args[0])) {
@@ -1873,7 +1873,7 @@ pub fn tryLowerReflectionCall(self: *Lowering, name: []const u8, c: *const ast.C
// the returned value carries Type semantics (tag field
// says ".any" → the value field holds the type id).
const val = self.lowerExpr(c.args[0]);
const tag_val = self.builder.structGet(val, 0, .s64);
const tag_val = self.builder.structGet(val, 0, .i64);
return self.builder.boxAny(tag_val, .any);
} else {
return self.builder.constType(arg_ty);
@@ -1881,14 +1881,14 @@ pub fn tryLowerReflectionCall(self: *Lowering, name: []const u8, c: *const ast.C
}
if (std.mem.eql(u8, name, "field_index")) {
// field_index(T, val) → extract tag from tagged union
if (c.args.len < 2) return self.builder.constInt(0, .s64);
if (c.args.len < 2) return self.builder.constInt(0, .i64);
const val = self.lowerExpr(c.args[1]);
// For tagged unions: extract field 0 (the tag)
return self.builder.emit(.{ .enum_tag = .{ .operand = val } }, .s64);
return self.builder.emit(.{ .enum_tag = .{ .operand = val } }, .i64);
}
if (std.mem.eql(u8, name, "field_value_int")) {
// field_value_int(T, i) → lookup enum variant value by index
if (c.args.len < 2) return self.builder.constInt(0, .s64);
if (c.args.len < 2) return self.builder.constInt(0, .i64);
const ty = self.resolveTypeArg(c.args[0]);
const idx = self.lowerExpr(c.args[1]);
// For enums with explicit values, build a global value array and index into it
@@ -1901,11 +1901,11 @@ pub fn tryLowerReflectionCall(self: *Lowering, name: []const u8, c: *const ast.C
var elems = std.ArrayList(Ref).empty;
defer elems.deinit(self.alloc);
for (vals) |v| {
elems.append(self.alloc, self.builder.constInt(v, .s64)) catch unreachable;
elems.append(self.alloc, self.builder.constInt(v, .i64)) catch unreachable;
}
const arr_ty = self.module.types.arrayOf(.s64, @intCast(vals.len));
const arr_ty = self.module.types.arrayOf(.i64, @intCast(vals.len));
const arr = self.builder.structInit(elems.items, arr_ty);
return self.builder.emit(.{ .index_get = .{ .lhs = arr, .rhs = idx } }, .s64);
return self.builder.emit(.{ .index_get = .{ .lhs = arr, .rhs = idx } }, .i64);
}
}
}
@@ -1921,7 +1921,7 @@ pub fn tryLowerReflectionCall(self: *Lowering, name: []const u8, c: *const ast.C
/// shapes), or a runtime `Type` value — which is `.any`-typed at
/// runtime (`type_of(x)`, a `[]Type` element `list[i]`, a `Type`-typed
/// local / field / param). Any other expression — a value of type
/// s64 / f64 / bool / a struct — is NOT a type.
/// i64 / f64 / bool / a struct — is NOT a type.
pub fn reflectionArgIsType(self: *Lowering, arg: *const Node) bool {
if (self.isStaticTypeArg(arg)) return true;
return self.inferExprType(arg) == .any;
@@ -1986,7 +1986,7 @@ pub fn reflectionErrorSentinel(self: *Lowering, name: []const u8) Ref {
std.mem.eql(u8, name, "type_is_unsigned") or
std.mem.eql(u8, name, "is_flags"))
return self.builder.constBool(false);
return self.builder.constInt(0, .s64);
return self.builder.constInt(0, .i64);
}
/// After args have been lowered, append the lowered values of any