pub struct Ast { /* private fields */ }
Expand description
A Koto program represented as an Abstract Syntax Tree
This is produced by the parser, and consumed by the compiler.
Implementations§
Source§impl Ast
impl Ast
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Initializes an Ast with the given capacity
Sourcepub fn push(&mut self, node: Node, span: Span) -> Result<AstIndex>
pub fn push(&mut self, node: Node, span: Span) -> Result<AstIndex>
Pushes a node and corresponding span onto the tree
Sourcepub fn constants(&self) -> &ConstantPool
pub fn constants(&self) -> &ConstantPool
Returns the constant pool referred to by the AST
Sourcepub fn consume_constants(self) -> ConstantPool
pub fn consume_constants(self) -> ConstantPool
Moves the constants out of the AST
This is used when building a Chunk
after compilation.
The constants get transferred to the Chunk
once the AST has been converted into bytecode.
Sourcepub fn entry_point(&self) -> Option<AstIndex>
pub fn entry_point(&self) -> Option<AstIndex>
Returns the root node in the tree
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Ast
impl RefUnwindSafe for Ast
impl !Send for Ast
impl !Sync for Ast
impl Unpin for Ast
impl UnwindSafe for Ast
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