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
impl ModuleCompiler
Sourcepub fn new(types: TypeRegistry, lookup: OpLookup) -> Self
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());Sourcepub fn compile(
self,
modules: ModuleSet,
) -> Result<CompiledModules, Vec<ModuleDiagnostic>>
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§
impl !RefUnwindSafe for ModuleCompiler
impl !Send for ModuleCompiler
impl !Sync for ModuleCompiler
impl !UnwindSafe for ModuleCompiler
impl Freeze for ModuleCompiler
impl Unpin for ModuleCompiler
impl UnsafeUnpin for ModuleCompiler
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more