Expand description
Cove in a browser tab: the front end and the linear-memory backend behind a C ABI, with no server and no Cove runtime anywhere but the page.
Issue #241 asks for a
playground. This crate is the half of it that is Rust; web/ is the half
that is a page. What it exports is described in abi, and it is seven
functions and one import.
The fifth is debug_json: the same run, watched by a recording
debugger, so that the page can scrub through a timeline of it. A browser
cannot be given the debugger cove debug is — a Web Worker cannot block
waiting for the page — and record says at length why, and what
recording keeps and loses instead.
The sixth is lex_json, which is the front end’s first stage and
nothing after it: the page colours its editor by asking the compiler’s own
lexer what each piece of the text is. highlight argues why that is the
only version of syntax highlighting worth having here.
The seventh is lex_ir_json, the same idea for the other text the page
shows: the disassembly cove_ir::print writes. That one has no lexer to
borrow, so highlight reads the line shapes the printer documents and
says, in ok, when it met a line it did not know — which is what
web/check.mjs holds it to, against the real disassembly of every shipped
sample.
§What is the same as cove run, and what is not
The same: the parser, the checker, the lowering, the VM, the diagnostics
(rendered by cove_diag::render, so the browser shows the sentences the
CLI shows), and the shipped host schemas — so a program that uses http
type-checks here exactly as it does on the command line, and is refused at
the boundary here exactly as it is there without a grant.
Not the same, and each for a reason a browser gives:
- No filesystem.
filesanddocumentsare the in-memory hosts the differential harness uses, seeded empty;processis recorded;httpanddatabaseare denied. Nothing here can reach anything. - No real clock host.
clockisVirtualTime, which is what makesclock.sleepfinish at once and a program that measures itself deterministic. The run’s clock is a different thing and is real: seeRUN_LIMITS. - No tasks.
spawnis refused, with a span, in the runtime. A Cove task is a thread (ADR 0008) and one Web Worker is one thread; the alternative was to run a task’s body inline, which would make this answer differently from the tree-walking oracle, and the corpus is held together by those two agreeing.examples/tasksdoes not run here, and that is the honest outcome rather than a bug.
Modules§
- abi
- The C ABI a JavaScript embedder calls, and the two allocation primitives that make it usable.
- highlight
- Colouring source the way the compiler reads it, and a disassembly the way its printer writes it.
- record
- Recording a run so that a page can scrub through it.
Constants§
- ENTRY
- The entry function looked for in
MODULE. - GRANTS
- What a run in the playground is granted.
- MODULE
- The module a playground’s one source file belongs to, and the function that is run.
- RUN_
LIMITS - What bounds a run that the page did not bound itself.
Functions§
- compile_
json - Checks and lowers
source, and answers what a reader would want to see before running it. - debug_
json - Runs
sourceasrun_jsondoes, watched by arecord::Recorder, and answers everythingrun_jsonanswers plus the recording underdebug. - lex_
ir_ json - Colours a disassembly and answers a colour for every part of it.
- lex_
json - Lexes
sourceand answers a colour for every part of it. - run_
json - Checks, lowers and runs
source, and answers what happened.