pub struct Tast { /* private fields */ }Expand description
One typed translation unit.
Implementations§
Source§impl Tast
impl Tast
Sourcepub fn top_level(&self) -> &[DeclId] ⓘ
pub fn top_level(&self) -> &[DeclId] ⓘ
The objects and functions of the translation unit, in the order they were declared.
Sourcepub fn add_top_level(&mut self, decl: DeclId)
pub fn add_top_level(&mut self, decl: DeclId)
Adds a declaration at file scope.
Sourcepub fn expr(&mut self, expr: Expr, span: Span) -> ExprId
pub fn expr(&mut self, expr: Expr, span: Span) -> ExprId
Adds an expression, with the source it came from.
§Panics
Panics if the arena would exceed four billion nodes, which is not a translation unit this compiler intends to accept.
Sourcepub fn stmt(&mut self, stmt: Stmt, span: Span) -> StmtId
pub fn stmt(&mut self, stmt: Stmt, span: Span) -> StmtId
Adds a statement, with the source it came from.
§Panics
Panics if the arena would exceed four billion nodes.
Sourcepub fn decl(&mut self, decl: Decl, span: Span) -> DeclId
pub fn decl(&mut self, decl: Decl, span: Span) -> DeclId
Adds a declaration, with the source it came from.
§Panics
Panics if the arena would exceed four billion nodes.
Sourcepub fn set_decl(&mut self, id: DeclId, decl: Decl)
pub fn set_decl(&mut self, id: DeclId, decl: Decl)
Replaces a declaration, which is what a definition of something already declared does.
§Panics
Panics if id is not a declaration of this tree.
Sourcepub fn set_stmt(&mut self, id: StmtId, stmt: Stmt)
pub fn set_stmt(&mut self, id: StmtId, stmt: Stmt)
Replaces a statement, which is what a switch does to the cases in its body.
A case is checked before the table it is an entry of exists, since the table is a run
and the run is not known until the whole body has been walked. So the statement is written
with a placeholder entry and given its real one here.
§Panics
Panics if id is not a statement of this tree.
Sourcepub fn add_vla(&mut self, size: ExprId) -> VlaId
pub fn add_vla(&mut self, size: ExprId) -> VlaId
Records the size of one variable length array, and gives back its identity.
The type table keeps a VlaId and nothing else, because two variable length arrays
written with the same element type are still distinct types and interning them together
would say they are not. The expression itself lives here, since it is evaluated once
where the declaration is reached and its value is what every sizeof of that type
afterwards answers with.
§Panics
Panics if the table would exceed four billion entries.
Sourcepub fn define_label(&mut self, id: LabelId, stmt: StmtId)
pub fn define_label(&mut self, id: LabelId, stmt: StmtId)
Records that a label names a statement, which is not known when the label is created
because a goto may come first.
§Panics
Panics if id is not a label of this tree.
Source§impl Tast
impl Tast
Sourcepub fn add_string(&mut self, item: StringLiteral) -> StrId
pub fn add_string(&mut self, item: StringLiteral) -> StrId
Source§impl Tast
impl Tast
Sourcepub fn add_expr_refs(&mut self, items: &[ExprId]) -> ExprList
pub fn add_expr_refs(&mut self, items: &[ExprId]) -> ExprList
Adds a run of expression references, which is what a call’s arguments are.
§Panics
Panics if the table would exceed four billion entries.
Source§impl Tast
impl Tast
Sourcepub fn add_stmt_refs(&mut self, items: &[StmtId]) -> StmtList
pub fn add_stmt_refs(&mut self, items: &[StmtId]) -> StmtList
Adds a run of statement references, which is what a block is.
§Panics
Panics if the table would exceed four billion entries.
Source§impl Tast
impl Tast
Sourcepub fn add_decl_refs(&mut self, items: &[DeclId]) -> DeclList
pub fn add_decl_refs(&mut self, items: &[DeclId]) -> DeclList
Adds a run of declaration references, which is what a declaration statement is.
§Panics
Panics if the table would exceed four billion entries.