selfhost/cmd/wcc/typ: drop ty_ prefix underscore on tctx primitives

This commit is contained in:
2026-05-11 14:38:20 +09:00
parent 6204c4cd27
commit 7ed6b39744
5 changed files with 201 additions and 201 deletions

View File

@@ -2901,7 +2901,7 @@ export fn parsefile(p: *parser) *node = {
// selfhost/cmd/wcc/type.ww — port of cmd/wcc/type.c. // selfhost/cmd/wcc/type.ww — port of cmd/wcc/type.c.
// //
// Status: full structural port. The C version uses module-globals for // Status: full structural port. The C version uses module-globals for
// the primitive types (ty_void, ty_i32, …); ww doesn't have writable // the primitive types (tyvoid, tyi32, …); ww doesn't have writable
// global storage yet, so we bundle the primitives into a `tctx` that // global storage yet, so we bundle the primitives into a `tctx` that
// the checker passes around explicitly. typesinit fills the tctx // the checker passes around explicitly. typesinit fills the tctx
// once per arena. // once per arena.
@@ -2982,30 +2982,30 @@ type tinfo = struct {
type tctx = struct { type tctx = struct {
a: *arena, a: *arena,
ty_void: *tinfo, tyvoid: *tinfo,
ty_bool: *tinfo, tybool: *tinfo,
ty_rune: *tinfo, tyrune: *tinfo,
ty_i8: *tinfo, tyi8: *tinfo,
ty_i16: *tinfo, tyi16: *tinfo,
ty_i32: *tinfo, tyi32: *tinfo,
ty_i64: *tinfo, tyi64: *tinfo,
ty_u8: *tinfo, tyu8: *tinfo,
ty_u16: *tinfo, tyu16: *tinfo,
ty_u32: *tinfo, tyu32: *tinfo,
ty_u64: *tinfo, tyu64: *tinfo,
ty_int: *tinfo, tyint: *tinfo,
ty_uint: *tinfo, tyuint: *tinfo,
ty_uintptr: *tinfo, tyuintptr: *tinfo,
ty_f32: *tinfo, tyf32: *tinfo,
ty_f64: *tinfo, tyf64: *tinfo,
ty_str: *tinfo, tystr: *tinfo,
ty_err: *tinfo, tyerr: *tinfo,
ty_untyped_int: *tinfo, tyuntypedint: *tinfo,
ty_untyped_float: *tinfo, tyuntypedfloat: *tinfo,
ty_untyped_str: *tinfo, tyuntypedstr: *tinfo,
ty_untyped_rune: *tinfo, tyuntypedrune: *tinfo,
ty_untyped_bool: *tinfo, tyuntypedbool: *tinfo,
ty_untyped_nil: *tinfo, tyuntypednil: *tinfo,
}; };
// ---- constructors ----------------------------------------------------- // ---- constructors -----------------------------------------------------
@@ -3026,31 +3026,31 @@ fn prim(a: *arena, k: i32, nm: str, sz: u64, al: u64) *tinfo = {
export fn typesinit(c: *tctx, a: *arena) void = { export fn typesinit(c: *tctx, a: *arena) void = {
c.a = a; c.a = a;
c.ty_void = prim(a, TY_VOID, "void", 0u64, 1u64); c.tyvoid = prim(a, TY_VOID, "void", 0u64, 1u64);
c.ty_bool = prim(a, TY_BOOL, "bool", 1u64, 1u64); c.tybool = prim(a, TY_BOOL, "bool", 1u64, 1u64);
c.ty_rune = prim(a, TY_RUNE, "rune", 4u64, 4u64); c.tyrune = prim(a, TY_RUNE, "rune", 4u64, 4u64);
c.ty_i8 = prim(a, TY_I8, "i8", 1u64, 1u64); c.tyi8 = prim(a, TY_I8, "i8", 1u64, 1u64);
c.ty_i16 = prim(a, TY_I16, "i16", 2u64, 2u64); c.tyi16 = prim(a, TY_I16, "i16", 2u64, 2u64);
c.ty_i32 = prim(a, TY_I32, "i32", 4u64, 4u64); c.tyi32 = prim(a, TY_I32, "i32", 4u64, 4u64);
c.ty_i64 = prim(a, TY_I64, "i64", 8u64, 8u64); c.tyi64 = prim(a, TY_I64, "i64", 8u64, 8u64);
c.ty_u8 = prim(a, TY_U8, "u8", 1u64, 1u64); c.tyu8 = prim(a, TY_U8, "u8", 1u64, 1u64);
c.ty_u16 = prim(a, TY_U16, "u16", 2u64, 2u64); c.tyu16 = prim(a, TY_U16, "u16", 2u64, 2u64);
c.ty_u32 = prim(a, TY_U32, "u32", 4u64, 4u64); c.tyu32 = prim(a, TY_U32, "u32", 4u64, 4u64);
c.ty_u64 = prim(a, TY_U64, "u64", 8u64, 8u64); c.tyu64 = prim(a, TY_U64, "u64", 8u64, 8u64);
c.ty_int = prim(a, TY_INT, "int", 8u64, 8u64); c.tyint = prim(a, TY_INT, "int", 8u64, 8u64);
c.ty_uint = prim(a, TY_UINT, "uint", 8u64, 8u64); c.tyuint = prim(a, TY_UINT, "uint", 8u64, 8u64);
c.ty_uintptr= prim(a, TY_UINTPTR, "uintptr", 8u64, 8u64); c.tyuintptr= prim(a, TY_UINTPTR, "uintptr", 8u64, 8u64);
c.ty_f32 = prim(a, TY_F32, "f32", 4u64, 4u64); c.tyf32 = prim(a, TY_F32, "f32", 4u64, 4u64);
c.ty_f64 = prim(a, TY_F64, "f64", 8u64, 8u64); c.tyf64 = prim(a, TY_F64, "f64", 8u64, 8u64);
c.ty_str = prim(a, TY_STR, "str", 16u64, 8u64); c.tystr = prim(a, TY_STR, "str", 16u64, 8u64);
c.ty_err = prim(a, TY_ERR, "<err>", 0u64, 1u64); c.tyerr = prim(a, TY_ERR, "<err>", 0u64, 1u64);
c.ty_untyped_int = prim(a, TY_UNTYPED_INT, "untyped_int", 0u64, 1u64); c.tyuntypedint = prim(a, TY_UNTYPED_INT, "untyped_int", 0u64, 1u64);
c.ty_untyped_float = prim(a, TY_UNTYPED_FLOAT, "untyped_float", 0u64, 1u64); c.tyuntypedfloat = prim(a, TY_UNTYPED_FLOAT, "untyped_float", 0u64, 1u64);
c.ty_untyped_str = prim(a, TY_UNTYPED_STR, "untyped_str", 0u64, 1u64); c.tyuntypedstr = prim(a, TY_UNTYPED_STR, "untyped_str", 0u64, 1u64);
c.ty_untyped_rune = prim(a, TY_UNTYPED_RUNE, "untyped_rune", 0u64, 1u64); c.tyuntypedrune = prim(a, TY_UNTYPED_RUNE, "untyped_rune", 0u64, 1u64);
c.ty_untyped_bool = prim(a, TY_UNTYPED_BOOL, "untyped_bool", 0u64, 1u64); c.tyuntypedbool = prim(a, TY_UNTYPED_BOOL, "untyped_bool", 0u64, 1u64);
c.ty_untyped_nil = prim(a, TY_UNTYPED_NIL, "untyped_nil", 0u64, 1u64); c.tyuntypednil = prim(a, TY_UNTYPED_NIL, "untyped_nil", 0u64, 1u64);
}; };
export fn typeptr(a: *arena, sub: *tinfo) *tinfo = { export fn typeptr(a: *arena, sub: *tinfo) *tinfo = {
@@ -3379,23 +3379,23 @@ type checker = struct {
// seedprimitives — install the built-in type names so `i32`, `str`, // seedprimitives — install the built-in type names so `i32`, `str`,
// etc. can be looked up like ordinary symbols. // etc. can be looked up like ordinary symbols.
fn seedprimitives(c: *checker) void = { fn seedprimitives(c: *checker) void = {
scopedefine(c.top, "void", SK_TYPE, c.tc.ty_void, nil); scopedefine(c.top, "void", SK_TYPE, c.tc.tyvoid, nil);
scopedefine(c.top, "bool", SK_TYPE, c.tc.ty_bool, nil); scopedefine(c.top, "bool", SK_TYPE, c.tc.tybool, nil);
scopedefine(c.top, "rune", SK_TYPE, c.tc.ty_rune, nil); scopedefine(c.top, "rune", SK_TYPE, c.tc.tyrune, nil);
scopedefine(c.top, "i8", SK_TYPE, c.tc.ty_i8, nil); scopedefine(c.top, "i8", SK_TYPE, c.tc.tyi8, nil);
scopedefine(c.top, "i16", SK_TYPE, c.tc.ty_i16, nil); scopedefine(c.top, "i16", SK_TYPE, c.tc.tyi16, nil);
scopedefine(c.top, "i32", SK_TYPE, c.tc.ty_i32, nil); scopedefine(c.top, "i32", SK_TYPE, c.tc.tyi32, nil);
scopedefine(c.top, "i64", SK_TYPE, c.tc.ty_i64, nil); scopedefine(c.top, "i64", SK_TYPE, c.tc.tyi64, nil);
scopedefine(c.top, "u8", SK_TYPE, c.tc.ty_u8, nil); scopedefine(c.top, "u8", SK_TYPE, c.tc.tyu8, nil);
scopedefine(c.top, "u16", SK_TYPE, c.tc.ty_u16, nil); scopedefine(c.top, "u16", SK_TYPE, c.tc.tyu16, nil);
scopedefine(c.top, "u32", SK_TYPE, c.tc.ty_u32, nil); scopedefine(c.top, "u32", SK_TYPE, c.tc.tyu32, nil);
scopedefine(c.top, "u64", SK_TYPE, c.tc.ty_u64, nil); scopedefine(c.top, "u64", SK_TYPE, c.tc.tyu64, nil);
scopedefine(c.top, "int", SK_TYPE, c.tc.ty_int, nil); scopedefine(c.top, "int", SK_TYPE, c.tc.tyint, nil);
scopedefine(c.top, "uint", SK_TYPE, c.tc.ty_uint, nil); scopedefine(c.top, "uint", SK_TYPE, c.tc.tyuint, nil);
scopedefine(c.top, "uintptr", SK_TYPE, c.tc.ty_uintptr, nil); scopedefine(c.top, "uintptr", SK_TYPE, c.tc.tyuintptr, nil);
scopedefine(c.top, "f32", SK_TYPE, c.tc.ty_f32, nil); scopedefine(c.top, "f32", SK_TYPE, c.tc.tyf32, nil);
scopedefine(c.top, "f64", SK_TYPE, c.tc.ty_f64, nil); scopedefine(c.top, "f64", SK_TYPE, c.tc.tyf64, nil);
scopedefine(c.top, "str", SK_TYPE, c.tc.ty_str, nil); scopedefine(c.top, "str", SK_TYPE, c.tc.tystr, nil);
// `nil`, `true`, `false` are keywords — handled at the lex/parser // `nil`, `true`, `false` are keywords — handled at the lex/parser
// level, no symbol needed. // level, no symbol needed.
// `len`, `alloc`, `free` are pseudo-builtins; scopedefine them so // `len`, `alloc`, `free` are pseudo-builtins; scopedefine them so
@@ -5199,7 +5199,7 @@ fn cgexpr(c: *cgen, n: *node) void = {
// Module-qualified value reference: `mod.name` where `mod` // Module-qualified value reference: `mod.name` where `mod`
// is N_IDENT bound as SK_USE and the leaf isn't a local. // is N_IDENT bound as SK_USE and the leaf isn't a local.
// Treat as a SB symbol — `MOVQ leaf(SB), AX`. Same fallback // Treat as a SB symbol — `MOVQ leaf(SB), AX`. Same fallback
// the C cgen takes when bt is NULL/ty_err. // the C cgen takes when bt is NULL/tyerr.
if (lhs != nil) { if (lhs != nil) {
if (lhs.kind == N_IDENT) { if (lhs.kind == N_IDENT) {
emitline("\tMOVQ\t"); emitline("\tMOVQ\t");

View File

@@ -1607,7 +1607,7 @@ fn cgexpr(c: *cgen, n: *node) void = {
// Module-qualified value reference: `mod.name` where `mod` // Module-qualified value reference: `mod.name` where `mod`
// is N_IDENT bound as SK_USE and the leaf isn't a local. // is N_IDENT bound as SK_USE and the leaf isn't a local.
// Treat as a SB symbol — `MOVQ leaf(SB), AX`. Same fallback // Treat as a SB symbol — `MOVQ leaf(SB), AX`. Same fallback
// the C cgen takes when bt is NULL/ty_err. // the C cgen takes when bt is NULL/tyerr.
if (lhs != nil) { if (lhs != nil) {
if (lhs.kind == N_IDENT) { if (lhs.kind == N_IDENT) {
emitline("\tMOVQ\t"); emitline("\tMOVQ\t");

View File

@@ -35,23 +35,23 @@ type checker = struct {
// seedprimitives — install the built-in type names so `i32`, `str`, // seedprimitives — install the built-in type names so `i32`, `str`,
// etc. can be looked up like ordinary symbols. // etc. can be looked up like ordinary symbols.
fn seedprimitives(c: *checker) void = { fn seedprimitives(c: *checker) void = {
scopedefine(c.top, "void", SK_TYPE, c.tc.ty_void, nil); scopedefine(c.top, "void", SK_TYPE, c.tc.tyvoid, nil);
scopedefine(c.top, "bool", SK_TYPE, c.tc.ty_bool, nil); scopedefine(c.top, "bool", SK_TYPE, c.tc.tybool, nil);
scopedefine(c.top, "rune", SK_TYPE, c.tc.ty_rune, nil); scopedefine(c.top, "rune", SK_TYPE, c.tc.tyrune, nil);
scopedefine(c.top, "i8", SK_TYPE, c.tc.ty_i8, nil); scopedefine(c.top, "i8", SK_TYPE, c.tc.tyi8, nil);
scopedefine(c.top, "i16", SK_TYPE, c.tc.ty_i16, nil); scopedefine(c.top, "i16", SK_TYPE, c.tc.tyi16, nil);
scopedefine(c.top, "i32", SK_TYPE, c.tc.ty_i32, nil); scopedefine(c.top, "i32", SK_TYPE, c.tc.tyi32, nil);
scopedefine(c.top, "i64", SK_TYPE, c.tc.ty_i64, nil); scopedefine(c.top, "i64", SK_TYPE, c.tc.tyi64, nil);
scopedefine(c.top, "u8", SK_TYPE, c.tc.ty_u8, nil); scopedefine(c.top, "u8", SK_TYPE, c.tc.tyu8, nil);
scopedefine(c.top, "u16", SK_TYPE, c.tc.ty_u16, nil); scopedefine(c.top, "u16", SK_TYPE, c.tc.tyu16, nil);
scopedefine(c.top, "u32", SK_TYPE, c.tc.ty_u32, nil); scopedefine(c.top, "u32", SK_TYPE, c.tc.tyu32, nil);
scopedefine(c.top, "u64", SK_TYPE, c.tc.ty_u64, nil); scopedefine(c.top, "u64", SK_TYPE, c.tc.tyu64, nil);
scopedefine(c.top, "int", SK_TYPE, c.tc.ty_int, nil); scopedefine(c.top, "int", SK_TYPE, c.tc.tyint, nil);
scopedefine(c.top, "uint", SK_TYPE, c.tc.ty_uint, nil); scopedefine(c.top, "uint", SK_TYPE, c.tc.tyuint, nil);
scopedefine(c.top, "uintptr", SK_TYPE, c.tc.ty_uintptr, nil); scopedefine(c.top, "uintptr", SK_TYPE, c.tc.tyuintptr, nil);
scopedefine(c.top, "f32", SK_TYPE, c.tc.ty_f32, nil); scopedefine(c.top, "f32", SK_TYPE, c.tc.tyf32, nil);
scopedefine(c.top, "f64", SK_TYPE, c.tc.ty_f64, nil); scopedefine(c.top, "f64", SK_TYPE, c.tc.tyf64, nil);
scopedefine(c.top, "str", SK_TYPE, c.tc.ty_str, nil); scopedefine(c.top, "str", SK_TYPE, c.tc.tystr, nil);
// `nil`, `true`, `false` are keywords — handled at the lex/parser // `nil`, `true`, `false` are keywords — handled at the lex/parser
// level, no symbol needed. // level, no symbol needed.
// `len`, `alloc`, `free` are pseudo-builtins; scopedefine them so // `len`, `alloc`, `free` are pseudo-builtins; scopedefine them so

View File

@@ -1,7 +1,7 @@
// selfhost/cmd/wcc/type.ww — port of cmd/wcc/type.c. // selfhost/cmd/wcc/type.ww — port of cmd/wcc/type.c.
// //
// Status: full structural port. The C version uses module-globals for // Status: full structural port. The C version uses module-globals for
// the primitive types (ty_void, ty_i32, …); ww doesn't have writable // the primitive types (tyvoid, tyi32, …); ww doesn't have writable
// global storage yet, so we bundle the primitives into a `tctx` that // global storage yet, so we bundle the primitives into a `tctx` that
// the checker passes around explicitly. typesinit fills the tctx // the checker passes around explicitly. typesinit fills the tctx
// once per arena. // once per arena.
@@ -82,30 +82,30 @@ type tinfo = struct {
type tctx = struct { type tctx = struct {
a: *arena, a: *arena,
ty_void: *tinfo, tyvoid: *tinfo,
ty_bool: *tinfo, tybool: *tinfo,
ty_rune: *tinfo, tyrune: *tinfo,
ty_i8: *tinfo, tyi8: *tinfo,
ty_i16: *tinfo, tyi16: *tinfo,
ty_i32: *tinfo, tyi32: *tinfo,
ty_i64: *tinfo, tyi64: *tinfo,
ty_u8: *tinfo, tyu8: *tinfo,
ty_u16: *tinfo, tyu16: *tinfo,
ty_u32: *tinfo, tyu32: *tinfo,
ty_u64: *tinfo, tyu64: *tinfo,
ty_int: *tinfo, tyint: *tinfo,
ty_uint: *tinfo, tyuint: *tinfo,
ty_uintptr: *tinfo, tyuintptr: *tinfo,
ty_f32: *tinfo, tyf32: *tinfo,
ty_f64: *tinfo, tyf64: *tinfo,
ty_str: *tinfo, tystr: *tinfo,
ty_err: *tinfo, tyerr: *tinfo,
ty_untyped_int: *tinfo, tyuntypedint: *tinfo,
ty_untyped_float: *tinfo, tyuntypedfloat: *tinfo,
ty_untyped_str: *tinfo, tyuntypedstr: *tinfo,
ty_untyped_rune: *tinfo, tyuntypedrune: *tinfo,
ty_untyped_bool: *tinfo, tyuntypedbool: *tinfo,
ty_untyped_nil: *tinfo, tyuntypednil: *tinfo,
}; };
// ---- constructors ----------------------------------------------------- // ---- constructors -----------------------------------------------------
@@ -126,31 +126,31 @@ fn prim(a: *arena, k: i32, nm: str, sz: u64, al: u64) *tinfo = {
export fn typesinit(c: *tctx, a: *arena) void = { export fn typesinit(c: *tctx, a: *arena) void = {
c.a = a; c.a = a;
c.ty_void = prim(a, TY_VOID, "void", 0u64, 1u64); c.tyvoid = prim(a, TY_VOID, "void", 0u64, 1u64);
c.ty_bool = prim(a, TY_BOOL, "bool", 1u64, 1u64); c.tybool = prim(a, TY_BOOL, "bool", 1u64, 1u64);
c.ty_rune = prim(a, TY_RUNE, "rune", 4u64, 4u64); c.tyrune = prim(a, TY_RUNE, "rune", 4u64, 4u64);
c.ty_i8 = prim(a, TY_I8, "i8", 1u64, 1u64); c.tyi8 = prim(a, TY_I8, "i8", 1u64, 1u64);
c.ty_i16 = prim(a, TY_I16, "i16", 2u64, 2u64); c.tyi16 = prim(a, TY_I16, "i16", 2u64, 2u64);
c.ty_i32 = prim(a, TY_I32, "i32", 4u64, 4u64); c.tyi32 = prim(a, TY_I32, "i32", 4u64, 4u64);
c.ty_i64 = prim(a, TY_I64, "i64", 8u64, 8u64); c.tyi64 = prim(a, TY_I64, "i64", 8u64, 8u64);
c.ty_u8 = prim(a, TY_U8, "u8", 1u64, 1u64); c.tyu8 = prim(a, TY_U8, "u8", 1u64, 1u64);
c.ty_u16 = prim(a, TY_U16, "u16", 2u64, 2u64); c.tyu16 = prim(a, TY_U16, "u16", 2u64, 2u64);
c.ty_u32 = prim(a, TY_U32, "u32", 4u64, 4u64); c.tyu32 = prim(a, TY_U32, "u32", 4u64, 4u64);
c.ty_u64 = prim(a, TY_U64, "u64", 8u64, 8u64); c.tyu64 = prim(a, TY_U64, "u64", 8u64, 8u64);
c.ty_int = prim(a, TY_INT, "int", 8u64, 8u64); c.tyint = prim(a, TY_INT, "int", 8u64, 8u64);
c.ty_uint = prim(a, TY_UINT, "uint", 8u64, 8u64); c.tyuint = prim(a, TY_UINT, "uint", 8u64, 8u64);
c.ty_uintptr= prim(a, TY_UINTPTR, "uintptr", 8u64, 8u64); c.tyuintptr= prim(a, TY_UINTPTR, "uintptr", 8u64, 8u64);
c.ty_f32 = prim(a, TY_F32, "f32", 4u64, 4u64); c.tyf32 = prim(a, TY_F32, "f32", 4u64, 4u64);
c.ty_f64 = prim(a, TY_F64, "f64", 8u64, 8u64); c.tyf64 = prim(a, TY_F64, "f64", 8u64, 8u64);
c.ty_str = prim(a, TY_STR, "str", 16u64, 8u64); c.tystr = prim(a, TY_STR, "str", 16u64, 8u64);
c.ty_err = prim(a, TY_ERR, "<err>", 0u64, 1u64); c.tyerr = prim(a, TY_ERR, "<err>", 0u64, 1u64);
c.ty_untyped_int = prim(a, TY_UNTYPED_INT, "untyped_int", 0u64, 1u64); c.tyuntypedint = prim(a, TY_UNTYPED_INT, "untyped_int", 0u64, 1u64);
c.ty_untyped_float = prim(a, TY_UNTYPED_FLOAT, "untyped_float", 0u64, 1u64); c.tyuntypedfloat = prim(a, TY_UNTYPED_FLOAT, "untyped_float", 0u64, 1u64);
c.ty_untyped_str = prim(a, TY_UNTYPED_STR, "untyped_str", 0u64, 1u64); c.tyuntypedstr = prim(a, TY_UNTYPED_STR, "untyped_str", 0u64, 1u64);
c.ty_untyped_rune = prim(a, TY_UNTYPED_RUNE, "untyped_rune", 0u64, 1u64); c.tyuntypedrune = prim(a, TY_UNTYPED_RUNE, "untyped_rune", 0u64, 1u64);
c.ty_untyped_bool = prim(a, TY_UNTYPED_BOOL, "untyped_bool", 0u64, 1u64); c.tyuntypedbool = prim(a, TY_UNTYPED_BOOL, "untyped_bool", 0u64, 1u64);
c.ty_untyped_nil = prim(a, TY_UNTYPED_NIL, "untyped_nil", 0u64, 1u64); c.tyuntypednil = prim(a, TY_UNTYPED_NIL, "untyped_nil", 0u64, 1u64);
}; };
export fn typeptr(a: *arena, sub: *tinfo) *tinfo = { export fn typeptr(a: *arena, sub: *tinfo) *tinfo = {

View File

@@ -2901,7 +2901,7 @@ export fn parsefile(p: *parser) *node = {
// selfhost/cmd/wcc/type.ww — port of cmd/wcc/type.c. // selfhost/cmd/wcc/type.ww — port of cmd/wcc/type.c.
// //
// Status: full structural port. The C version uses module-globals for // Status: full structural port. The C version uses module-globals for
// the primitive types (ty_void, ty_i32, …); ww doesn't have writable // the primitive types (tyvoid, tyi32, …); ww doesn't have writable
// global storage yet, so we bundle the primitives into a `tctx` that // global storage yet, so we bundle the primitives into a `tctx` that
// the checker passes around explicitly. typesinit fills the tctx // the checker passes around explicitly. typesinit fills the tctx
// once per arena. // once per arena.
@@ -2982,30 +2982,30 @@ type tinfo = struct {
type tctx = struct { type tctx = struct {
a: *arena, a: *arena,
ty_void: *tinfo, tyvoid: *tinfo,
ty_bool: *tinfo, tybool: *tinfo,
ty_rune: *tinfo, tyrune: *tinfo,
ty_i8: *tinfo, tyi8: *tinfo,
ty_i16: *tinfo, tyi16: *tinfo,
ty_i32: *tinfo, tyi32: *tinfo,
ty_i64: *tinfo, tyi64: *tinfo,
ty_u8: *tinfo, tyu8: *tinfo,
ty_u16: *tinfo, tyu16: *tinfo,
ty_u32: *tinfo, tyu32: *tinfo,
ty_u64: *tinfo, tyu64: *tinfo,
ty_int: *tinfo, tyint: *tinfo,
ty_uint: *tinfo, tyuint: *tinfo,
ty_uintptr: *tinfo, tyuintptr: *tinfo,
ty_f32: *tinfo, tyf32: *tinfo,
ty_f64: *tinfo, tyf64: *tinfo,
ty_str: *tinfo, tystr: *tinfo,
ty_err: *tinfo, tyerr: *tinfo,
ty_untyped_int: *tinfo, tyuntypedint: *tinfo,
ty_untyped_float: *tinfo, tyuntypedfloat: *tinfo,
ty_untyped_str: *tinfo, tyuntypedstr: *tinfo,
ty_untyped_rune: *tinfo, tyuntypedrune: *tinfo,
ty_untyped_bool: *tinfo, tyuntypedbool: *tinfo,
ty_untyped_nil: *tinfo, tyuntypednil: *tinfo,
}; };
// ---- constructors ----------------------------------------------------- // ---- constructors -----------------------------------------------------
@@ -3026,31 +3026,31 @@ fn prim(a: *arena, k: i32, nm: str, sz: u64, al: u64) *tinfo = {
export fn typesinit(c: *tctx, a: *arena) void = { export fn typesinit(c: *tctx, a: *arena) void = {
c.a = a; c.a = a;
c.ty_void = prim(a, TY_VOID, "void", 0u64, 1u64); c.tyvoid = prim(a, TY_VOID, "void", 0u64, 1u64);
c.ty_bool = prim(a, TY_BOOL, "bool", 1u64, 1u64); c.tybool = prim(a, TY_BOOL, "bool", 1u64, 1u64);
c.ty_rune = prim(a, TY_RUNE, "rune", 4u64, 4u64); c.tyrune = prim(a, TY_RUNE, "rune", 4u64, 4u64);
c.ty_i8 = prim(a, TY_I8, "i8", 1u64, 1u64); c.tyi8 = prim(a, TY_I8, "i8", 1u64, 1u64);
c.ty_i16 = prim(a, TY_I16, "i16", 2u64, 2u64); c.tyi16 = prim(a, TY_I16, "i16", 2u64, 2u64);
c.ty_i32 = prim(a, TY_I32, "i32", 4u64, 4u64); c.tyi32 = prim(a, TY_I32, "i32", 4u64, 4u64);
c.ty_i64 = prim(a, TY_I64, "i64", 8u64, 8u64); c.tyi64 = prim(a, TY_I64, "i64", 8u64, 8u64);
c.ty_u8 = prim(a, TY_U8, "u8", 1u64, 1u64); c.tyu8 = prim(a, TY_U8, "u8", 1u64, 1u64);
c.ty_u16 = prim(a, TY_U16, "u16", 2u64, 2u64); c.tyu16 = prim(a, TY_U16, "u16", 2u64, 2u64);
c.ty_u32 = prim(a, TY_U32, "u32", 4u64, 4u64); c.tyu32 = prim(a, TY_U32, "u32", 4u64, 4u64);
c.ty_u64 = prim(a, TY_U64, "u64", 8u64, 8u64); c.tyu64 = prim(a, TY_U64, "u64", 8u64, 8u64);
c.ty_int = prim(a, TY_INT, "int", 8u64, 8u64); c.tyint = prim(a, TY_INT, "int", 8u64, 8u64);
c.ty_uint = prim(a, TY_UINT, "uint", 8u64, 8u64); c.tyuint = prim(a, TY_UINT, "uint", 8u64, 8u64);
c.ty_uintptr= prim(a, TY_UINTPTR, "uintptr", 8u64, 8u64); c.tyuintptr= prim(a, TY_UINTPTR, "uintptr", 8u64, 8u64);
c.ty_f32 = prim(a, TY_F32, "f32", 4u64, 4u64); c.tyf32 = prim(a, TY_F32, "f32", 4u64, 4u64);
c.ty_f64 = prim(a, TY_F64, "f64", 8u64, 8u64); c.tyf64 = prim(a, TY_F64, "f64", 8u64, 8u64);
c.ty_str = prim(a, TY_STR, "str", 16u64, 8u64); c.tystr = prim(a, TY_STR, "str", 16u64, 8u64);
c.ty_err = prim(a, TY_ERR, "<err>", 0u64, 1u64); c.tyerr = prim(a, TY_ERR, "<err>", 0u64, 1u64);
c.ty_untyped_int = prim(a, TY_UNTYPED_INT, "untyped_int", 0u64, 1u64); c.tyuntypedint = prim(a, TY_UNTYPED_INT, "untyped_int", 0u64, 1u64);
c.ty_untyped_float = prim(a, TY_UNTYPED_FLOAT, "untyped_float", 0u64, 1u64); c.tyuntypedfloat = prim(a, TY_UNTYPED_FLOAT, "untyped_float", 0u64, 1u64);
c.ty_untyped_str = prim(a, TY_UNTYPED_STR, "untyped_str", 0u64, 1u64); c.tyuntypedstr = prim(a, TY_UNTYPED_STR, "untyped_str", 0u64, 1u64);
c.ty_untyped_rune = prim(a, TY_UNTYPED_RUNE, "untyped_rune", 0u64, 1u64); c.tyuntypedrune = prim(a, TY_UNTYPED_RUNE, "untyped_rune", 0u64, 1u64);
c.ty_untyped_bool = prim(a, TY_UNTYPED_BOOL, "untyped_bool", 0u64, 1u64); c.tyuntypedbool = prim(a, TY_UNTYPED_BOOL, "untyped_bool", 0u64, 1u64);
c.ty_untyped_nil = prim(a, TY_UNTYPED_NIL, "untyped_nil", 0u64, 1u64); c.tyuntypednil = prim(a, TY_UNTYPED_NIL, "untyped_nil", 0u64, 1u64);
}; };
export fn typeptr(a: *arena, sub: *tinfo) *tinfo = { export fn typeptr(a: *arena, sub: *tinfo) *tinfo = {
@@ -3379,23 +3379,23 @@ type checker = struct {
// seedprimitives — install the built-in type names so `i32`, `str`, // seedprimitives — install the built-in type names so `i32`, `str`,
// etc. can be looked up like ordinary symbols. // etc. can be looked up like ordinary symbols.
fn seedprimitives(c: *checker) void = { fn seedprimitives(c: *checker) void = {
scopedefine(c.top, "void", SK_TYPE, c.tc.ty_void, nil); scopedefine(c.top, "void", SK_TYPE, c.tc.tyvoid, nil);
scopedefine(c.top, "bool", SK_TYPE, c.tc.ty_bool, nil); scopedefine(c.top, "bool", SK_TYPE, c.tc.tybool, nil);
scopedefine(c.top, "rune", SK_TYPE, c.tc.ty_rune, nil); scopedefine(c.top, "rune", SK_TYPE, c.tc.tyrune, nil);
scopedefine(c.top, "i8", SK_TYPE, c.tc.ty_i8, nil); scopedefine(c.top, "i8", SK_TYPE, c.tc.tyi8, nil);
scopedefine(c.top, "i16", SK_TYPE, c.tc.ty_i16, nil); scopedefine(c.top, "i16", SK_TYPE, c.tc.tyi16, nil);
scopedefine(c.top, "i32", SK_TYPE, c.tc.ty_i32, nil); scopedefine(c.top, "i32", SK_TYPE, c.tc.tyi32, nil);
scopedefine(c.top, "i64", SK_TYPE, c.tc.ty_i64, nil); scopedefine(c.top, "i64", SK_TYPE, c.tc.tyi64, nil);
scopedefine(c.top, "u8", SK_TYPE, c.tc.ty_u8, nil); scopedefine(c.top, "u8", SK_TYPE, c.tc.tyu8, nil);
scopedefine(c.top, "u16", SK_TYPE, c.tc.ty_u16, nil); scopedefine(c.top, "u16", SK_TYPE, c.tc.tyu16, nil);
scopedefine(c.top, "u32", SK_TYPE, c.tc.ty_u32, nil); scopedefine(c.top, "u32", SK_TYPE, c.tc.tyu32, nil);
scopedefine(c.top, "u64", SK_TYPE, c.tc.ty_u64, nil); scopedefine(c.top, "u64", SK_TYPE, c.tc.tyu64, nil);
scopedefine(c.top, "int", SK_TYPE, c.tc.ty_int, nil); scopedefine(c.top, "int", SK_TYPE, c.tc.tyint, nil);
scopedefine(c.top, "uint", SK_TYPE, c.tc.ty_uint, nil); scopedefine(c.top, "uint", SK_TYPE, c.tc.tyuint, nil);
scopedefine(c.top, "uintptr", SK_TYPE, c.tc.ty_uintptr, nil); scopedefine(c.top, "uintptr", SK_TYPE, c.tc.tyuintptr, nil);
scopedefine(c.top, "f32", SK_TYPE, c.tc.ty_f32, nil); scopedefine(c.top, "f32", SK_TYPE, c.tc.tyf32, nil);
scopedefine(c.top, "f64", SK_TYPE, c.tc.ty_f64, nil); scopedefine(c.top, "f64", SK_TYPE, c.tc.tyf64, nil);
scopedefine(c.top, "str", SK_TYPE, c.tc.ty_str, nil); scopedefine(c.top, "str", SK_TYPE, c.tc.tystr, nil);
// `nil`, `true`, `false` are keywords — handled at the lex/parser // `nil`, `true`, `false` are keywords — handled at the lex/parser
// level, no symbol needed. // level, no symbol needed.
// `len`, `alloc`, `free` are pseudo-builtins; scopedefine them so // `len`, `alloc`, `free` are pseudo-builtins; scopedefine them so
@@ -5199,7 +5199,7 @@ fn cgexpr(c: *cgen, n: *node) void = {
// Module-qualified value reference: `mod.name` where `mod` // Module-qualified value reference: `mod.name` where `mod`
// is N_IDENT bound as SK_USE and the leaf isn't a local. // is N_IDENT bound as SK_USE and the leaf isn't a local.
// Treat as a SB symbol — `MOVQ leaf(SB), AX`. Same fallback // Treat as a SB symbol — `MOVQ leaf(SB), AX`. Same fallback
// the C cgen takes when bt is NULL/ty_err. // the C cgen takes when bt is NULL/tyerr.
if (lhs != nil) { if (lhs != nil) {
if (lhs.kind == N_IDENT) { if (lhs.kind == N_IDENT) {
emitline("\tMOVQ\t"); emitline("\tMOVQ\t");