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: u32Next 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: DataSegmentTrackerCloneData 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: u32Base function index for lambda functions in the WASM table.
Implementations§
Source§impl FuncContext
impl FuncContext
Sourcepub fn alloc_local(&mut self, ty: ValType) -> u32
pub fn alloc_local(&mut self, ty: ValType) -> u32
Allocate a new local of the given type. Returns the local index.
Sourcepub fn push_local(&mut self, name: &str, idx: u32)
pub fn push_local(&mut self, name: &str, idx: u32)
Push a named local binding (for let and for scopes).
Sourcepub fn is_state_field(&self, name: &str) -> bool
pub fn is_state_field(&self, name: &str) -> bool
Check if a name is a state field.
Sourcepub fn get_action_id(&self, name: &str) -> Option<usize>
pub fn get_action_id(&self, name: &str) -> Option<usize>
Get the action_id for a name.
Sourcepub fn get_function(&self, name: &str) -> Option<u32>
pub fn get_function(&self, name: &str) -> Option<u32>
Get verbose function index by name.
Sourcepub fn get_variant_id(&self, name: &str) -> u32
pub fn get_variant_id(&self, name: &str) -> u32
Get variant id by name.
Sourcepub fn intern_string(&mut self, s: &str) -> (u32, u32)
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.
Sourcepub fn register_lambda(
&mut self,
params: Vec<Param>,
body: Block,
captured: Vec<String>,
) -> u32
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.
Sourcepub fn resolve_qualified_call(&self, module: &str, function: &str) -> (u32, u32)
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.
Sourcepub fn resolve_method_call(&self, method: &str) -> (u32, u32)
pub fn resolve_method_call(&self, method: &str) -> (u32, u32)
Resolve a method call to (module_id, function_id).