CompileCtx

Struct CompileCtx 

Source
pub struct CompileCtx {
    pub reg_map: HashMap<usize, u32>,
    pub symbols: HashMap<u64, u32>,
    pub symbol_ptrs: HashMap<u64, usize>,
    pub dictionary: HashMap<u64, String>,
    pub mutable_symbols: HashSet<u64>,
    pub types: TypeSection,
    pub features: HashSet<FeatureFlag>,
    pub const_entries: Vec<ConstEntry>,
    pub const_blob: Vec<u8>,
    pub instrs: Vec<EncodedInstr>,
    pub next_reg: u32,
}

Fields§

§reg_map: HashMap<usize, u32>§symbols: HashMap<u64, u32>§symbol_ptrs: HashMap<u64, usize>§dictionary: HashMap<u64, String>§mutable_symbols: HashSet<u64>§types: TypeSection§features: HashSet<FeatureFlag>§const_entries: Vec<ConstEntry>§const_blob: Vec<u8>§instrs: Vec<EncodedInstr>§next_reg: u32

Implementations§

Source§

impl CompileCtx

Source

pub fn new() -> CompileCtx

Source

pub fn clear(&mut self)

Source

pub fn define_symbol(&mut self, id: usize, reg: u32, name: &str, mutable: bool)

Source

pub fn alloc_register_for_ptr(&mut self, ptr: usize) -> u32

Source

pub fn emit_const_load(&mut self, dst: u32, const_id: u32)

Source

pub fn emit_nullop(&mut self, fxn_id: u64, dst: u32)

Source

pub fn emit_unop(&mut self, fxn_id: u64, dst: u32, src: u32)

Source

pub fn emit_binop(&mut self, fxn_id: u64, dst: u32, lhs: u32, rhs: u32)

Source

pub fn emit_ternop(&mut self, fxn_id: u64, dst: u32, a: u32, b: u32, c: u32)

Source

pub fn emit_quadop( &mut self, fxn_id: u64, dst: u32, a: u32, b: u32, c: u32, d: u32, )

Source

pub fn emit_varop(&mut self, fxn_id: u64, dst: u32, args: Vec<u32>)

Source

pub fn emit_ret(&mut self, src: u32)

Source

pub fn compile_const( &mut self, bytes: &[u8], value_kind: ValueKind, ) -> Result<u32, MechError2>

Source

pub fn compile(&mut self) -> Result<Vec<u8>, MechError2>

Trait Implementations§

Source§

impl Debug for CompileCtx

Source§

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

Formats the value using the given formatter. 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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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.