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 declaratorThe semantic analysis typechecking stage resolves a declared type to a canonical AstType.
Fields§
§basic_type: AstBasicTypeThe 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
impl AstDeclaredType
pub fn unresolved(
basic_type: AstBasicType,
storage_class: Option<AstStorageClassSpecifier>,
declarator: Option<AstDeclarator>,
) -> Self
pub fn unresolved( basic_type: AstBasicType, storage_class: Option<AstStorageClassSpecifier>, declarator: Option<AstDeclarator>, ) -> Self
Creates a new, unresolved AstDeclaredType.
pub fn is_resolved(&self) -> bool
pub fn is_resolved(&self) -> bool
Has the declared type been resolved?
pub fn get_identifier(&self) -> Option<&AstIdentifier>
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
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>
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
impl Clone for AstDeclaredType
§fn clone(&self) -> AstDeclaredType
fn clone(&self) -> AstDeclaredType
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more