Skip to main content

FuncContext

Struct FuncContext 

Source
pub struct FuncContext {
    pub locals: Vec<(u32, ValType)>,
    pub local_names: HashMap<String, Vec<u32>>,
    pub next_local: u32,
    pub state_field_names: Vec<String>,
    pub action_names: Vec<String>,
    pub variant_ids: HashMap<String, u32>,
    pub function_table: HashMap<String, u32>,
    pub data: DataSegmentTrackerClone,
    pub user_data: Vec<u8>,
    pub string_cache: HashMap<String, (u32, u32)>,
    pub lambda_bodies: Vec<LambdaBody>,
    pub lambda_base_idx: u32,
}
Expand description

State maintained while generating code for a single function body.

Fields§

§locals: Vec<(u32, ValType)>

Additional locals declared during codegen: (count, type).

§local_names: HashMap<String, Vec<u32>>

Name → local index stack (for scoped let bindings).

§next_local: u32

Next available local index.

§state_field_names: Vec<String>

State field names for identifier resolution.

§action_names: Vec<String>

Action names for action-ref resolution.

§variant_ids: HashMap<String, u32>

Variant name → id.

§function_table: HashMap<String, u32>

Known functions.

§data: DataSegmentTrackerClone

Data segment tracker (for interning strings).

§user_data: Vec<u8>

User string data accumulated during codegen.

§string_cache: HashMap<String, (u32, u32)>

String deduplication cache: content → (offset, length).

§lambda_bodies: Vec<LambdaBody>

Lambda bodies collected during codegen (deferred compilation).

§lambda_base_idx: u32

Base function index for lambda functions in the WASM table.

Implementations§

Source§

impl FuncContext

Source

pub fn alloc_local(&mut self, ty: ValType) -> u32

Allocate a new local of the given type. Returns the local index.

Source

pub fn push_local(&mut self, name: &str, idx: u32)

Push a named local binding (for let and for scopes).

Source

pub fn pop_local(&mut self, name: &str)

Pop a named local binding.

Source

pub fn get_local(&self, name: &str) -> Option<u32>

Get the local index for a named binding.

Source

pub fn is_state_field(&self, name: &str) -> bool

Check if a name is a state field.

Source

pub fn get_action_id(&self, name: &str) -> Option<usize>

Get the action_id for a name.

Source

pub fn get_function(&self, name: &str) -> Option<u32>

Get verbose function index by name.

Source

pub fn get_variant_id(&self, name: &str) -> u32

Get variant id by name.

Source

pub fn intern_string(&mut self, s: &str) -> (u32, u32)

Intern a string constant, returning (offset, length). Deduplicates: if the same string was already interned, reuses it.

Source

pub fn register_lambda( &mut self, params: Vec<Param>, body: Block, captured: Vec<String>, ) -> u32

Register a lambda body for deferred compilation. Returns the WASM function index for this lambda.

Source

pub fn resolve_qualified_call(&self, module: &str, function: &str) -> (u32, u32)

Resolve a qualified call to (module_id, function_id).

For capability modules this returns the capability/function IDs. For pure stdlib modules, we use synthetic IDs starting at 100.

Source

pub fn resolve_method_call(&self, method: &str) -> (u32, u32)

Resolve a method call to (module_id, function_id).

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, 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.