Skip to main content

ModuleCompiler

Struct ModuleCompiler 

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

Owns the type and operation environments for one collection-wide compilation.

Compilation does not execute user expressions or construct live graphs. See Self::new for an example.

Implementations§

Source§

impl ModuleCompiler

Source

pub fn new(types: TypeRegistry, lookup: OpLookup) -> Self

Takes ownership of the immutable environments without cloning either.

§Examples
use adam_lang::{ModuleCompiler, ModuleSet, TypeRegistry};
let mut modules = ModuleSet::new();
modules.insert_source("example".parse()?, "example.adm2", "sheet reusable() {}")?;
let compiled = ModuleCompiler::new(TypeRegistry::new(), cel_parser::OpLookup::new())
    .compile(modules).map_err(|mut errors| errors.remove(0))?;
assert!(compiled.template(&"example".parse()?, "reusable").is_some());
Source

pub fn compile( self, modules: ModuleSet, ) -> Result<CompiledModules, Vec<ModuleDiagnostic>>

Checks the collection once and materializes every definition in dependency order.

All definitions, including unused definitions and inactive branches, must check. Initializers, defaults, policies, operations and matches remain unexecuted. Whole-graph solvability and live-root construction are not compilation checks.

§Errors

Returns source-owning diagnostics for invalid collections or recipe preparation. No partial compiled collection escapes on failure.

  • Complexity: Borrowed analysis plus expression emission, native recipe validation and O(n) owning syntax/metadata storage in authored nodes, not expanded uses.
§Examples

See Self::new.

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.