Struct AstDeclaredType

pub struct AstDeclaredType {
    pub basic_type: AstBasicType,
    pub storage_class: Option<AstStorageClassSpecifier>,
    pub declarator: Option<AstDeclarator>,
    pub resolved_type: Option<AstType>,
}
Expand description

An AstDeclaredType represents a parsed type declaration which is not yet resolved to its canonical AstType.

The declared type consists of a basic type, optional storage class specifier, and optional declarator.

 static unsigned long int *ptr = 0;
 ~~~~~~ ~~~~~~~~~~~~~~~~~ ~~~~

// 'static':            the storage class specifier
// 'unsigned long int': the basic type
// '*ptr':              the declarator

The semantic analysis typechecking stage resolves a declared type to a canonical AstType.

Fields§

§basic_type: AstBasicType

The basic type of the declaration, from which the optional declarator’s derived type is resolved.

§storage_class: Option<AstStorageClassSpecifier>

Optional storage class specifier.

§declarator: Option<AstDeclarator>

The optional declarator which augments the basic type (e.g. a pointer). The declarator may be ommitted in certain contexts, e.g.

int calc(int, float, double);   // Declare a function `calc` with parameter types but no names
(float)                         // A cast expression to `float` type.
§resolved_type: Option<AstType>

The resolved, canonical AstType. The semantic analysis stage fills this out.

Implementations§

§

impl AstDeclaredType

pub fn unresolved( basic_type: AstBasicType, storage_class: Option<AstStorageClassSpecifier>, declarator: Option<AstDeclarator>, ) -> Self

Creates a new, unresolved AstDeclaredType.

pub fn resolved(ty: &AstType) -> Self

Creates a new, resolved AstDeclaredType.

pub fn is_resolved(&self) -> bool

Has the declared type been resolved?

pub fn get_identifier(&self) -> Option<&AstIdentifier>

If the declared type has a declarator, and if that declarator has an identifier, returns that identifier. Otherwise returns None.

pub fn location(&self) -> SourceLocation

The source location of the declared type including the basic type, storage class and declarator (if they exist).

pub fn declarator_location(&self) -> Option<SourceLocation>

If the type includes a declarator, returns its location. Otherwise returns None.

Trait Implementations§

§

impl Clone for AstDeclaredType

§

fn clone(&self) -> AstDeclaredType

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl Debug for AstDeclaredType

§

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

Formats the value using the given formatter. Read more
§

impl Display for AstDeclaredType

§

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

Formats the value using the given formatter. Read more
§

impl PartialEq for AstDeclaredType

§

fn eq(&self, other: &AstDeclaredType) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl StructuralPartialEq for AstDeclaredType

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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.