pub struct Compiler<'a> { /* private fields */ }Expand description
The runtime’s parts a compilation uses. Dropping it ends the
compilation: its pinned units and held atoms are released (a
Compiler::reborrow ends nothing).
Implementations§
Source§impl<'a> Compiler<'a>
impl<'a> Compiler<'a>
Sourcepub fn reborrow(&mut self) -> Compiler<'_>
pub fn reborrow(&mut self) -> Compiler<'_>
The same parts for a shorter borrow (a host callback’s view).
Sourcepub fn new_host_function(
&mut self,
name: &str,
length: u32,
constructor: bool,
data: &[Value],
body: Rc<HostFn>,
) -> Result<ObjectId, HeapError>
pub fn new_host_function( &mut self, name: &str, length: u32, constructor: bool, data: &[Value], body: Rc<HostFn>, ) -> Result<ObjectId, HeapError>
Sourcepub fn new_host_object(
&mut self,
prototype: Option<ObjectId>,
data: Rc<dyn Any>,
) -> Result<ObjectId, HeapError>
pub fn new_host_object( &mut self, prototype: Option<ObjectId>, data: Rc<dyn Any>, ) -> Result<ObjectId, HeapError>
Sourcepub fn hold(&mut self, value: Value) -> Handle
pub fn hold(&mut self, value: Value) -> Handle
Holds value for the embedder until released (the heap’s handle
table).
Sourcepub fn new_error(
&mut self,
kind: ErrorKind,
message: &str,
) -> Result<Value, HeapError>
pub fn new_error( &mut self, kind: ErrorKind, message: &str, ) -> Result<Value, HeapError>
A new error object of kind with message and an empty stack: an
error a host callback raises, with no JavaScript frame, as QuickJS’s.
Sourcepub fn new_located_error(
&mut self,
kind: ErrorKind,
message: &str,
file: &str,
line: u32,
column: u32,
) -> Result<Value, HeapError>
pub fn new_located_error( &mut self, kind: ErrorKind, message: &str, file: &str, line: u32, column: u32, ) -> Result<Value, HeapError>
Compiler::new_error located at file:line:column (a module’s
compile error): fileName, lineNumber, columnNumber, and a
stack of the location alone.
pub fn heap(&self) -> &Heap
pub fn heap_mut(&mut self) -> &mut Heap
pub fn intrinsic(&self, intrinsic: Intrinsic) -> ObjectId
Sourcepub fn publish(&mut self, unit: CodeUnit) -> Result<CodeUnitId, ValidateError>
pub fn publish(&mut self, unit: CodeUnit) -> Result<CodeUnitId, ValidateError>
Validates unit, reserves its cache entries and publishes it: into
the code store before the program runs (its key atoms pinned), into
the heap (pinned until the compilation ends, its bytes charged to the
collection trigger) while it runs. Its children must be published
first.
Sourcepub fn instantiate(
&mut self,
root: CodeUnitId,
constants: &[&[Value]],
) -> Result<ObjectId, HeapError>
pub fn instantiate( &mut self, root: CodeUnitId, constants: &[&[Value]], ) -> Result<ObjectId, HeapError>
A function object for the published unit root, with a bytecode
record for it and every unit below it. constants holds one table per
unit, in the pre-order of Units::tree.