code wiki / (root) / nx_str_canonical.nx

nx_str_canonical.nx

buildroot/runtime/nx_str_canonical.nx

8418 B311 linesdepth 2pulls 2 transitivereach 0 importersview sourcekind orphan librarytopic str
docsdependenciesstructsconstsfunctions

about

str.nx -- first-class string / byte-slice type for NishiLang. Carries (ptr, length) by pointer. Fixes the null-terminator problem: `str` can store embedded zeros, and length is O(1). Eventually generalizes to `Slice<T>` once A4 (generics) lands; for now we specialize to bytes because that's 99% of the use case (HTTP parsing, markdown, file contents, console I/O). Usage pattern: let hello: *str = str_from_cstr("Hello, World\n") sys_write(1, hello.ptr, hello.len) Helper `str_from_cstr(ptr)` computes length by walking to NUL. For true runtime-constructed slices (e.g. a substring), use `str_new(ptr, len)` which stores as-given.

dependencies 1 imports · 0 importers

nx_syscalls.nx nx_str_canonical.nx

imports: nx_syscalls.nx

imported by: nobody (leaf or entry point)

structs

18struct str

consts

none

functions

34func str_sys_mmap(size: i64) -> *u8
called by 2: str_from_cstrstr_new calls 1: sys_mmap
42func str_from_cstr(p: *u8) -> *str
calls 1: str_sys_mmap
54func str_new(p: *u8, len: i64) -> *str
64func str_empty() -> *str
called by 1: str_split_once calls 1: str_new
70func str_len(s: *str) -> i64 { return s.len }
71func str_is_empty(s: *str) -> i64
78func str_at(s: *str, i: i64) -> i64
85func str_eq(a: *str, b: *str) -> i64
99func str_eq_cstr(a: *str, cstr: *u8) -> i64
115func str_substr(s: *str, begin: i64, end: i64) -> *str
called by 2: str_split_oncestr_trim calls 1: str_new
122func str_starts_with(s: *str, prefix: *str) -> i64
135func str_index_of(s: *str, c: i64) -> i64
called by 1: str_split_once
149func str_split_once(s: *str, c: i64, rest_out: *i64) -> *str
162func str_trim(s: *str) -> *str
calls 1: str_substr
184func str_parse_int(s: *str, consumed_out: *i64) -> i64
209func str_write(fd: i64, s: *str) -> i64
216func str_ends_with(s: *str, suffix: *str) -> i64
230func str_contains(s: *str, needle: *str) -> i64
250func str_to_lower(s: *str) -> *str
calls 2: sys_mmapstr_new
265func str_to_upper(s: *str) -> *str
calls 2: sys_mmapstr_new
281func str_format_int(n: i64) -> *str
calls 2: sys_mmapstr_new