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:
@@ -556,7 +556,7 @@ pub const Lowering = struct {
|
||||
return self.resolveTypeWithBindings(rt);
|
||||
}
|
||||
// No explicit annotation — the type is inferred from the body, which
|
||||
// references the function's own parameters (`(x: s32) => x * 2`). Those
|
||||
// references the function's own parameters (`(x: i32) => x * 2`). Those
|
||||
// params aren't pushed into `self.scope` until body lowering, so bind
|
||||
// them into a temporary scope here; otherwise `inferExprType` can't
|
||||
// resolve `x`, the inference yields `.unresolved`, and that reaches LLVM
|
||||
@@ -806,7 +806,7 @@ pub const Lowering = struct {
|
||||
// trampoline bodies (`(*void, $args[0]) -> $args[1]`) in stdlib's
|
||||
// generic Into(Block) impl. OOB indices / a missing binding emit a
|
||||
// diagnostic and return the `.unresolved` sentinel — never a plausible
|
||||
// `.s64`, which would silently fabricate an 8-byte int.
|
||||
// `.i64`, which would silently fabricate an 8-byte int.
|
||||
if (node.data == .pack_index_type_expr) {
|
||||
const pi = node.data.pack_index_type_expr;
|
||||
if (self.pack_arg_types) |pat| {
|
||||
@@ -933,7 +933,7 @@ pub const Lowering = struct {
|
||||
},
|
||||
.identifier => |id| return self.resolveNominalLeaf(id.name, id.is_raw, node.span),
|
||||
// A non-spread tuple literal in a type position is a tuple-type
|
||||
// literal (`(s32, s32)`); validate its elements are types and reject
|
||||
// literal (`(i32, i32)`); validate its elements are types and reject
|
||||
// non-type elements loudly.
|
||||
.tuple_literal => return self.resolveTupleLiteralTypeArg(node),
|
||||
else => return type_bridge.resolveAstType(node, &self.module.types, &self.program_index.type_alias_map, &self.program_index.module_const_map),
|
||||
@@ -1117,7 +1117,7 @@ pub const Lowering = struct {
|
||||
|
||||
/// Get the element type for a slice/array/string type. A non-collection
|
||||
/// type has no element type — return `.unresolved` (asking for it is a bug)
|
||||
/// rather than a plausible `.s64`.
|
||||
/// rather than a plausible `.i64`.
|
||||
pub fn getElementType(self: *Lowering, ty: TypeId) TypeId {
|
||||
if (ty == .string) return .u8;
|
||||
if (ty.isBuiltin()) return .unresolved;
|
||||
@@ -1154,7 +1154,7 @@ pub const Lowering = struct {
|
||||
/// value path (`lowerBinaryOp`) and AST-level inference
|
||||
/// (`ExprTyper.inferType`'s binary-op arm), so static typing reports
|
||||
/// exactly the type the lowered value carries. An integer LHS with a
|
||||
/// floating-point RHS promotes to the float (`s64 + f64` → `f64`); every
|
||||
/// floating-point RHS promotes to the float (`i64 + f64` → `f64`); every
|
||||
/// other pairing — including vectors / structs, whose `isInt` is false —
|
||||
/// takes the LHS type. Comparison / logical ops never reach here (they
|
||||
/// are `.bool` at both sites).
|
||||
@@ -1165,7 +1165,7 @@ pub const Lowering = struct {
|
||||
|
||||
fn isInt(ty: TypeId) bool {
|
||||
return switch (ty) {
|
||||
.s8, .s16, .s32, .s64, .u8, .u16, .u32, .u64, .usize, .isize => true,
|
||||
.i8, .i16, .i32, .i64, .u8, .u16, .u32, .u64, .usize, .isize => true,
|
||||
else => false,
|
||||
};
|
||||
}
|
||||
@@ -1293,15 +1293,15 @@ pub const Lowering = struct {
|
||||
var width: u8 = 0;
|
||||
var is_signed = false;
|
||||
switch (ty) {
|
||||
.s8 => {
|
||||
.i8 => {
|
||||
width = 8;
|
||||
is_signed = true;
|
||||
},
|
||||
.s16 => {
|
||||
.i16 => {
|
||||
width = 16;
|
||||
is_signed = true;
|
||||
},
|
||||
.s32 => {
|
||||
.i32 => {
|
||||
width = 32;
|
||||
is_signed = true;
|
||||
},
|
||||
@@ -1309,7 +1309,7 @@ pub const Lowering = struct {
|
||||
.u16 => width = 16,
|
||||
.u32 => width = 32,
|
||||
else => {
|
||||
if (ty.isBuiltin()) return null; // s64/u64/isize/usize/non-int
|
||||
if (ty.isBuiltin()) return null; // i64/u64/isize/usize/non-int
|
||||
switch (self.module.types.get(ty)) {
|
||||
.signed => |w| {
|
||||
width = w;
|
||||
@@ -1343,7 +1343,7 @@ pub const Lowering = struct {
|
||||
const tn = blk: {
|
||||
if (ty.isBuiltin()) break :blk self.module.types.typeName(ty);
|
||||
break :blk switch (self.module.types.get(ty)) {
|
||||
.signed => |w| std.fmt.bufPrint(&name_buf, "s{d}", .{w}) catch "integer",
|
||||
.signed => |w| std.fmt.bufPrint(&name_buf, "i{d}", .{w}) catch "integer",
|
||||
.unsigned => |w| std.fmt.bufPrint(&name_buf, "u{d}", .{w}) catch "integer",
|
||||
else => self.module.types.typeName(ty),
|
||||
};
|
||||
@@ -1449,10 +1449,10 @@ pub const Lowering = struct {
|
||||
fn typeBits(ty: TypeId) u32 {
|
||||
return switch (ty) {
|
||||
.bool => 1,
|
||||
.s8, .u8 => 8,
|
||||
.s16, .u16 => 16,
|
||||
.s32, .u32 => 32,
|
||||
.s64, .u64 => 64,
|
||||
.i8, .u8 => 8,
|
||||
.i16, .u16 => 16,
|
||||
.i32, .u32 => 32,
|
||||
.i64, .u64 => 64,
|
||||
.usize, .isize => 0, // target-dependent — use typeBitsEx
|
||||
.f32 => 32,
|
||||
.f64 => 64,
|
||||
|
||||
Reference in New Issue
Block a user