pub struct AstArena { /* private fields */ }Expand description
Arena for storing AST nodes with deduplication
Implementations§
Source§impl AstArena
impl AstArena
pub fn new() -> Self
pub fn with_capacity(node_cap: usize) -> Self
Sourcepub fn insert(&mut self, node: AstNodeData) -> AstNodeId
pub fn insert(&mut self, node: AstNodeData) -> AstNodeId
Insert a node, deduplicating if it already exists
Sourcepub fn insert_literal(&mut self, value: ValueRef) -> AstNodeId
pub fn insert_literal(&mut self, value: ValueRef) -> AstNodeId
Insert a literal node
Sourcepub fn insert_reference(
&mut self,
original: &str,
ref_type: CompactRefType,
) -> AstNodeId
pub fn insert_reference( &mut self, original: &str, ref_type: CompactRefType, ) -> AstNodeId
Insert a reference node
Sourcepub fn insert_unary_op(&mut self, op: &str, expr: AstNodeId) -> AstNodeId
pub fn insert_unary_op(&mut self, op: &str, expr: AstNodeId) -> AstNodeId
Insert a unary operation node
Sourcepub fn insert_binary_op(
&mut self,
op: &str,
left: AstNodeId,
right: AstNodeId,
) -> AstNodeId
pub fn insert_binary_op( &mut self, op: &str, left: AstNodeId, right: AstNodeId, ) -> AstNodeId
Insert a binary operation node
Sourcepub fn insert_function(&mut self, name: &str, args: Vec<AstNodeId>) -> AstNodeId
pub fn insert_function(&mut self, name: &str, args: Vec<AstNodeId>) -> AstNodeId
Insert a function call node
Sourcepub fn insert_array(
&mut self,
rows: u16,
cols: u16,
elements: Vec<AstNodeId>,
) -> AstNodeId
pub fn insert_array( &mut self, rows: u16, cols: u16, elements: Vec<AstNodeId>, ) -> AstNodeId
Insert an array literal node
Sourcepub fn get(&self, id: AstNodeId) -> Option<&AstNodeData>
pub fn get(&self, id: AstNodeId) -> Option<&AstNodeData>
Get a node by ID
Sourcepub fn get_function_args(&self, id: AstNodeId) -> Option<&[AstNodeId]>
pub fn get_function_args(&self, id: AstNodeId) -> Option<&[AstNodeId]>
Get function arguments for a function node
Sourcepub fn get_array_elements(&self, id: AstNodeId) -> Option<&[AstNodeId]>
pub fn get_array_elements(&self, id: AstNodeId) -> Option<&[AstNodeId]>
Get array elements for an array node
Sourcepub fn resolve_string(&self, id: StringId) -> &str
pub fn resolve_string(&self, id: StringId) -> &str
Resolve a string ID to its content
Sourcepub fn strings(&self) -> &StringInterner
pub fn strings(&self) -> &StringInterner
Get the string interner (for external use)
Sourcepub fn strings_mut(&mut self) -> &mut StringInterner
pub fn strings_mut(&mut self) -> &mut StringInterner
Get mutable access to the string interner
Sourcepub fn stats(&self) -> AstArenaStats
pub fn stats(&self) -> AstArenaStats
Get statistics about the arena
Sourcepub fn memory_usage(&self) -> usize
pub fn memory_usage(&self) -> usize
Returns memory usage in bytes (approximate)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for AstArena
impl RefUnwindSafe for AstArena
impl Send for AstArena
impl Sync for AstArena
impl Unpin for AstArena
impl UnwindSafe for AstArena
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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