Skip to main content

Compiler

Struct Compiler 

Source
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>

Source

pub fn reborrow(&mut self) -> Compiler<'_>

The same parts for a shorter borrow (a host callback’s view).

Source

pub fn new_host_function( &mut self, name: &str, length: u32, constructor: bool, data: &[Value], body: Rc<HostFn>, ) -> Result<ObjectId, HeapError>

Source

pub fn new_host_object( &mut self, prototype: Option<ObjectId>, data: Rc<dyn Any>, ) -> Result<ObjectId, HeapError>

Source

pub fn hold(&mut self, value: Value) -> Handle

Holds value for the embedder until released (the heap’s handle table).

Source

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.

Source

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.

Source

pub fn heap(&self) -> &Heap

Source

pub fn heap_mut(&mut self) -> &mut Heap

Source

pub fn units(&self) -> Units<'_>

Every published unit, static and dynamic.

Source

pub fn intrinsic(&self, intrinsic: Intrinsic) -> ObjectId

Source

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.

Source

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.

Source§

impl Compiler<'_>

Source

pub fn template_object( &mut self, cooked: &[Value], raw: &[Value], ) -> Result<ObjectId, HeapError>

A tagged template’s frozen site object.

Trait Implementations§

Source§

impl Drop for Compiler<'_>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for Compiler<'a>

§

impl<'a> !Send for Compiler<'a>

§

impl<'a> !Sync for Compiler<'a>

§

impl<'a> !UnwindSafe for Compiler<'a>

§

impl<'a> Freeze for Compiler<'a>

§

impl<'a> Unpin for Compiler<'a>

§

impl<'a> UnsafeUnpin for Compiler<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.