Struct pliron_llvm::types::StructType
source · 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. Call “set_fields” after creation to set recursive types.
- LLVM calls anonymous structs as literal structs and named structs as identified structs.
Implementations§
source§impl StructType
impl StructType
sourcepub fn get_named(
ctx: &mut Context,
name: &str,
fields: Option<Vec<StructField>>
) -> Result<TypePtr<Self>>
pub fn get_named( ctx: &mut Context, name: &str, fields: Option<Vec<StructField>> ) -> Result<TypePtr<Self>>
Get or create a new named StructType.
If fields is None, it indicates an opaque (i.e., not finalized) struct.
Opaque structs must be finalized (by passing non-none fields
) for verify() to succeed.
Opaque structs are an intermediary in creating recursive types.
Returns an error when the name is already registered but the fields don’t match.
sourcepub fn get_unnamed(ctx: &mut Context, fields: Vec<StructField>) -> TypePtr<Self>
pub fn get_unnamed(ctx: &mut Context, fields: Vec<StructField>) -> TypePtr<Self>
Get or create a new unnamed (anonymous) struct. These are finalized upon creation, and uniqued based on the fields.
sourcepub fn is_finalized(ctx: &Context, ty: Ptr<TypeObj>) -> bool
pub fn is_finalized(ctx: &Context, ty: Ptr<TypeObj>) -> bool
Is this struct finalized? Returns false for non StructTypes.
sourcepub fn get_existing_named(ctx: &Context, name: &str) -> Option<TypePtr<Self>>
pub fn get_existing_named(ctx: &Context, name: &str) -> Option<TypePtr<Self>>
If a named struct already exists, get a pointer to it.
sourcepub fn get_existing_unnamed(
ctx: &Context,
fields: Vec<StructField>
) -> Option<TypePtr<Self>>
pub fn get_existing_unnamed( ctx: &Context, fields: Vec<StructField> ) -> Option<TypePtr<Self>>
If an unnamed struct already exists, get a pointer to it.
sourcepub fn field_type(&self, field_idx: usize) -> Ptr<TypeObj>
pub fn field_type(&self, field_idx: usize) -> Ptr<TypeObj>
Get type of the idx’th field.
sourcepub fn field_name(&self, field_idx: usize) -> Identifier
pub fn field_name(&self, field_idx: usize) -> Identifier
Get name of the idx’th field.
sourcepub fn num_fields(&self) -> usize
pub fn num_fields(&self) -> usize
Get the number of fields this struct has
Trait Implementations§
source§impl Debug for StructType
impl Debug for StructType
source§impl Hash for StructType
impl Hash for StructType
source§impl Parsable for StructType
impl Parsable for StructType
§type Parsed = TypePtr<StructType>
type Parsed = TypePtr<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§fn parser<'a>(
arg: Self::Arg
) -> Box<dyn Parser<Stream<Stream<Stream<Stream<IteratorStream<CharIterator<'a>>, SourcePosition>>>, State<'a>>, PartialState = (), Output = Self::Parsed> + 'a>
fn parser<'a>( arg: Self::Arg ) -> Box<dyn Parser<Stream<Stream<Stream<Stream<IteratorStream<CharIterator<'a>>, SourcePosition>>>, State<'a>>, PartialState = (), Output = Self::Parsed> + 'a>
source§fn parser_fn<'a>(
_: &'a (),
arg: Self::Arg
) -> Box<dyn Parser<Stream<Stream<Stream<Stream<IteratorStream<CharIterator<'a>>, SourcePosition>>>, State<'a>>, PartialState = (), Output = Self::Parsed> + 'a>
fn parser_fn<'a>( _: &'a (), arg: Self::Arg ) -> Box<dyn Parser<Stream<Stream<Stream<Stream<IteratorStream<CharIterator<'a>>, SourcePosition>>>, State<'a>>, PartialState = (), Output = Self::Parsed> + 'a>
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
source§fn get_self_ptr(&self, ctx: &Context) -> Ptr<Box<dyn Type>>
fn get_self_ptr(&self, ctx: &Context) -> Ptr<Box<dyn Type>>
source§fn register_instance(t: Self, ctx: &mut Context) -> TypePtr<Self>where
Self: Sized,
fn register_instance(t: Self, ctx: &mut Context) -> TypePtr<Self>where
Self: Sized,
source§fn register_type_in_dialect(
dialect: &mut Dialect,
parser: for<'a> fn(_: &'a (), _: ()) -> Box<dyn Parser<Stream<Stream<Stream<Stream<IteratorStream<CharIterator<'a>>, SourcePosition>>>, State<'a>>, PartialState = (), Output = TypePtr<Self>> + 'a>
)where
Self: Sized,
fn register_type_in_dialect(
dialect: &mut Dialect,
parser: for<'a> fn(_: &'a (), _: ()) -> Box<dyn Parser<Stream<Stream<Stream<Stream<IteratorStream<CharIterator<'a>>, SourcePosition>>>, State<'a>>, PartialState = (), Output = TypePtr<Self>> + 'a>
)where
Self: Sized,
impl Eq for StructType
Auto Trait Implementations§
impl Freeze for StructType
impl !RefUnwindSafe for StructType
impl !Send for StructType
impl Sync for StructType
impl Unpin 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
source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
source§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>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.source§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>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.source§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.source§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.