Skip to main content

Module

Struct Module 

Source
pub struct Module {
Show 14 fields pub types: Vec<Type>, pub values: Vec<Value>, pub value_types: Vec<TypeId>, pub names: Vec<(ValueId, String)>, pub metadata: Vec<Metadata>, pub metadata_at: Vec<usize>, pub named_metadata: Vec<(String, Vec<MetadataId>)>, pub named_metadata_at: Vec<usize>, pub at: usize, pub functions: Vec<Function>, pub precise_kind: Option<u64>, pub kinds: Vec<(u64, String)>, pub attribute_groups: Vec<AttributeGroup>, pub attribute_lists: Vec<Vec<u64>>,
}
Expand description

A module: its types, values, metadata and function bodies.

Fields§

§types: Vec<Type>

The type table.

§values: Vec<Value>

The module’s values by id (globals, functions, module constants); a function body’s own values continue the numbering in its Function.

§value_types: Vec<TypeId>

Each value’s type.

§names: Vec<(ValueId, String)>

The symbol table: the name of the values that have one.

§metadata: Vec<Metadata>

The metadata records, by MetadataId.

§metadata_at: Vec<usize>

The bit of the bitcode each metadata record (by id) starts at, for the locations of reflection errors.

§named_metadata: Vec<(String, Vec<MetadataId>)>

The named metadata (dx.entryPoints, …): the name and the records it lists.

§named_metadata_at: Vec<usize>

The bit each named metadata record (by index in named_metadata) starts at.

§at: usize

The bit of the bitcode the module block starts at: where a record the module lacks would be.

§functions: Vec<Function>

The function bodies, in the order of their definitions.

§precise_kind: Option<u64>

The id of the module’s dx.precise metadata kind (the kind Instruction::precise reads), where it names one.

§kinds: Vec<(u64, String)>

The module’s metadata kinds: each id and its name, in the order stored.

§attribute_groups: Vec<AttributeGroup>

The attribute groups, in the order stored.

§attribute_lists: Vec<Vec<u64>>

The attribute lists, in the order stored: the ids of the groups each lists. A function value’s attributes is an index into this.

Implementations§

Source§

impl Module

Source

pub fn name(&self, value: ValueId) -> Option<&str>

The module’s name for a value, where its symbol table has one.

Source

pub fn kind_name(&self, kind: u64) -> Option<&str>

The name of a metadata kind id, where the module names it.

Source

pub fn attachment( &self, attachments: &[Attachment], name: &str, ) -> Option<MetadataId>

The node of the attachment among attachments whose kind is called name.

Source

pub fn function_attributes(&self, function: ValueId) -> Vec<&Attribute>

The attributes a function value carries on itself (the groups of its list whose slot is FUNCTION_SLOT); none for a value that is not a function or names no list.

Source

pub fn string_attribute(&self, function: ValueId, key: &str) -> Option<&str>

The value of the string attribute key on a function (empty where the attribute has no value), if it carries it.

Source§

impl Module

Source

pub fn read(top: &[Block]) -> Result<Self>

Read a module from the bitcode’s top-level blocks.

Trait Implementations§

Source§

impl Clone for Module

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Module

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Module

Source§

fn default() -> Self

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

impl PartialEq for Module

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Module

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.