Skip to main content

Crate viperjs

Crate viperjs 

Source
Expand description

ViperJS — an embeddable JavaScript engine in safe Rust, with zero runtime dependencies.

Start at api. api::Engine runs a script, binds host functions written in Rust, and can give a run a wall-clock budget that the script cannot catch — which is what makes running untrusted source a configuration problem rather than a liability. examples/embed.rs is the tour.

Everything else is public because the engine is meant to be taken apart: lexer, parser and compile are each usable on their own, and span is the worked example of the standard the rest is held to. That is a wide surface on purpose, and none of it is stable until 1.0.

§The one invariant that outranks everything

No input may panic. Every failure a script author can cause — a syntax error, a stack overflow, a 100 MB string literal, a truncated UTF-16 surrogate — is a Result, never a panic and never a process exit. An embedder runs untrusted source inside their own binary; a panic there is our bug, categorically, and no amount of “well, that input is absurd” makes it not our bug.

Modules§

api
The embedding surface — DR-0021.
ast
The syntax tree.
bigint
§6.1.6.2’s BigInt — an integer with no width, and the arithmetic §6.1.6.2.1 to §6.1.6.2.22 asks of it.
builtins
The objects a script can reach without making them — §19 through §28, as far as they go.
compile
The syntax tree to bytecode — §13’s evaluation semantics, rearranged.
heap
Where the values that do not fit in a register live.
lexer
Source text to tokens — trivia, punctuators, names, and end of input.
parser
Tokens to a syntax tree.
realm
The objects that exist before any code runs — §9.3’s realm, in the part that has one yet.
regexp
§22.2 — regular expressions, pattern and matcher both.
span
Source positions — byte spans, and the line/column translation used by every error message.
static_semantics
Syntax-directed operations over the tree (ECMAScript §8.2, §8.3).
value
The ECMAScript language values (ECMA-262 §6.1), and every question one can be asked without a heap.
vm
The interpreter loop — a stack, a chunk, and one match.

Constants§

VERSION
The engine version, as reported to embedders (viperjs::VERSION).

Functions§

local_offset
The offset from UTC the engine is currently treating as local, in milliseconds.
set_local_offset
Tell the engine what the host’s offset from UTC is, in milliseconds east of it.