Skip to main content

Ast

Struct Ast 

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

Every node of one translation unit.

Implementations§

Source§

impl Ast

Source

pub fn new() -> Ast

An empty tree.

Source

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

The declarations of the translation unit, in source order.

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 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 counts(&self) -> Counts

How many expressions, statements and declarations the tree holds.

The three numbers the size of a translation unit is usually quoted in, and what the --emit=ast header prints.

Source

pub fn is_empty(&self) -> bool

Whether nothing has been parsed into this tree.

Source§

impl Ast

Source

pub fn add_declarator(&mut self, item: Declarator) -> DeclaratorId

Adds a declarator.

§Panics

Panics if the table would exceed four billion entries.

Source§

impl Ast

Source

pub fn add_type_name(&mut self, item: TypeName) -> TypeNameId

Adds a type name.

§Panics

Panics if the table would exceed four billion entries.

Source§

impl Ast

Source

pub fn add_specs(&mut self, item: DeclSpecs) -> DeclSpecsId

Adds a set of declaration specifiers.

§Panics

Panics if the table would exceed four billion entries.

Source§

impl Ast

Source

pub fn add_init(&mut self, item: Init) -> InitId

Adds an initializer.

§Panics

Panics if the table would exceed four billion entries.

Source§

impl Ast

Source

pub fn add_asm(&mut self, item: Asm) -> AsmId

Adds an assembly statement.

§Panics

Panics if the table would exceed four billion entries.

Source§

impl Ast

Source

pub fn add_int(&mut self, item: IntConstant) -> IntId

Adds an integer constant.

§Panics

Panics if the table would exceed four billion entries.

Source§

impl Ast

Source

pub fn add_float(&mut self, item: FloatConstant) -> FloatId

Adds a floating constant.

§Panics

Panics if the table would exceed four billion entries.

Source§

impl Ast

Source

pub fn add_char(&mut self, item: CharConstant) -> CharId

Adds a character constant.

§Panics

Panics if the table would exceed four billion entries.

Source§

impl Ast

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 Ast

Source

pub fn add_expr_list(&mut self, items: &[ExprId]) -> ExprList

Adds a run of expressions, such as the arguments of a call.

§Panics

Panics if the table would exceed four billion entries.

Source§

impl Ast

Source

pub fn add_stmt_list(&mut self, items: &[StmtId]) -> StmtList

Adds a run of statements, such as the body of a compound statement.

§Panics

Panics if the table would exceed four billion entries.

Source§

impl Ast

Source

pub fn add_decl_list(&mut self, items: &[DeclId]) -> DeclList

Adds a run of declarations, such as the parameter declarations of an old-style function definition.

§Panics

Panics if the table would exceed four billion entries.

Source§

impl Ast

Source

pub fn add_str_list(&mut self, items: &[StrId]) -> StrList

Adds a run of string literals, such as an asm clobber list.

§Panics

Panics if the table would exceed four billion entries.

Source§

impl Ast

Source

pub fn add_symbol_list(&mut self, items: &[Symbol]) -> SymbolList

Adds a run of identifiers, such as the labels of an asm goto.

§Panics

Panics if the table would exceed four billion entries.

Source§

impl Ast

Source

pub fn add_attr_list(&mut self, items: &[Attribute]) -> AttrList

Adds a run of attributes.

§Panics

Panics if the table would exceed four billion entries.

Source§

impl Ast

Source

pub fn add_attr_args(&mut self, items: &[AttrArg]) -> AttrArgList

Adds a run of attribute arguments.

§Panics

Panics if the table would exceed four billion entries.

Source§

impl Ast

Source

pub fn add_derived_list(&mut self, items: &[Derived]) -> DerivedList

Adds a run of declarator derivations, from the name outward.

§Panics

Panics if the table would exceed four billion entries.

Source§

impl Ast

Source

pub fn add_param_list(&mut self, items: &[Param]) -> ParamList

Adds a run of function parameters.

§Panics

Panics if the table would exceed four billion entries.

Source§

impl Ast

Source

pub fn add_member_list(&mut self, items: &[Member]) -> MemberList

Adds a run of struct or union members.

§Panics

Panics if the table would exceed four billion entries.

Source§

impl Ast

Source

pub fn add_enumerator_list(&mut self, items: &[Enumerator]) -> EnumeratorList

Adds a run of enumerators.

§Panics

Panics if the table would exceed four billion entries.

Source§

impl Ast

Source

pub fn add_init_declarator_list( &mut self, items: &[InitDeclarator], ) -> InitDeclaratorList

Adds a run of init-declarators.

§Panics

Panics if the table would exceed four billion entries.

Source§

impl Ast

Source

pub fn add_init_item_list(&mut self, items: &[InitItem]) -> InitItemList

Adds a run of braced initializer elements.

§Panics

Panics if the table would exceed four billion entries.

Source§

impl Ast

Source

pub fn add_designator_list(&mut self, items: &[Designator]) -> DesignatorList

Adds a run of designators.

§Panics

Panics if the table would exceed four billion entries.

Source§

impl Ast

Source

pub fn add_generic_list(&mut self, items: &[GenericAssoc]) -> GenericList

