Skip to main content

ModuleSet

Struct ModuleSet 

Source
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

Source

pub fn new() -> Self

Creates an empty supplied module collection.

§Examples

See the module example.

Source

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.

Source

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)?;
Source

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.

Trait Implementations§

Source§

impl Default for ModuleSet

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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.