pub struct StructType { /* private fields */ }Expand description
Represents a c-like struct type.
Limitations and warnings on its usage are similar to that in MLIR.
<https://mlir.llvm.org/docs/Dialects/LLVM/#structure-types>
- Anonymous (aka unnamed) structs cannot be recursive.
- Named structs are uniqued only by name, and may be recursive.
- LLVM calls anonymous structs as literal structs and named structs as identified structs.
- Named structs may be opaque, i.e., no body specificed. Recursive types may be created by first creating an opaque struct and later setting its body.
Implementations§
Source§impl StructType
impl StructType
Sourcepub fn get_named(
ctx: &Context,
name: Identifier,
body: Option<(Vec<TypeHandle>, StructLayout)>,
) -> Result<TypedHandle<Self>>
pub fn get_named( ctx: &Context, name: Identifier, body: Option<(Vec<TypeHandle>, StructLayout)>, ) -> Result<TypedHandle<Self>>
Get or create a named StructType.
If body is None, it indicates an opaque struct.
A body can be added to opaque structs by calling this again later.
Returns an error if all of the below conditions are true:
a. The name is already registered
b. The body is already set (i.e, the struct is not oqaue)
c. The body provided here don’t match with the existing body.
Since named structs only rely on the name for uniqueness,
It is not an error to provide body as None even when
the named struct already exists and has its body set.
Sourcepub fn get_unnamed(
ctx: &Context,
body: (Vec<TypeHandle>, StructLayout),
) -> TypedHandle<Self>
pub fn get_unnamed( ctx: &Context, body: (Vec<TypeHandle>, StructLayout), ) -> TypedHandle<Self>
Get or create a new unnamed (anonymous) struct. These are finalized upon creation, and uniqued based on the fields and layout.
Sourcepub fn layout(&self) -> StructLayout
pub fn layout(&self) -> StructLayout
Get this struct’s layout.
Panics if the struct is opaque.
Sourcepub fn field_type(&self, field_idx: usize) -> TypeHandle
pub fn field_type(&self, field_idx: usize) -> TypeHandle
Get type of the idx’th field.
Panics if the struct is opaque or the index is invalid.
Sourcepub fn num_fields(&self) -> usize
pub fn num_fields(&self) -> usize
Get the number of fields this struct has
Panics if the struct is opaque.
Trait Implementations§
Source§impl Debug for StructType
impl Debug for StructType
impl Eq for StructType
Source§impl Hash for StructType
impl Hash for StructType
Source§impl Parsable for StructType
impl Parsable for StructType
Source§type Parsed = TypedHandle<StructType>
type Parsed = TypedHandle<StructType>
Source§fn parse<'a>(
state_stream: &mut StateStream<'a>,
_arg: Self::Arg,
) -> ParseResult<'a, Self::Parsed>where
Self: Sized,
fn parse<'a>(
state_stream: &mut StateStream<'a>,
_arg: Self::Arg,
) -> ParseResult<'a, Self::Parsed>where
Self: Sized,
into on [Parser::parse_stream] to get the final [ParseResult].
Use state_stream.state as necessary.Source§impl PartialEq for StructType
impl PartialEq for StructType
Source§impl Printable for StructType
impl Printable for StructType
Source§impl Type for StructType
impl Type for StructType
Source§fn hash_type(&self) -> TypeValueHash
fn hash_type(&self) -> TypeValueHash
Source§fn get_type_id(&self) -> TypeId
fn get_type_id(&self) -> TypeId
Source§fn get_type_id_static() -> TypeId
fn get_type_id_static() -> TypeId
§fn get_self_handle(&self, ctx: &Context) -> TypeHandle
fn get_self_handle(&self, ctx: &Context) -> TypeHandle
§fn instantiate(t: Self, ctx: &Context) -> TypedHandle<Self>where
Self: Sized,
fn instantiate(t: Self, ctx: &Context) -> TypedHandle<Self>where
Self: Sized,
Auto Trait Implementations§
impl Freeze for StructType
impl RefUnwindSafe for StructType
impl Send for StructType
impl Sync for StructType
impl Unpin for StructType
impl UnsafeUnpin for StructType
impl UnwindSafe for StructType
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSend for T
impl<T> DowncastSend for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.