Adds a run of _Generic associations.

§Panics

Panics if the table would exceed four billion entries.

Source§

impl Ast

Source

pub fn add_asm_operand_list(&mut self, items: &[AsmOperand]) -> AsmOperandList

Adds a run of assembly operands.

§Panics

Panics if the table would exceed four billion entries.

Trait Implementations§

Source§

impl Debug for Ast

Source§

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

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

impl Default for Ast

Source§

fn default() -> Ast

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

impl Index<Idx<Asm>> for Ast

Source§

type Output = Asm

The returned type after indexing.
Source§

fn index(&self, id: AsmId) -> &Asm

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

impl Index<Idx<CharConstant>> for Ast

Source§

type Output = CharConstant

The returned type after indexing.
Source§

fn index(&self, id: CharId) -> &CharConstant

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

impl Index<Idx<Decl>> for Ast

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<DeclSpecs>> for Ast

Source§

type Output = DeclSpecs

The returned type after indexing.
Source§

fn index(&self, id: DeclSpecsId) -> &DeclSpecs

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

impl Index<Idx<Declarator>> for Ast

Source§

type Output = Declarator

The returned type after indexing.
Source§

fn index(&self, id: DeclaratorId) -> &Declarator

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

impl Index<Idx<Expr>> for Ast

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<FloatConstant>> for Ast

Source§

type Output = FloatConstant

The returned type after indexing.
Source§

fn index(&self, id: FloatId) -> &FloatConstant

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

impl Index<Idx<Init>> for Ast

Source§

type Output = Init

The returned type after indexing.
Source§

fn index(&self, id: InitId) -> &Init

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

impl Index<Idx<IntConstant>> for Ast

Source§

type Output = IntConstant

The returned type after indexing.
Source§

fn index(&self, id: IntId) -> &IntConstant

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

impl Index<Idx<Stmt>> for Ast

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 Ast

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<Idx<TypeName>> for Ast

Source§

type Output = TypeName

The returned type after indexing.
Source§

fn index(&self, id: TypeNameId) -> &TypeName

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

impl Index<IdxRange<AsmOperand>> for Ast

Source§

type Output = [AsmOperand]

The returned type after indexing.
Source§

fn index(&self, list: AsmOperandList) -> &[AsmOperand]

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

impl Index<IdxRange<AttrArg>> for Ast

Source§

type Output = [AttrArg]

The returned type after indexing.
Source§

fn index(&self, list: AttrArgList) -> &[AttrArg]

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

impl Index<IdxRange<Attribute>> for Ast

Source§

type Output = [Attribute]

The returned type after indexing.
Source§

fn index(&self, list: AttrList) -> &[Attribute]

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

impl Index<IdxRange<DeclRef>> for Ast

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<Derived>> for Ast

Source§

type Output = [Derived]

The returned type after indexing.
Source§

fn index(&self, list: DerivedList) -> &[Derived]

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

impl Index<IdxRange<Designator>> for Ast

Source§

type Output = [Designator]

The returned type after indexing.
Source§

fn index(&self, list: DesignatorList) -> &[Designator]

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

impl Index<IdxRange<Enumerator>> for Ast

Source§

type Output = [Enumerator]

The returned type after indexing.
Source§

fn index(&self, list: EnumeratorList) -> &[Enumerator]

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

impl Index<IdxRange<ExprRef>> for Ast

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<GenericAssoc>> for Ast

Source§

type Output = [GenericAssoc]

The returned type after indexing.
Source§

fn index(&self, list: GenericList) -> &[GenericAssoc]

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

impl Index<IdxRange<InitDeclarator>> for Ast

Source§

type Output = [InitDeclarator]

The returned type after indexing.
Source§

fn index(&self, list: InitDeclaratorList) -> &[InitDeclarator]

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

impl Index<IdxRange<InitItem>> for Ast

Source§

type Output = [InitItem]

The returned type after indexing.
Source§

fn index(&self, list: InitItemList) -> &[InitItem]

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

impl Index<IdxRange<Member>> for Ast

Source§

type Output = [Member]

The returned type after indexing.
Source§

fn index(&self, list: MemberList) -> &[Member]

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

impl Index<IdxRange<Param>> for Ast

Source§

type Output = [Param]

The returned type after indexing.
Source§

fn index(&self, list: ParamList) -> &[Param]

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

impl Index<IdxRange<StmtRef>> for Ast

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
Source§

impl Index<IdxRange<StrRef>> for Ast

Source§

type Output = [Idx<StringLiteral>]

The returned type after indexing.
Source§

fn index(&self, list: StrList) -> &[StrId]

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

impl Index<IdxRange<Symbol>> for Ast

Source§

type Output = [Symbol]

The returned type after indexing.
Source§

fn index(&self, list: SymbolList) -> &[Symbol]

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

Auto Trait Implementations§

§

impl Freeze for Ast

§

impl RefUnwindSafe for Ast

§

impl Send for Ast

§

impl Sync for Ast

§

impl Unpin for Ast

§

impl UnsafeUnpin for Ast

§

impl UnwindSafe for Ast

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.