Struct PreCompileProgram

Source
pub struct PreCompileProgram { /* private fields */ }

Implementations§

Source§

impl PreCompileProgram

Source

pub fn merge(&mut self, other: &PreCompileProgram) -> Result<(), Error>

merge the instructions from another program

Source

pub fn set_export(&mut self, label: impl StringLike) -> Result<(), Error>

Set an entry to be exported

Source

pub fn delete_ent(&mut self, label: impl StringLike) -> Result<(), Error>

Source

pub fn define_jmp( &mut self, label: impl StringLike, cont: impl StringLike, per: impl AsPermutation, ) -> Result<EntryRef, Error>

Define a jmp instruction

A jmp instruction performs a specific permutation on its values. Then it will jump to another entry.

label: the name of the entry cont: the entry this instruction will jump to per: how to permutate the values

Source

pub fn define_call( &mut self, label: impl StringLike, callee: impl StringLike, callcnt: u8, callcont: impl StringLike, ) -> Result<EntryRef, Error>

Define a call instruction

A Call instruction will seperate the current context into two. One of them will be put in a closure and add to the other as a single value. Then it will jump to another entry.

label: the name of this entry callee: the entry this entry will jump to callcnt: how many values the current context will keep callcont: an entry to keep the rest of context

Source

pub fn define_ret( &mut self, label: impl StringLike, variant: u8, ) -> Result<EntryRef, Error>

Define a return instruction

The first value of the context will be picked up and treat as a closure. Its captured context released and merged into the current context. Then the closure’s group entry reference will contain some variants. The specified variant will be used as the return target.

variant: which element of the group should be refer to

Source

pub fn define_group( &mut self, label: impl StringLike, elements: &[impl StringLike], ) -> Result<EntryRef, Error>

Define a group of instructions

A group of entries contains zero of more variants. When called with a specific variants, it will be picked up and being used as the execution target.

label: the name of this group entry elements: the variant entries

Source

pub fn externs(&self) -> Vec<(String, EntryRef)>

Returns all defined external entries, including the name

Source

pub fn compile( &self, externs: impl Iterator<Item = ExternEntry>, ) -> Result<Program, Error>

Compile this program with a set of external functions

Trait Implementations§

Source§

impl<'a> Access<'a, PreCompileProgram> for EntryRef

Source§

type Target = Result<&'a Entry, Error>

Source§

fn access<'b>(&self, src: &'b PreCompileProgram) -> Self::Target
where 'b: 'a,

Source§

impl<'a> AccessMut<'a, PreCompileProgram> for EntryRef

Source§

type Target = Result<&'a mut Entry, Error>

Source§

fn access_mut<'b>(&self, src: &'b mut PreCompileProgram) -> Self::Target
where 'b: 'a,

Source§

impl Debug for PreCompileProgram

Source§

fn fmt(&self, fmt: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for PreCompileProgram

Source§

fn default() -> PreCompileProgram

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for PreCompileProgram

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for PreCompileProgram

Source§

fn fmt(&self, fmt: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Serialize for PreCompileProgram

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

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> AnyDebugDisplay for T
where T: Any + Debug + Display,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Obtain a trait object for Any
Source§

fn as_debug(&self) -> &dyn Debug

Obtain a trait object for Debug
Source§

fn as_display(&self) -> &dyn Display

Obtain a trait object for Display
Source§

fn into_boxed_any(self: Box<T>) -> Box<dyn Any>

Turn a concret box into a box of Any
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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,