pub struct ModuleBindingRegistry { /* private fields */ }Expand description
Single source of truth for all module binding values.
Used by:
- Interpreter: name-based lookup
- VM: index-based lookup (after compilation resolves names)
- JIT: stable pointers for inlined access
Implementations§
Source§impl ModuleBindingRegistry
impl ModuleBindingRegistry
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Create with pre-allocated capacity
Sourcepub fn register(
&mut self,
name: &str,
value: ValueWord,
is_const: bool,
) -> Result<u32>
pub fn register( &mut self, name: &str, value: ValueWord, is_const: bool, ) -> Result<u32>
Register or update a module binding, returns its stable index.
If the module binding already exists:
- If it’s const and we’re re-registering with same constness, update value
- If it’s const and we’re trying to make it mutable, error
- If it’s mutable, always update
§Arguments
name- The module binding’s namevalue- The value to store (converted to ValueWord internally)is_const- Whether this module binding is constant (functions, imports)
§Returns
The stable index for this module binding
Sourcepub fn register_nb(
&mut self,
name: &str,
value: ValueWord,
is_const: bool,
) -> Result<u32>
pub fn register_nb( &mut self, name: &str, value: ValueWord, is_const: bool, ) -> Result<u32>
Register or update a module binding with a ValueWord value, returns its stable index.
Sourcepub fn register_const(&mut self, name: &str, value: ValueWord) -> Result<u32>
pub fn register_const(&mut self, name: &str, value: ValueWord) -> Result<u32>
Register a constant module binding (convenience method)
Sourcepub fn register_mut(&mut self, name: &str, value: ValueWord) -> Result<u32>
pub fn register_mut(&mut self, name: &str, value: ValueWord) -> Result<u32>
Register a mutable module binding (convenience method)
Sourcepub fn get_by_name(&self, name: &str) -> Option<ValueWord>
pub fn get_by_name(&self, name: &str) -> Option<ValueWord>
Get by name as owned ValueWord (interpreter, dynamic lookup)
Sourcepub fn get_by_index(&self, idx: u32) -> Option<&ValueWord>
pub fn get_by_index(&self, idx: u32) -> Option<&ValueWord>
Get by index as ValueWord reference (O(1))
Sourcepub fn set_by_index(&mut self, idx: u32, value: ValueWord) -> Result<()>
pub fn set_by_index(&mut self, idx: u32, value: ValueWord) -> Result<()>
Set by index from ValueWord (for VM assignment)
Sourcepub fn is_const_by_index(&self, idx: u32) -> Option<bool>
pub fn is_const_by_index(&self, idx: u32) -> Option<bool>
Check if a module binding at index is const
Sourcepub fn names(&self) -> impl Iterator<Item = &str>
pub fn names(&self) -> impl Iterator<Item = &str>
Get all module binding names (for debugging/introspection)
Sourcepub fn get_ptr(&self, idx: u32) -> Option<*const ValueWord>
pub fn get_ptr(&self, idx: u32) -> Option<*const ValueWord>
Get stable pointer for JIT (address won’t change after registration)
§Safety
The pointer is valid as long as no new module bindings are registered. For JIT, call this after all module bindings are registered.
Sourcepub fn snapshot_constants(&self) -> Vec<(u32, ValueWord)>
pub fn snapshot_constants(&self) -> Vec<(u32, ValueWord)>
Snapshot constant module bindings for JIT constant folding
Trait Implementations§
Source§impl Debug for ModuleBindingRegistry
impl Debug for ModuleBindingRegistry
Auto Trait Implementations§
impl Freeze for ModuleBindingRegistry
impl RefUnwindSafe for ModuleBindingRegistry
impl Send for ModuleBindingRegistry
impl Sync for ModuleBindingRegistry
impl Unpin for ModuleBindingRegistry
impl UnsafeUnpin for ModuleBindingRegistry
impl UnwindSafe for ModuleBindingRegistry
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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