Skip to main content

aver/vm/
mod.rs

1mod builtin;
2mod compiler;
3mod execute;
4pub mod opcode;
5mod profile;
6mod runtime;
7mod symbol;
8mod types;
9
10pub use compiler::{compile_program, compile_program_with_modules};
11pub use execute::VM;
12pub use opcode::opcode_name;
13pub use profile::{
14    VmBuiltinProfile, VmFunctionProfile, VmOpcodeProfile, VmProfileReport, VmReturnStats,
15};
16pub use types::{CallFrame, CodeStore, FnChunk, VmError};
17
18/// Register builtin service record types (HttpResponse, HttpRequest, etc.)
19/// in the arena before compilation. These types are used by services but
20/// not declared in user code.
21pub fn register_service_types(arena: &mut crate::nan_value::Arena) {
22    arena.register_record_type(
23        "HttpResponse",
24        vec!["status".into(), "body".into(), "headers".into()],
25    );
26    arena.register_record_type(
27        "HttpRequest",
28        vec![
29            "method".into(),
30            "path".into(),
31            "body".into(),
32            "headers".into(),
33        ],
34    );
35    arena.register_record_type("Header", vec!["name".into(), "value".into()]);
36    arena.register_record_type(
37        "Tcp.Connection",
38        vec!["id".into(), "host".into(), "port".into()],
39    );
40    #[cfg(feature = "terminal")]
41    arena.register_record_type("Terminal.Size", vec!["width".into(), "height".into()]);
42}