Skip to main content

Tast

Struct Tast 

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

One typed translation unit.

Implementations§

Source§

impl Tast

Source

pub fn new() -> Tast

An empty tree.

Source

pub fn top_level(&self) -> &[DeclId]

The objects and functions of the translation unit, in the order they were declared.

Source

pub fn add_top_level(&mut self, decl: DeclId)

Adds a declaration at file scope.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn expr_span(&self, id: ExprId) -> Span

The source an expression came from.

Source

pub fn stmt_span(&self, id: StmtId) -> Span

The source a statement came from.

Source

pub fn decl_span(&self, id: DeclId) -> Span

The source a declaration came from.

Source

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.

Source

pub fn vla_size(&self, id: VlaId) -> ExprId

The size expression of one variable length array.

§Panics

Panics if id is not one of this tree’s.

Source

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

pub fn counts(&self) -> Counts

How many expressions, statements and declarations the tree holds.

Source

pub fn is_empty(&self) -> bool

Whether nothing has been checked into this tree.

Source§

impl Tast

Source

pub fn add_const(&mut self, item: Const) -> ConstId

Adds a folded constant.

§Panics

Panics if the table would exceed four billion entries.

Source§

impl Tast

Source

pub fn add_string(&mut self, item: StringLiteral) -> StrId

Adds a string literal.

§Panics

Panics if the table would exceed four billion entries.

Source§

impl Tast

Source

pub fn add_label(&mut self, item: Label) -> LabelId

Adds a label, which is not defined until the statement it names has been seen.

§Panics

Panics if the table would exceed four billion entries.

Source§

impl Tast

Source

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

Source

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

Source

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.

Source§

impl Tast

Source

pub fn add_cases(&mut self, items: &[Case]) -> CaseList

Adds the cases of one switch, in the order a jump table wants them.

§Panics

Panics if the table would exceed four billion entries.

Source§

impl Tast

Source

pub fn add_init_entries(&mut self, items: &[InitEntry]) -> InitList

Adds the values one initializer stores.

§Panics

Panics if the table would exceed four billion entries.

Trait Implementations§

Source§

impl Debug for Tast

Source§

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

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

impl Default for Tast

Source§

fn default() -> Tast

Returns the “default value” for a type. Read more
Source§

impl Index<Idx<Case>> for Tast

Source§

type Output = Case

The returned type after indexing.
Source§

fn index(&self, id: CaseId) -> &Case

Performs the indexing (container[index]) operation. Read more
Source§

impl Index<Idx<Const>> for Tast

Source§

type Output = Const

The returned type after indexing.
Source§

fn index(&self, id: ConstId) -> &Const

Performs the indexing (container[index]) operation. Read more
Source§

impl Index<Idx<Decl>> for Tast

Source§

type Output = Decl

The returned type after indexing.
Source§

fn index(&self, id: DeclId) -> &Decl

Performs the indexing (container[index]) operation. Read more
Source§

impl Index<Idx<Expr>> for Tast

Source§

type Output = Expr

The returned type after indexing.
Source§

fn index(&self, id: ExprId) -> &Expr

Performs the indexing (container[index]) operation. Read more
Source§

impl Index<Idx<Label>> for Tast

Source§

type Output = Label

The returned type after indexing.
Source§

fn index(&self, id: LabelId) -> &Label

Performs the indexing (container[index]) operation. Read more
Source§

impl Index<Idx<Stmt>> for Tast

Source§

type Output = Stmt

The returned type after indexing.
Source§

fn index(&self, id: StmtId) -> &Stmt

Performs the indexing (container[index]) operation. Read more
Source§

impl Index<Idx<StringLiteral>> for Tast

Source§

type Output = StringLiteral

The returned type after indexing.
Source§

fn index(&self, id: StrId) -> &StringLiteral

Performs the indexing (container[index]) operation. Read more
Source§

impl Index<IdxRange<Case>> for Tast

Source§

type Output = [Case]

The returned type after indexing.
Source§

fn index(&self, list: CaseList) -> &[Case]

Performs the indexing (container[index]) operation. Read more
Source§

impl Index<IdxRange<DeclRef>> for Tast

Source§

type Output = [Idx<Decl>]

The returned type after indexing.
Source§

fn index(&self, list: DeclList) -> &[DeclId]

Performs the indexing (container[index]) operation. Read more
Source§

impl Index<IdxRange<ExprRef>> for Tast

Source§

type Output = [Idx<Expr>]

The returned type after indexing.
Source§

fn index(&self, list: ExprList) -> &[ExprId]

Performs the indexing (container[index]) operation. Read more
Source§

impl Index<IdxRange<InitEntry>> for Tast

Source§

type Output = [InitEntry]

The returned type after indexing.
Source§

fn index(&self, list: InitList) -> &[InitEntry]

Performs the indexing (container[index]) operation. Read more
Source§

impl Index<IdxRange<StmtRef>> for Tast

Source§

type Output = [Idx<Stmt>]

The returned type after indexing.
Source§

fn index(&self, list: StmtList) -> &[StmtId]

Performs the indexing (container[index]) operation. Read more

Auto Trait Implementations§

§

impl Freeze for Tast

§

impl RefUnwindSafe for Tast

§

impl Send for Tast

§

impl Sync for Tast

§

impl Unpin for Tast

§

impl UnsafeUnpin for Tast

§

impl UnwindSafe for Tast

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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.