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.