pub struct Types { /* private fields */ }
Expand description
Holds a reference to all of the Type
s used in the Module
, and facilitates
lookups so you can get a TypeRef
to the Type
you want.
Implementations§
Source§impl Types
impl Types
Sourcepub fn type_of<T: Typed + ?Sized>(&self, t: &T) -> TypeRef
pub fn type_of<T: Typed + ?Sized>(&self, t: &T) -> TypeRef
Get the type of anything that is Typed
Sourcepub fn pointer_to(&self, pointee_type: TypeRef) -> TypeRef
pub fn pointer_to(&self, pointee_type: TypeRef) -> TypeRef
Get a pointer type in the default address space (0
)
Sourcepub fn pointer_in_addr_space(
&self,
pointee_type: TypeRef,
addr_space: AddrSpace,
) -> TypeRef
pub fn pointer_in_addr_space( &self, pointee_type: TypeRef, addr_space: AddrSpace, ) -> TypeRef
Get a pointer type in the specified address space
Sourcepub fn func_type(
&self,
result_type: TypeRef,
param_types: Vec<TypeRef>,
is_var_arg: bool,
) -> TypeRef
pub fn func_type( &self, result_type: TypeRef, param_types: Vec<TypeRef>, is_var_arg: bool, ) -> TypeRef
Get a function type
pub fn vector_of(&self, element_type: TypeRef, num_elements: usize) -> TypeRef
Sourcepub fn array_of(&self, element_type: TypeRef, num_elements: usize) -> TypeRef
pub fn array_of(&self, element_type: TypeRef, num_elements: usize) -> TypeRef
Get an array type
Sourcepub fn struct_of(&self, element_types: Vec<TypeRef>, is_packed: bool) -> TypeRef
pub fn struct_of(&self, element_types: Vec<TypeRef>, is_packed: bool) -> TypeRef
Get a struct type
Sourcepub fn named_struct(&self, name: &str) -> TypeRef
pub fn named_struct(&self, name: &str) -> TypeRef
Get the TypeRef
for the struct with the given name
.
Note that this gives a NamedStructType
.
To get the actual definition of a named struct (the NamedStructDef
),
use named_struct_def()
.
Sourcepub fn named_struct_def(&self, name: &str) -> Option<&NamedStructDef>
pub fn named_struct_def(&self, name: &str) -> Option<&NamedStructDef>
Get the NamedStructDef
for the struct with the given name
, or
None
if there is no struct by that name.
Note that this gives a NamedStructDef
.
To get the NamedStructType
for a name
, use named_struct()
.
Sourcepub fn all_struct_names(&self) -> impl Iterator<Item = &String>
pub fn all_struct_names(&self) -> impl Iterator<Item = &String>
Get the names of all the named structs
Sourcepub fn add_named_struct_def(&mut self, name: String, def: NamedStructDef)
pub fn add_named_struct_def(&mut self, name: String, def: NamedStructDef)
Add the given NamedStructDef
as the definition of the struct with the given name
.
Panics if that name already had a definition.
Sourcepub fn remove_named_struct_def(&mut self, name: &str) -> bool
pub fn remove_named_struct_def(&mut self, name: &str) -> bool
Remove the definition of the struct with the given name
.
Returns true
if the definition was removed, or false
if no definition
existed.
Sourcepub fn metadata_type(&self) -> TypeRef
pub fn metadata_type(&self) -> TypeRef
Get the metadata type
Sourcepub fn label_type(&self) -> TypeRef
pub fn label_type(&self) -> TypeRef
Get the label type
Sourcepub fn token_type(&self) -> TypeRef
pub fn token_type(&self) -> TypeRef
Get the token type
Sourcepub fn get_for_type(&self, ty: &Type) -> TypeRef
pub fn get_for_type(&self, ty: &Type) -> TypeRef
Get a TypeRef
for the given Type
Source§impl Types
impl Types
Sourcepub fn blank_for_testing() -> Self
pub fn blank_for_testing() -> Self
Get a blank Types
containing essentially no types.
This function is intended only for use in testing;
it’s probably not useful otherwise.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Types
impl RefUnwindSafe for Types
impl Send for Types
impl Sync for Types
impl Unpin for Types
impl UnwindSafe for Types
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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