Skip to main content

Module l0

Module l0 

Source
Expand description

L0, the core of the WASM runtime interface (l0-design.md), as typed Rust over Any.

One function per L0 function, under its L0 name, generic over IVm. The types are Rust’s, not the ABI’s: an index is a u32, the bytes of a string or a bigint are a slice, a container is built through a Builder, and call answers a Result. dup and drop are Clone and Drop, and an argument is borrowed unless the design says the function takes it.

Where WASM traps, a function here panics, with the text the FunctionalScript view of L0 throws, l0.<name>: <reason>, so the tests below and that view’s proofs check the same preconditions.

An object answers its properties as Object::own_entries lists them: each key once, array-index keys first, as a JavaScript host and the FunctionalScript view do. NaNVM keeps an object’s properties as they were written, so a read computes that view each time.

Modules§

abi
L0’s ABI over handles: step 2 of todo/l0-interface.md.

Structs§

Builder
An open container: what L0’s begin_array and begin_object answer, filled by push or push_property with exactly the number of items it was begun with, then sealed.

Enums§

Kind
A value’s kind, as L0 kind answers it. The tags are part of the ABI version.

Functions§

begin_array
L0 begin_array: a builder of an array of len items.
begin_object
L0 begin_object: a builder of an object of len properties, before repeated keys merge.
call
L0 call: f called with args, a sealed array. Err is a thrown value, status 1 in the ABI.
concat
L0 concat: two strings joined.
find
L0 find: the index of the property key of an object, or -1. The key must be a string.
frame
L0 frame: the item i of the frame of the function whose code is running, read through the code’s self_.
from_bool
L0 from_bool, which also makes the constants true and false.
from_f64
L0 from_f64. A NaN loses its payload.
from_unit
L0 from_unit: the string of one UTF-16 unit.
item
L0 item: the item i of an array, or the value of the property i of an object.
join
L0 join: the strings of an array joined, with separator between two of them (l0-design.md §22). Each item and the separator must be strings.
key
L0 key: the key of the property i of an object.
kind
L0 kind.
length
L0 length (l0-design.md §18): a string’s UTF-16 units, a bigint’s u64 words, an array’s items, an object’s properties, and a function’s declared parameters.
make_bigint
L0 make_bigint: a sign, 0, 1 or -1, and a magnitude in u64 words, least significant first, in its canonical form only: no leading zero word, and the sign 0 for zero alone (l0-design.md §19).
make_function
L0 make_function: a function of code over frame, a sealed array, declaring length parameters. NaNVM keeps a function’s text as a &'static str, where L0 passes a string value.
make_string
L0 make_string: a string of UTF-16 units.
null
L0 null.
read_units
L0 read_units: the units of s from start, as many as out holds.
read_words
L0 read_words: the words of b’s magnitude from start, as many as out holds.
same
L0 same: whether two arrays, objects or functions are the same value. A primitive traps: L1 compares those by content.
sign
L0 sign: 0 for zero, 1 for a positive bigint and -1 for a negative one.
substring
L0 substring: the units of s from start up to end, where start <= end <= length. It neither clamps nor counts from the end.
text
L0 text: a function’s text, or undefined for a function that has none.
to_bool
L0 to_bool.
to_f64
L0 to_f64.
undefined
L0 undefined.
unit
L0 unit: the UTF-16 unit i of a string.