Skip to main content

Context

Struct Context 

Source
pub struct Context {
    pub constants: Vec<ConstantData>,
    pub void_ty: TypeId,
    pub i1_ty: TypeId,
    pub i8_ty: TypeId,
    pub i16_ty: TypeId,
    pub i32_ty: TypeId,
    pub i64_ty: TypeId,
    pub f32_ty: TypeId,
    pub f64_ty: TypeId,
    pub ptr_ty: TypeId,
    pub label_ty: TypeId,
    /* private fields */
}
Expand description

Public API for Context.

Fields§

§constants: Vec<ConstantData>

Constant pool.

§void_ty: TypeId

Public API for void_ty.

§i1_ty: TypeId

Public API for i1_ty.

§i8_ty: TypeId

Public API for i8_ty.

§i16_ty: TypeId

Public API for i16_ty.

§i32_ty: TypeId

Public API for i32_ty.

§i64_ty: TypeId

Public API for i64_ty.

§f32_ty: TypeId

Public API for f32_ty.

§f64_ty: TypeId

Public API for f64_ty.

§ptr_ty: TypeId

Public API for ptr_ty.

§label_ty: TypeId

Public API for label_ty.

Implementations§

Source§

impl Context

Source

pub fn new() -> Self

Public API for new.

Source

pub fn mk_int(&mut self, bits: u32) -> TypeId

Public API for mk_int.

Source

pub fn mk_float(&mut self, kind: FloatKind) -> TypeId

Public API for mk_float.

Source

pub fn mk_ptr(&mut self) -> TypeId

Public API for mk_ptr.

Source

pub fn mk_label(&mut self) -> TypeId

Public API for mk_label.

Source

pub fn mk_metadata(&mut self) -> TypeId

Public API for mk_metadata.

Source

pub fn mk_array(&mut self, element: TypeId, len: u64) -> TypeId

Public API for mk_array.

Source

pub fn mk_vector(&mut self, element: TypeId, len: u32, scalable: bool) -> TypeId

Public API for mk_vector.

Source

pub fn mk_fn_type( &mut self, ret: TypeId, params: Vec<TypeId>, variadic: bool, ) -> TypeId

Public API for mk_fn_type.

Source

pub fn mk_struct_anon(&mut self, fields: Vec<TypeId>, packed: bool) -> TypeId

Public API for mk_struct_anon.

Source

pub fn mk_struct_named(&mut self, name: String) -> TypeId

Create or look up a named struct. If the name is new, an opaque (empty-body) struct is allocated. Call define_struct_body to fill in fields later.

Source

pub fn define_struct_body( &mut self, id: TypeId, fields: Vec<TypeId>, packed: bool, )

Fill in the body of a previously-created named struct.

Source

pub fn get_named_struct(&self, name: &str) -> Option<TypeId>

Look up a named struct by name.

Source

pub fn get_type(&self, id: TypeId) -> &TypeData

Public API for get_type.

Source

pub fn get_type_mut(&mut self, id: TypeId) -> &mut TypeData

Public API for get_type_mut.

Source

pub fn num_types(&self) -> usize

Total number of interned types.

Source

pub fn types(&self) -> impl Iterator<Item = (TypeId, &TypeData)>

Iterate over all (TypeId, TypeData) pairs.

Source

pub fn const_int(&mut self, ty: TypeId, val: u64) -> ConstId

Public API for const_int.

Source

pub fn const_float(&mut self, ty: TypeId, bits: u64) -> ConstId

Store a float constant as raw bits (f32 bits in low 32 for Single, full u64 bits for Double / other).

Source

pub fn const_null(&mut self, ty: TypeId) -> ConstId

Public API for const_null.

Source

pub fn const_undef(&mut self, ty: TypeId) -> ConstId

Public API for const_undef.

Source

pub fn const_poison(&mut self, ty: TypeId) -> ConstId

Public API for const_poison.

Source

pub fn const_zero(&mut self, ty: TypeId) -> ConstId

Public API for const_zero.

Source

pub fn push_const(&mut self, c: ConstantData) -> ConstId

Push a complex (non-scalar) constant without deduplication.

Source

pub fn get_const(&self, id: ConstId) -> &ConstantData

Public API for get_const.

Source

pub fn type_of_const(&self, id: ConstId) -> TypeId

Public API for type_of_const.

Trait Implementations§

Source§

impl Default for Context

Source§

fn default() -> Self

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

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, 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.