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:
@@ -9,7 +9,7 @@ pub const TypeId = enum(u32) {
|
||||
// Builtin slots 0–17.
|
||||
/// Resolution failed (e.g. an unannotated param whose type was never
|
||||
/// inferred from context). A dedicated sentinel — never a legitimate
|
||||
/// result — so downstream `== .void`/`== .s64` checks can't silently
|
||||
/// result — so downstream `== .void`/`== .i64` checks can't silently
|
||||
/// swallow it. Must never reach codegen; sizeOf/toLLVMType panic on it.
|
||||
///
|
||||
/// Deliberately slot 0: a zero-initialised or forgotten `TypeId` (the most
|
||||
@@ -17,10 +17,10 @@ pub const TypeId = enum(u32) {
|
||||
/// tripwire, rather than silently masquerading as `.void`.
|
||||
unresolved = 0,
|
||||
bool = 1,
|
||||
s8 = 2,
|
||||
s16 = 3,
|
||||
s32 = 4,
|
||||
s64 = 5,
|
||||
i8 = 2,
|
||||
i16 = 3,
|
||||
i32 = 4,
|
||||
i64 = 5,
|
||||
u8 = 6,
|
||||
u16 = 7,
|
||||
u32 = 8,
|
||||
@@ -125,7 +125,7 @@ pub const TypeInfo = union(enum) {
|
||||
pub const TaggedUnionInfo = struct {
|
||||
name: StringId,
|
||||
fields: []const StructInfo.Field,
|
||||
tag_type: TypeId, // tag integer type (e.g. .u32, .s64)
|
||||
tag_type: TypeId, // tag integer type (e.g. .u32, .i64)
|
||||
backing_type: ?TypeId = null, // enum struct backing (e.g. { tag: u32; _: u32; payload: [30]u32; })
|
||||
explicit_tag_values: ?[]const i64 = null, // explicit variant values (e.g., quit :: 0x100)
|
||||
nominal_id: u32 = 0, // stable nominal identity; 0 == structural (legacy)
|
||||
@@ -366,10 +366,10 @@ pub const TypeTable = struct {
|
||||
const builtins = [_]TypeInfo{
|
||||
.unresolved, // 0: resolution-failure sentinel
|
||||
.bool, // 1
|
||||
.{ .signed = 8 }, // 2: s8
|
||||
.{ .signed = 16 }, // 3: s16
|
||||
.{ .signed = 32 }, // 4: s32
|
||||
.{ .signed = 64 }, // 5: s64
|
||||
.{ .signed = 8 }, // 2: i8
|
||||
.{ .signed = 16 }, // 3: i16
|
||||
.{ .signed = 32 }, // 4: i32
|
||||
.{ .signed = 64 }, // 5: i64
|
||||
.{ .unsigned = 8 }, // 6: u8
|
||||
.{ .unsigned = 16 }, // 7: u16
|
||||
.{ .unsigned = 32 }, // 8: u32
|
||||
@@ -662,11 +662,11 @@ pub const TypeTable = struct {
|
||||
/// True iff `ty` is an unsigned integer — a builtin (u8/u16/u32/u64/usize)
|
||||
/// or a user-defined arbitrary-width unsigned int. Canonical signedness
|
||||
/// query for reflection (`type_is_unsigned`) and the `{}` formatter so a
|
||||
/// u64 value renders as unsigned decimal rather than the s64 reinterpretation.
|
||||
/// u64 value renders as unsigned decimal rather than the i64 reinterpretation.
|
||||
pub fn isUnsignedInt(self: *const TypeTable, ty: TypeId) bool {
|
||||
switch (ty) {
|
||||
.u8, .u16, .u32, .u64, .usize => return true,
|
||||
.bool, .s8, .s16, .s32, .s64, .isize => return false,
|
||||
.bool, .i8, .i16, .i32, .i64, .isize => return false,
|
||||
else => {},
|
||||
}
|
||||
if (ty.isBuiltin()) return false;
|
||||
@@ -677,10 +677,10 @@ pub const TypeTable = struct {
|
||||
const ptr_size: usize = self.pointer_size;
|
||||
if (ty == .void) return 0;
|
||||
if (ty == .bool) return 1;
|
||||
if (ty == .u8 or ty == .s8) return 1;
|
||||
if (ty == .u16 or ty == .s16) return 2;
|
||||
if (ty == .s32 or ty == .u32 or ty == .f32) return 4;
|
||||
if (ty == .s64 or ty == .u64 or ty == .f64) return 8;
|
||||
if (ty == .u8 or ty == .i8) return 1;
|
||||
if (ty == .u16 or ty == .i16) return 2;
|
||||
if (ty == .i32 or ty == .u32 or ty == .f32) return 4;
|
||||
if (ty == .i64 or ty == .u64 or ty == .f64) return 8;
|
||||
if (ty == .usize or ty == .isize) return ptr_size;
|
||||
if (ty == .string) return 16; // {ptr, i64} — always 16 (i64 alignment pads on wasm32)
|
||||
if (ty == .any) return 16; // {i64 tag, i64 value} — Any boxed layout
|
||||
@@ -777,10 +777,10 @@ pub const TypeTable = struct {
|
||||
const ptr_align: usize = self.pointer_size;
|
||||
if (ty == .void) return 1;
|
||||
if (ty == .bool) return 1;
|
||||
if (ty == .u8 or ty == .s8) return 1;
|
||||
if (ty == .u16 or ty == .s16) return 2;
|
||||
if (ty == .s32 or ty == .u32 or ty == .f32) return 4;
|
||||
if (ty == .s64 or ty == .u64 or ty == .f64) return 8;
|
||||
if (ty == .u8 or ty == .i8) return 1;
|
||||
if (ty == .u16 or ty == .i16) return 2;
|
||||
if (ty == .i32 or ty == .u32 or ty == .f32) return 4;
|
||||
if (ty == .i64 or ty == .u64 or ty == .f64) return 8;
|
||||
if (ty == .usize or ty == .isize) return ptr_align;
|
||||
if (ty == .string) return 8; // i64 drives alignment
|
||||
if (ty == .any) return 8; // {i64, i64} aligns to 8
|
||||
@@ -836,16 +836,16 @@ pub const TypeTable = struct {
|
||||
return self.strings.get(id);
|
||||
}
|
||||
|
||||
/// Format a TypeId for display (e.g., "s32", "*bool", "[]u8").
|
||||
/// Format a TypeId for display (e.g., "i32", "*bool", "[]u8").
|
||||
pub fn typeName(self: *const TypeTable, id: TypeId) []const u8 {
|
||||
// Fast path for builtins
|
||||
return switch (id) {
|
||||
.void => "void",
|
||||
.bool => "bool",
|
||||
.s8 => "s8",
|
||||
.s16 => "s16",
|
||||
.s32 => "s32",
|
||||
.s64 => "s64",
|
||||
.i8 => "i8",
|
||||
.i16 => "i16",
|
||||
.i32 => "i32",
|
||||
.i64 => "i64",
|
||||
.u8 => "u8",
|
||||
.u16 => "u16",
|
||||
.u32 => "u32",
|
||||
@@ -965,7 +965,7 @@ pub const TypeTable = struct {
|
||||
buf.append(alloc, ')') catch break :blk "pack(?)";
|
||||
break :blk buf.toOwnedSlice(alloc) catch "pack(?)";
|
||||
},
|
||||
.signed => |w| std.fmt.allocPrint(alloc, "s{d}", .{w}) catch "s?",
|
||||
.signed => |w| std.fmt.allocPrint(alloc, "i{d}", .{w}) catch "i?",
|
||||
.unsigned => |w| std.fmt.allocPrint(alloc, "u{d}", .{w}) catch "u?",
|
||||
else => self.typeName(id),
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user