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:
@@ -43,10 +43,10 @@ pub const Type = union(enum) {
|
||||
unresolved,
|
||||
|
||||
/// `is_raw` records whether the inner type-name came from a backtick raw
|
||||
/// reference (`` `s2 ``) or an already-resolved user type. It is the
|
||||
/// reference (`` `i2 ``) or an already-resolved user type. It is the
|
||||
/// `skip_builtin` the resolver MUST pass when re-resolving the stored inner
|
||||
/// name — without it `resolveTypeNameStr` would reclassify a
|
||||
/// user type named `s2` as the builtin int, diverging from codegen. The
|
||||
/// user type named `i2` as the builtin int, diverging from codegen. The
|
||||
/// field is REQUIRED (no default) so a future construction site cannot
|
||||
/// silently drop the bit, the way the LSP index did for compound shapes.
|
||||
pub const SliceTypeInfo = struct {
|
||||
@@ -115,14 +115,7 @@ pub const Type = union(enum) {
|
||||
pub fn fromName(name: []const u8) ?Type {
|
||||
if (name.len == 0) return null;
|
||||
return switch (name[0]) {
|
||||
's' => {
|
||||
if (std.mem.eql(u8, name, "string")) return .string_type;
|
||||
if (name.len >= 2) {
|
||||
const width = std.fmt.parseInt(u8, name[1..], 10) catch return null;
|
||||
if (width >= 1 and width <= 64) return Type.s(width);
|
||||
}
|
||||
return null;
|
||||
},
|
||||
's' => if (std.mem.eql(u8, name, "string")) .string_type else null,
|
||||
'u' => {
|
||||
if (std.mem.eql(u8, name, "usize")) return .usize_type;
|
||||
if (name.len >= 2) {
|
||||
@@ -133,6 +126,10 @@ pub const Type = union(enum) {
|
||||
},
|
||||
'i' => {
|
||||
if (std.mem.eql(u8, name, "isize")) return .isize_type;
|
||||
if (name.len >= 2) {
|
||||
const width = std.fmt.parseInt(u8, name[1..], 10) catch return null;
|
||||
if (width >= 1 and width <= 64) return Type.s(width);
|
||||
}
|
||||
return null;
|
||||
},
|
||||
'b' => if (std.mem.eql(u8, name, "bool")) .boolean else null,
|
||||
@@ -181,14 +178,14 @@ pub const Type = union(enum) {
|
||||
}
|
||||
|
||||
/// Returns the canonical type name for this type, or null for complex types.
|
||||
/// Used for looking up impl methods on non-struct types (e.g., s32.eq).
|
||||
/// Used for looking up impl methods on non-struct types (e.g., i32.eq).
|
||||
pub fn toName(self: Type) ?[]const u8 {
|
||||
return switch (self) {
|
||||
.signed => |w| switch (w) {
|
||||
8 => "s8",
|
||||
16 => "s16",
|
||||
32 => "s32",
|
||||
64 => "s64",
|
||||
8 => "i8",
|
||||
16 => "i16",
|
||||
32 => "i32",
|
||||
64 => "i64",
|
||||
else => null,
|
||||
},
|
||||
.unsigned => |w| switch (w) {
|
||||
@@ -214,7 +211,7 @@ pub const Type = union(enum) {
|
||||
|
||||
pub fn fromTypeExpr(node: *Node) ?Type {
|
||||
if (node.data != .type_expr) return null;
|
||||
// A backtick raw type reference (`` `s2 ``) is the LITERAL name used as
|
||||
// A backtick raw type reference (`` `i2 ``) is the LITERAL name used as
|
||||
// a type — it must skip this builtin/reserved classifier and resolve
|
||||
// through user-defined types only, mirroring the codegen-
|
||||
// side `resolveNamed`'s `skip_builtin`. Returning null lets the sema
|
||||
@@ -272,12 +269,12 @@ pub const Type = union(enum) {
|
||||
return try allocator.dupe(u8, result);
|
||||
}
|
||||
|
||||
/// Format type name for mangling and display (e.g. "s32", "u8", "f64")
|
||||
/// Format type name for mangling and display (e.g. "i32", "u8", "f64")
|
||||
pub fn displayName(self: Type, allocator: std.mem.Allocator) ![]const u8 {
|
||||
return switch (self) {
|
||||
.signed => |w| {
|
||||
var buf: [4]u8 = undefined;
|
||||
const result = std.fmt.bufPrint(&buf, "s{d}", .{w}) catch unreachable;
|
||||
const result = std.fmt.bufPrint(&buf, "i{d}", .{w}) catch unreachable;
|
||||
return try allocator.dupe(u8, result);
|
||||
},
|
||||
.unsigned => |w| {
|
||||
|
||||
Reference in New Issue
Block a user