Skip to main content

aver/vm/
mod.rs

1mod alloc_policy;
2mod builtin;
3mod compiler;
4mod execute;
5pub mod opcode;
6mod profile;
7pub mod runtime;
8mod symbol;
9mod types;
10
11pub use compiler::{
12    compile_program, compile_program_with_loaded_modules, compile_program_with_modules,
13};
14pub use execute::VM;
15pub use opcode::opcode_name;
16pub use profile::{
17    VmBuiltinProfile, VmFunctionProfile, VmOpcodeProfile, VmProfileReport, VmReturnStats,
18};
19pub use types::{CallFrame, CodeStore, FnChunk, VmError};
20
21/// Register builtin service record types (HttpResponse, HttpRequest, etc.)
22/// in the arena before compilation. These types are used by services but
23/// not declared in user code.
24pub fn register_service_types(arena: &mut crate::nan_value::Arena) {
25    arena.register_record_type(
26        "HttpResponse",
27        vec!["status".into(), "body".into(), "headers".into()],
28    );
29    arena.register_record_type(
30        "HttpRequest",
31        vec![
32            "method".into(),
33            "path".into(),
34            "body".into(),
35            "headers".into(),
36        ],
37    );
38    arena.register_record_type(
39        "Tcp.Connection",
40        vec!["id".into(), "host".into(), "port".into()],
41    );
42    // Always register Terminal.Size so record-field access works in
43    // every build (the playground wasm ships without `terminal` but
44    // the compiler still emits field reads against the stubs).
45    arena.register_record_type("Terminal.Size", vec!["width".into(), "height".into()]);
46    // Oracle: BranchPath is an opaque builtin wrapping a dewey-decimal string.
47    // Only reachable via BranchPath.root / .child / .parse constructors.
48    arena.register_record_type("BranchPath", vec!["dewey".into()]);
49    // Oracle: EffectEvent represents one recorded effect emission in a
50    // verify-trace assertion's view of a function's trace. Produced by
51    // context-sensitive elaboration of effect-method calls inside trace
52    // blocks; never constructed by user code directly.
53    crate::types::effect_event::register(arena);
54    // Oracle: Trace wraps the list of EffectEvent values emitted during a
55    // verify-trace LHS evaluation. Only materialized via the `.trace`
56    // projection on the verified function's return.
57    crate::types::trace::register(arena);
58}