Expand description
The prelude’s implementation: every built-in method, static, constant, and
vtable as Rust host fns, registered under submilli:prelude.
Each method is declared (via [declare_method]) as a value symbol whose
mangled name is the method’s dispatch key (e.g.
submilli:prelude#String#repeat) — the same string is the linker field the
host fn registers under, so codegen’s method lookup resolves straight to the
Rust impl. codegen::prelude::merged_prelude_declaration folds these value
symbols into the single submilli:prelude package next to the type surface;
selected top-level bindings (isNaN, NaN, …) are loaded into user scope by
the typechecker.
Re-exports§
pub use declaration::MODULE_NAME;pub use declaration::cached_runtime_package_declarations;pub use declaration::prelude_package_declaration;
Modules§
- array
- The submilli array’s operations — the Rust port of the prelude’s
ArrayandArrayConstructormethods. - bigint
- The Rust port of the prelude’s
BigIntinstance-method surface (toString(radix?),toJson). The arbitrary-precision compute lives in [crate::runtime::prelude::bigint::ops] (num-bigint); this module is the wasmtime boundary that reads the$bigintreceiver and marshals the$stringresult. - boolean
- The Rust port of the prelude’s
Booleansurface —toString/toJson, both"true"/"false". The receiver is the unboxedi32(0 = false). - declaration
- The prelude’s declaration: the full typed interface/type surface plus the cached package assembly codegen and the typechecker consume.
- map
- The submilli
Map<K, V>— the Rust port of the prelude’s hand-written Wasm hashtable (codegen/prelude/map.rs). - math
- The Rust port of the prelude’s built-in
Mathnamespace. - number
- The Rust port of the prelude’s
Number/NumberConstructorsurface. - object
- The Rust port of the prelude’s
ObjectConstructorstatics —Object.keys/values/entries/hasOwn/is— reading the$ObjectShapefield-name/field-value arrays directly. Every per-arity object subtype subtypes$ObjectShape, so onematches_tytest covers them all; any other value takes the “no fields” path ([]/false), and a null receiver throws a catchableError, matching the Wasm bodies incodegen/prelude/object_shape.rs. - regex
- The Rust port of the prelude’s hand-written Wasm
RegExp/RegExpMatch/RegExpConstructorglue (codegen/prelude/regex.rs). - set
- The submilli
Set<T>— the Rust port of the prelude’s hand-written Wasm hashset (codegen/prelude/set.rs). - string
- The submilli string and its operations — the Rust port of the prelude’s
Stringmethods. - temporal
- Rust implementations of the prelude’s Temporal surface.
- textcodec
- Stateless
TextEncoder/TextDecoder, ported off the Wasm prelude. The instances carry no state —new TextEncoder()builds an empty$ObjectShapewith the host genericobjectvtable, soJSON.stringifyyields{}andtoStringyields[object Object](parity with the old dedicated vtable).encodebridges the$stringUTF-16 ABI to the$Uint8Arraybyte ABI;decodedoes the reverse. UTF-8 only:decodethrows a catchableTypeErroron invalid UTF-8. All marshalling and registration live ininstall. - uint8array
- The submilli
Uint8Arrayoperations — the Rust port of the prelude’sUint8ArrayandUint8ArrayConstructorsurface. Bytes live as aVec<u8>; the higher-order methods box each byte into a$boxed_numberbefore calling back into a guest closure. The$Uint8Arraymarshalling and host-fn registration live ininstall; the sharedClosurehandles callbacks.
Functions§
- install
- Register every ported host fn. Store-less, so it goes into the reusable base
linker; the returned
$string/$Arrayvalues read the prelude’s vtables at call time, not here. The store-bound vtable globals install separately via [install_vtables]. - package_
declaration - The codegen-facing declaration: the value symbols that route ported methods to their Rust impls (see the module doc).