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
impl CompiledModules
Sourcepub fn instantiate_root(
&self,
module: &ModulePath,
name: &str,
) -> Result<ParsedSheet, ModuleDiagnostic>
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);Sourcepub fn sources(&self) -> &[SourceId]
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");Sourcepub fn compiler(&self) -> ModuleCompiler
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());Sourcepub fn template(
&self,
module: &ModulePath,
name: &str,
) -> Option<&TypedTemplate>
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.
Sourcepub fn roots<'a>(&'a self, module: &ModulePath) -> impl Iterator<Item = &'a str>
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.
Sourcepub fn prepared_root(
&self,
module: &ModulePath,
name: &str,
) -> Option<&PreparedRoot>
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");