Skip to main content

ASTRegistry

Struct ASTRegistry 

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

Complete AST storage for symbols

Stores the full PureItem AST for each symbol, enabling:

  • Direct AST mutation without file I/O
  • Complete AST reconstruction at dump time
  • Simplified mutation logic (no type-specific storage)

§SSOT Design

  • All items stored in unified items map via SymbolId
  • Module content stored in PureMod.items (Use statements, Impl blocks, etc.)
  • Module children tracked in module_children for O(1) access
  • Binary entries: individual symbols registered in items (no separate storage)
  • Inline modules tracked separately in inline_modules for generation

Implementations§

Source§

impl ASTRegistry

Source

pub fn new() -> Self

Create a new empty registry

Source

pub fn get(&self, id: SymbolId) -> Option<&PureItem>

Get AST for a symbol (immutable)

Source

pub fn get_mut(&mut self, id: SymbolId) -> Option<&mut PureItem>

Get AST for a symbol (mutable)

Source

pub fn set(&mut self, id: SymbolId, item: PureItem)

Set AST for a symbol

Overwrites existing AST if present.

Source

pub fn remove(&mut self, id: SymbolId) -> Option<PureItem>

Remove AST for a symbol

Returns the removed AST if it existed.

Source

pub fn contains(&self, id: SymbolId) -> bool

Check if symbol has AST

Source

pub fn len(&self) -> usize

Get number of stored ASTs

Source

pub fn is_empty(&self) -> bool

Check if registry is empty

Source

pub fn iter(&self) -> impl Iterator<Item = (SymbolId, &PureItem)>

Iterate all (SymbolId, &PureItem) pairs

Source

pub fn iter_mut(&mut self) -> impl Iterator<Item = (SymbolId, &mut PureItem)>

Iterate all (SymbolId, &mut PureItem) pairs

Source

pub fn clear(&mut self)

Clear all stored ASTs

Source

pub fn mark_inline_module(&mut self, id: SymbolId)

Mark a module as inline (defined with mod name { ... } syntax)

Inline modules stay in their parent file during generation, while external modules get their own files.

Source

pub fn is_inline_module(&self, id: SymbolId) -> bool

Check if a module is inline

Source

pub fn inline_module_ids(&self) -> impl Iterator<Item = SymbolId> + '_

Get all inline module IDs

Source

pub fn get_module_children(&self, module_id: SymbolId) -> Option<&Vec<SymbolId>>

Get child symbol IDs for a module

Source

pub fn get_module_children_mut( &mut self, module_id: SymbolId, ) -> Option<&mut Vec<SymbolId>>

Get child symbol IDs for a module (mutable)

Source

pub fn set_module_children( &mut self, module_id: SymbolId, children: Vec<SymbolId>, )

Set child symbol IDs for a module

Source

pub fn add_child_to_module(&mut self, module_id: SymbolId, child_id: SymbolId)

Add a child to a module

§Panics

Panics if module_id is not a valid SymbolId in the underlying SlotMap. Callers are responsible for supplying a registered SymbolId.

Source

pub fn remove_child_from_module( &mut self, module_id: SymbolId, child_id: SymbolId, )

Remove a child from a module

Source

pub fn has_module_children(&self, module_id: SymbolId) -> bool

Check if module has children tracked

Source

pub fn iter_module_children( &self, ) -> impl Iterator<Item = (SymbolId, &Vec<SymbolId>)>

Iterate all (ModuleSymbolId, &Vec<SymbolId>) pairs

Source

pub fn get_module_items(&self, module_id: SymbolId) -> Option<&Vec<PureItem>>

Get all items for a module (including use statements, impl blocks)

Source

pub fn get_module_items_mut( &mut self, module_id: SymbolId, ) -> Option<&mut Vec<PureItem>>

Get all items for a module (mutable)

Source

pub fn set_module_items(&mut self, module_id: SymbolId, items: Vec<PureItem>)

Set all items for a module.

If the module doesn’t exist in the AST registry yet, creates a new empty PureMod entry and sets its items. If items is empty and the module doesn’t exist, no entry is created (mod declarations are generated from module hierarchy, not stored in ASTRegistry).

Source

pub fn has_module_items(&self, module_id: SymbolId) -> bool

Check if module has items stored

Source

pub fn iter_module_items( &self, ) -> impl Iterator<Item = (SymbolId, &Vec<PureItem>)>

Iterate all (ModuleSymbolId, &Vec<PureItem>) pairs

Source

pub fn iter_module_items_mut( &mut self, ) -> impl Iterator<Item = (SymbolId, &mut Vec<PureItem>)>

Iterate all (ModuleSymbolId, &mut Vec<PureItem>) pairs

Source

pub fn build_from_files( files: &HashMap<WorkspaceFilePath, Arc<PureFile>>, registry: &SymbolRegistry, _crate_name: &str, ) -> Self

Build ASTRegistry from parsed files.

Iterates over all files and stores PureItem for each symbol found in SymbolRegistry. This establishes the initial AST state before mutations.

§Arguments
  • files - Parsed files keyed by workspace path
  • registry - Symbol registry with pre-registered symbols
  • crate_name - Crate name for path resolution

Trait Implementations§

Source§

impl Clone for ASTRegistry

Source§

fn clone(&self) -> ASTRegistry

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ASTRegistry

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ASTRegistry

Source§

fn default() -> ASTRegistry

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.