pub struct JsVm {
pub stack: Vec<JsValue>,
pub call_stack: Vec<CallFrame>,
pub globals: BTreeMap<String, JsValue>,
pub object_arena: Vec<JsObject>,
pub function_arena: Vec<FunctionTemplate>,
pub output: Vec<String>,
/* private fields */
}Expand description
JavaScript virtual machine
Fields§
§stack: Vec<JsValue>Operand stack
call_stack: Vec<CallFrame>Call stack
globals: BTreeMap<String, JsValue>Global variables
object_arena: Vec<JsObject>Object arena
function_arena: Vec<FunctionTemplate>Function templates
output: Vec<String>Output buffer (from console.log)
Implementations§
Source§impl JsVm
impl JsVm
pub fn new() -> Self
Sourcepub fn alloc_object(&mut self, obj: JsObject) -> ObjectId
pub fn alloc_object(&mut self, obj: JsObject) -> ObjectId
Allocate an object in the arena
Sourcepub fn register_function(&mut self, template: FunctionTemplate) -> FunctionId
pub fn register_function(&mut self, template: FunctionTemplate) -> FunctionId
Register a function template