Expand description
The WASM demo pages’ samples (todo/wasm-demos.md), compiled by fjs compile into gen.samples/ and built for wasm32-unknown-unknown by
gen.build.sh into the committed wasm/. A page loads a sample with its export, runs it with
run_sample, and then reads what the sample wrote to standard output,
one byte at a time, with output_byte: the page is FunctionalScript,
which can call a function but cannot construct a view of the module’s
memory.
Modules§
- samples
- The compiled samples.
npm run genwritesgen.samples/mod.rs; one#[path]names that file, since agen.name is never a Rust identifier.
Functions§
- call
- Calls a sample’s entry with one number, as a page calls a function
sample: what it answered, or what it threw, each as
spellwrites it. - call_
sample - Calls the sample loaded last with
inputand keeps the text of its answer foroutput_byte. Answers the text’s length in bytes where the call returned,-1 - lengthwhere it threw, andi32::MINif no sample is loaded. - load
- Loads a sample: initializes its module with the runtime value, and answers
its
defaultexport, or what it threw. - output_
byte - The
indexth byte the last sample run wrote. - perform
- Performs a sample’s entry: calls it with no arguments, and performs the effect it answers with an empty standard input. Answers what the sample wrote to standard output, or what it threw.
- run_
sample - Runs the sample loaded last and keeps its output. Answers the output’s
length in bytes, or
-1if no sample is loaded or the sample threw. - spell
- A value as the page spells it, as
fjs/nanvm/demos/spelldoes for the JavaScript call: a string quoted as JSON quotes it, abigintwith itsn, an array and an object with their nesting and no spaces, a function as(function), and anything else asString(value)spells it.
Type Aliases§
- Module
- A compiled module: what
fjs compilewrites asmodule, a function of the runtime value, on the VM the samples run on.