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