code wiki / (root) / generic_types_test.nx

generic_types_test.nx

buildroot/runtime/generic_types_test.nx

2207 B64 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind gate/proof
docsdependenciesstructsconstsfunctions

about

generic_types_test.nx -- exercises the monomorphization port. Declares a generic struct and uses it with two distinct type arguments in the same module. If monomorphization is working, the two instantiations produce separate Type objects keyed under mangled names (Pair$i64 and Pair$p). If broken, they collapse into one shared struct and the payloads would type- confuse. Today this file is compiled ONLY through nxc2.exe (the C-based compiler using parse.c). That establishes the reference behaviour. When nxc.nx (using parse.nx's ported monomorphization) is bootstrapped through QEMU, compiling this file with it should produce byte-identical output to the nxc2.exe version -- which will confirm parse.nx's instantiate_generic_n logic matches parse.c's for real. For now, the file serves as: 1. A live test-case for parse.c + code-gen of the feature 2. A future regression guard when parse.nx becomes the actual compiler frontend 3. Concrete documentation of what generic struct usage looks like in NishiLang

dependencies 1 imports · 0 importers

syscalls.nx generic_types_test.nx

imports: syscalls.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main make_pair_i64 make_pair_str

structs

28struct Pair<T> {

consts

none

functions

34func make_pair_i64(a: i64, b: i64) -> *Pair<i64> {
called by 1: main
43func make_pair_str(a: *u8, b: *u8) -> *Pair<*u8> {
called by 1: main
52func main() -> i64 {