pub struct ModuleSet { /* private fields */ }Expand description
Owns parsed and native declarations under explicit module paths.
A module has at most one source file and may also contain native definitions.
Insertion parses syntax only. Self::check_resolution checks names and cycles,
not types, actual cells, executable bodies or graph solvability.
check_module adds borrowed, nonexecuting signature and body analysis.
See the module example.
Implementations§
Source§impl ModuleSet
impl ModuleSet
Sourcepub fn insert_source(
&mut self,
path: ModulePath,
file_name: &str,
source: &str,
) -> Result<(), ModuleDiagnostic>
pub fn insert_source( &mut self, path: ModulePath, file_name: &str, source: &str, ) -> Result<(), ModuleDiagnostic>
Parses one source file and adds its declarations without executing expressions.
A rejected insertion leaves existing declarations unchanged.
§Errors
Rejects malformed syntax or a second source file for the same module. Diagnostics own their source even after this collection is dropped. The collection does not retain rejected malformed source revisions.
- Complexity: O(n) source and AST size, excluding embedded CEL parsing.
§Examples
See the module example.
Sourcepub fn insert_template(
&mut self,
path: ModulePath,
name: &str,
template: TypedTemplate,
) -> Result<(), ModuleDiagnostic>
pub fn insert_template( &mut self, path: ModulePath, name: &str, template: TypedTemplate, ) -> Result<(), ModuleDiagnostic>
Adds an immutable source-free definition to a supplied module.
Native and parsed definitions share the module’s export namespace.
§Errors
Rejects invalid identifiers or an already declared local definition. Duplicate errors retain the incoming and earlier declaration labels.
- Complexity: O(d + b) existing local definitions and compared/copied name/label bytes.
§Examples
let mut modules = adam_lang::ModuleSet::new();
let native = adam_lang::CompositionBuilder::new(adam_lang::TypeRegistry::new()).finish()?;
modules.insert_template("native".parse()?, "empty", native)?;Sourcepub fn check_resolution(&self) -> Result<(), Vec<ModuleDiagnostic>>
pub fn check_resolution(&self) -> Result<(), Vec<ModuleDiagnostic>>
Checks definition names, explicit imports and actual component-use cycles.
Resolves imported bodies in their defining module. Aliases do not re-export. Checks every authored use, including unused definitions and conditional branches. Import-only cycles are valid. No expression executes. This phase does not check types, actual-cell bindings, executable bodies, branch eligibility or whole-graph validity.
§Errors
Reports duplicate names, missing modules/exports, uses of roots and actual-use cycles. Returned labels retain sources independently of this collection.
- Complexity: O(n + p) time for file/body/branch declarations n and qualified-name bytes p; O(d + i + u + p) additional space for definitions, imports, uses and names.
§Examples
See the module example.