Skip to main content

Crate nova_runtime

Crate nova_runtime 

Source
Expand description

The Nova runtime: support functions linked into every Nova program.

Phase 1 scope (spec 13-RUNTIME.md, “minimal: panic, allocator, basic types”): string values, console output, and sum-type allocation. All functions use the C ABI so compiled Nova code (Cranelift/LLVM) can call them directly; for nova run they are registered as JIT symbols via symbols.

Memory: heap values (records, sums, arrays, closures, strings, and Bytes) are managed by a conservative mark-and-sweep garbage collector — see [gc] and docs/adr/0002-phase1-leaking-allocator.md. All heap allocation routes through [gc::alloc], which reclaims unreachable objects.

Modules§

bytes
Byte-buffer intrinsics for std/bytes. pub, not private, for the same reason as fs: its own doc comment explains the boundary it implements (one representation, shared with NovaStr, distinguished only by hir::Ty). Branch byte-type’s own Task 3 (docs/superpowers/plans/2026-08-12-byte-type.md) added the rest of the byte surface beside this module’s first four intrinsics, the same way this crate’s other modules build on task. Byte-buffer intrinsics for std/bytes.
fs
Filesystem intrinsics for std/fs. pub, not private: its own doc comment explains the boundary it implements; nothing about that requires hiding the module itself. Branch std-fs-strings’s Task 3 and Task 4 (docs/superpowers/plans/2026-08-11-std-fs-strings.md) built most of this module, and branch byte-type’s own Task 4 later added read/write beside them, the same way this crate’s other modules build on task. Filesystem intrinsics for std/fs.
io
The three standard streams’ intrinsics for std/io. pub, not private, for the same reason as fs and bytes: its own doc comment explains the boundary it implements. Branch read-write-stdio’s Task 1 added this module beside fs and bytes, reusing fs‘s per-task slot table rather than owning a second one. The three standard streams’ boundary.
process
The program’s arguments and exit, behind std/process (see its module doc and docs/adr/0023-program-arguments.md). pub so the driver’s JIT path can set the list, and so tests/process_args_*.rs can drive it. The running program’s arguments, and a way to end it with a status: the runtime half of std/process’s args() and exit().
signal
The process-wide shutdown flag std/http’s Server::listen polls (see its module doc and docs/adr/0022-process-shutdown-signals.md). pub, unlike [time], so tests/signal_*.rs can drive it. The process-wide shutdown flag behind std/http’s graceful Server::listen.
task
pub, not private like [gc]: task’s ABI constants (PollFn, POLL_READY, STATE_SLOT_TAG, STATE_SLOT_TEMPS) are not all read by this crate’s own runtime logic – some exist purely as the documented contract codegen (Task 5’s async_lower.rs) must reproduce. A private module would make those pub items unreachable from outside the crate, which both defeats their purpose and makes rustc’s dead_code lint treat them as genuinely dead, since nothing inside this crate alone uses them. A single-threaded cooperative executor.

Structs§

NovaStr
A Nova string value: immutable UTF-8, { len, ptr }.

Functions§

nova_rt_alloc
Allocate size zeroed bytes for a heap value — a sum { tag, fields... }, record { fields... }, array { len, elems... }, or closure environment. The result is GC-managed and its slots are traced for further pointers.
nova_rt_bool_to_str
Format a Bool as true / false.
nova_rt_char_to_str
Format a Char (Unicode scalar value) as a string.
nova_rt_check_bounds
Abort if index is outside 0..len (an array bounds violation).
nova_rt_eprint⚠
Write s to stderr with no trailing newline.
nova_rt_eprintln⚠
Write s to stderr followed by a newline.
nova_rt_float_fixed
Format a Float to a fixed number of decimal places.
nova_rt_float_to_str
Format a Float as a string.
nova_rt_int_hash_seed
The per-process seed for std/core’s Int, Bool and Char hashing, XORed into the input before mix64 runs.
nova_rt_int_to_str
Format an Int as a string.
nova_rt_json_quote⚠
s as a JSON string literal, quotation marks included: the body of std/json’s quote.
nova_rt_panic_str⚠
Abort the program with a panic message given as a Nova string.
nova_rt_print⚠
Print a string to stdout without a trailing newline.
nova_rt_println⚠
Print a string followed by a newline to stdout.
nova_rt_str_chars⚠
Decompose s into a Nova [Char].
nova_rt_str_cmp⚠
Byte-lexicographic comparison of two strings: -1, 0, or 1.
nova_rt_str_concat⚠
Concatenate two strings into a new string value.
nova_rt_str_concat_n⚠
Concatenate every string in parts into one new string: the n-ary form string interpolation of three or more parts lowers to.
nova_rt_str_eq⚠
Compare two strings for byte equality.
nova_rt_str_from_chars⚠
Encode a Nova [Char] back into a string.
nova_rt_str_hash⚠
Seeded, finalized hash of a Nova string’s bytes, as an i64.
nova_rt_str_index_of⚠
The character index of the first occurrence of needle in haystack, or -1: the body of std/strings’ String.index_of and String.contains. An empty needle occurs at 0.
nova_rt_str_join⚠
Join every string in parts with sep between each pair: the body of std/strings’ String.join.
nova_rt_str_len_chars⚠
Number of Unicode scalar values in s.
nova_rt_str_new⚠
Create a string value from raw bytes (used for string literals).
nova_rt_str_to_float⚠
Parse decimal text as a Float.
nova_rt_str_to_lower⚠
Lowercase s with full Unicode case mapping. Whole-string for the same reason as nova_rt_str_to_upper.
nova_rt_str_to_upper⚠
Uppercase s with full Unicode case mapping.
nova_rt_test_selector
test_selector() -> i64. See Builtin::TestSelector.
splitmix64_finalize
splitmix64’s finalizer — the same function std/core’s mix64 computes.
symbols
All runtime symbols, for registration with the JIT (or a linker map).