Skip to main content

CompiledModules

Struct CompiledModules 

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

Owns resolved immutable exports and explicitly selectable prepared roots.

Imported aliases do not become exports. Factories and diagnostics retain their actual source owners independently of this collection. See ModuleCompiler::new for an example.

Implementations§

Source§

impl CompiledModules

Source

pub fn instantiate_root( &self, module: &ModulePath, name: &str, ) -> Result<ParsedSheet, ModuleDiagnostic>

Constructs one explicitly selected root without propagation.

Only authored root declarations enter the ordered public maps. Included private cells retain shapes and provenance but never become public names. The complete combined sheet passes native guard-independence validation.

§Errors

Returns an owning diagnostic for an unknown selection, construction failure, or invalid combined graph. No partial live sheet escapes on failure.

  • Complexity: Native instantiation and validation plus O(c + a + s) root declarations, authored records and retained source identities.
§Examples
let mut modules = adam_lang::ModuleSet::new();
let path = "app".parse()?;
modules.insert_source(path, "app.adm2", "sheet app { cell x: i32 = 7; }")?;
let compiled = adam_lang::ModuleCompiler::new(adam_lang::TypeRegistry::new(),
    cel_parser::OpLookup::new()).compile(modules).map_err(|mut e| e.remove(0))?;
let parsed = compiled.instantiate_root(&"app".parse()?, "app")?;
assert_eq!(*parsed.read::<i32>(parsed.cell_names["x"].0).unwrap(), 7);
Source

pub fn sources(&self) -> &[SourceId]

Borrows source identities from supplied files and imported immutable templates.

Includes empty source modules. Independent sources keep their ownership identity even when file names, text or original collection indices coincide.

§Examples
let mut modules = adam_lang::ModuleSet::new();
modules.insert_source("empty".parse()?, "empty.adm2", "")?;
let compiled = adam_lang::ModuleCompiler::new(adam_lang::TypeRegistry::new(),
    cel_parser::OpLookup::new()).compile(modules).map_err(|mut e| e.remove(0))?;
assert_eq!(compiled.sources()[0].file_name(), "empty.adm2");
Source

pub fn compiler(&self) -> ModuleCompiler

Creates a compiler sharing only this collection’s immutable environments.

New compilations retain independent module collections and construction frames.

§Examples
let compiled = adam_lang::ModuleCompiler::new(adam_lang::TypeRegistry::new(),
    cel_parser::OpLookup::new()).compile(adam_lang::ModuleSet::new())
    .map_err(|mut errors| errors.remove(0))?;
let other = compiled.compiler().compile(adam_lang::ModuleSet::new());
assert!(other.is_ok());
Source

pub fn template( &self, module: &ModulePath, name: &str, ) -> Option<&TypedTemplate>

Borrows a declared reusable export, excluding roots and imported aliases.

  • Complexity: Expected O(p + n) module-path and definition-name bytes.
§Examples

See ModuleCompiler::new.

Source

pub fn roots<'a>(&'a self, module: &ModulePath) -> impl Iterator<Item = &'a str>

Enumerates explicitly selectable root names in authored order.

An unknown module has no roots; no arbitrary root is selected.

  • Complexity: O(r) traversal for r roots.
§Examples

See Self::prepared_root.

Source

pub fn prepared_root( &self, module: &ModulePath, name: &str, ) -> Option<&PreparedRoot>

Borrows one explicit root’s lowered recipe metadata without instantiating it.

  • Complexity: O(r + p + n) root/name comparisons and module-path bytes.
§Examples
let mut modules = adam_lang::ModuleSet::new();
let path = "app".parse()?;
modules.insert_source(path, "app.adm2", "sheet first { cell x: i32; } sheet second {}")?;
let compiled = adam_lang::ModuleCompiler::new(adam_lang::TypeRegistry::new(),
    cel_parser::OpLookup::new()).compile(modules).map_err(|mut e| e.remove(0))?;
let path = "app".parse()?;
assert_eq!(compiled.roots(&path).collect::<Vec<_>>(), ["first", "second"]);
assert_eq!(compiled.prepared_root(&path, "first").unwrap().cells()[0].name, "x");

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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.