Skip to main content

ModuleData

Struct ModuleData 

Source
pub struct ModuleData { /* private fields */ }
Expand description

A loaded module: an immutable table of unevaluated item bodies (“dehydrated code”), sorted by name. Built once by crate::compile_module and then frozen behind an Rc. Sibling references inside the bodies are compiled to Expr::ModItem — a sink resolved through the home module carried in the environment (EnvNode::Module), not through any registry — so a ModuleData owns nothing but Exprs and never points back at a value, and the value heap stays acyclic. See docs/done/2026-08-07_elly-modules-v0.md.

A sibling reference reaches its body by index (a direct slice index, the hot path); an outside M.name access, which has only a name, binary-searches.

Implementations§

Source§

impl ModuleData

Source

pub fn item_names(&self) -> Vec<&Text>

The module’s item names, in sorted order — its public listing, and the only names an outside M.name access can reach.

Source

pub fn local_names(&self) -> Vec<&Text>

The names the module declares with local, in sorted order. A local appears here and nowhere else — it is not an item, so it is not reachable as M.name from outside — which is the same shape a private iota has, and it is offered for the same reason: a host’s introspection (a debugger, a const stage) wants to see what a module declares, while the language gives no way to reach it.

Source

pub fn iota_names(&self) -> &[Text]

The names the module declares with const, in sorted order. A private iota appears here and nowhere else — it is not an item, so it is not reachable as M.name from outside.

Source

pub fn frame_names(&self) -> &[Text]

The names of the module’s frame slots, in slot order — what it must be instantiated against (see instantiate). Empty for a module with no frame.

Source

pub fn imports(&self) -> &[ImportSpec]

The specs of the module’s imports, in slot order: imports()[i] is what frame_names()[i] was imported from. The list is a static, auditable account of every module this one can reach, readable without running anything — which is the point of writing an import rather than calling a loader.

Source

pub fn body(&self) -> Option<&Expr>

The module’s body, if it has one: a recur group’s body, or the __main a source declared. A runner reads it here and evaluates it in the instance’s own environment (see crate::eval_main); everything else leaves it alone, which is what makes an imported __main inert.

Source

pub fn name(&self) -> Option<&ModuleName>

The canonical name the module’s code came from, when a host named it — what __Mod.name reports and what the const stage deduplicates instances by. None for code no host named.

Trait Implementations§

Source§

impl Debug for ModuleData

Source§

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

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

impl Eq for ModuleData

Source§

impl PartialEq for ModuleData

Source§

fn eq(&self, other: &ModuleData) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for ModuleData

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.