kecc::ir::dtype

Struct BaseDtype

Source
struct BaseDtype {
    scalar: Option<TypeSpecifier>,
    size_modifiers: Vec<TypeSpecifier>,
    signed_option: Option<TypeSpecifier>,
    typedef_name: Option<String>,
    struct_type: Option<StructType>,
    is_const: bool,
    is_typedef: bool,
}

Fields§

§scalar: Option<TypeSpecifier>§size_modifiers: Vec<TypeSpecifier>§signed_option: Option<TypeSpecifier>§typedef_name: Option<String>§struct_type: Option<StructType>§is_const: bool§is_typedef: bool

Implementations§

Source§

impl BaseDtype

Source

fn apply_storage_class( &mut self, storage_class: &StorageClassSpecifier, ) -> Result<(), DtypeError>

Apply StorageClassSpecifier to BaseDtype.

Let’s say declaration is typedef int i32_t;, if self represents int and type_qualifier represents typedef, self is transformed to representing typedef int.

§Arguments
  • self - Part that has been converted to ‘BaseDtype’ on the declaration.
  • storage_class - storage class requiring to apply to ‘self’ immediately.
Source

fn apply_type_specifier( &mut self, type_specifier: &TypeSpecifier, ) -> Result<(), DtypeError>

Apply TypeSpecifier to BaseDtype.

Let’s say the declaration is const int a;, if self represents int and type_specifier represents const, self is transformed to representing const int.

§Arguments
  • self - Part that has been converted to ‘BaseDtype’ on the declaration.
  • type_qualifier - type qualifiers requiring to apply to ‘self’ immediately.
Source

fn apply_type_qualifier( &mut self, type_qualifier: &TypeQualifier, ) -> Result<(), DtypeError>

Apply Typequalifier to BaseDtype.

Let’s say the declaration is const int a;, if self represents int and type_qualifier represents const, self is transformed to representing const int.

§Arguments
  • self - Part that has been converted to ‘BaseDtype’ on the declaration.
  • type_qualifier - type qualifiers requiring to apply to ‘self’ immediately.
Source

pub(crate) fn apply_specifier_qualifier( &mut self, typename_specifier: &SpecifierQualifier, ) -> Result<(), DtypeError>

Source

pub(crate) fn apply_declaration_specifier( &mut self, declaration_specifier: &DeclarationSpecifier, ) -> Result<(), DtypeError>

Source

pub(crate) fn apply_pointer_qualifier( &mut self, pointer_qualifier: &PointerQualifier, ) -> Result<(), DtypeError>

Apply PointerQualifier to BaseDtype.

let’s say pointer declarator is * const of const int * const a;. If self represents nothing, and pointer_qualifier represents const between the first and second asterisk, self is transformed to representing const. This information is used later when generating Dtype.

§Arguments
  • self - Part that has been converted to ‘BaseDtype’ on the pointer declarator.
  • pointer_qualifier - Pointer qualifiers required to apply to ‘BaseDtype’ immediately.
Source

pub(crate) fn apply_specifier_qualifiers( &mut self, typename_specifiers: &[Node<SpecifierQualifier>], ) -> Result<(), DtypeError>

Source

pub(crate) fn apply_declaration_specifiers( &mut self, declaration_specifiers: &[Node<DeclarationSpecifier>], ) -> Result<(), DtypeError>

Trait Implementations§

Source§

impl Default for BaseDtype

Source§

fn default() -> BaseDtype

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

impl TryFrom<BaseDtype> for Dtype

Source§

fn try_from(spec: BaseDtype) -> Result<Self, DtypeError>

Derive a data type containing scalar type from specifiers.

§Example

For declaration is const unsigned int * p, specifiers is const unsigned int, and the result is Dtype::Int { width: 4, is_signed: false, is_const: true }.

Source§

type Error = DtypeError

The type returned in the event of a conversion error.

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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. 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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V