Skip to main content

Module composition

Module composition 

Source
Expand description

Builds complete-shape templates without parsing source text.

Emitters return fresh segments; they never execute expressions during definition checking. Each live factory creates fresh mutable execution frames. Immutable definitions and intentionally shared host inputs may be captured by emitters.

use adam_lang::{CompositionBuilder, ParsedSheet, TypeRegistry};
use adam_lang::type_registry::TypeShape;
use std::any::TypeId;
let types = TypeRegistry::new();
let shape = TypeShape::Named(TypeId::of::<i32>());
let mut builder = CompositionBuilder::new(types.clone());
builder.parameter("x", shape.clone())?;
let template = builder.finish()?;
let mut destination = ParsedSheet::new();
let x = destination.add_cell(3i32);
destination.register_cell("x", x, shape, &types)?;
template.instantiate(&mut destination, &[("x", x)])?;

Structs§

AuthoredItem
Retains one authored node and its native slots without expanding included definitions.
CellOrigin
Maps one local declaration or bound formal to its live occurrence.
CellSlot
Retains a native local handle and its complete declared shape.
CompositionBuilder
Builds shape-checked recipes by delegating every graph operation to Adam.
InstanceOrigin
Retains one direct invocation’s flat occurrence records after template drop.
MethodRecipe
Owns a repeatable native method with full input and output shapes.
OccurrenceOrigin
Retains one occurrence using parent links, never copied full invocation paths.
TypedTemplate
Owns a reusable native definition, complete formal/local shapes and source metadata.

Enums§

AuthoredRole
Classifies a local authored record without guessing from label text or output count.