Struct spirt::Context

source ·
pub struct Context {
    interners: Interners,
    entity_allocs: EntityAllocs,
    custom_spv_ext_inst_set_descs: FrozenBTreeMap<String, Box<ExtInstSetDesc>>,
}
Expand description

Context object with global resources for SPIR-T.

Those resources currently are:

  • interners, for anything without an identity, and which can be deduplicated
  • “entity” allocators, for everything else - i.e. anything with an identity that needs to remain unique across an entire Context
    • the definition of an entity isn’t kept in the Context, but rather in some EntityDefs collection somewhere in a Module (or further nested), with only the entity indices being allocated by the Context
  • custom SPIR-V “extended instruction set” descriptions, which can be dynamically registered, to account for any such “extended instruction set” not covered by spv::spec::Spec’s built-in list (e.g. non-standard tool-specific sets), and only used for pretty-printing

Fields§

§interners: Interners§entity_allocs: EntityAllocs§custom_spv_ext_inst_set_descs: FrozenBTreeMap<String, Box<ExtInstSetDesc>>

Implementations§

source§

impl Context

source

pub fn register_custom_ext_inst_set( &self, ext_inst_set_name: &str, ext_inst_set_desc: ExtInstSetDesc )

Register a custom ExtInstSetDesc with name ext_inst_set_name, to be used by pretty-printing when using this Context.

source

pub fn get_custom_ext_inst_set_by_lowercase_name( &self, lowercase_ext_inst_set_name: &str ) -> Option<&ExtInstSetDesc>

Return a custom ExtInstSetDesc, if one was registered on this Context, for this OpExtInstImport name (required to be lowercase, due to Khronos’ choice of case insensitivity, but not checked by this function).

source§

impl Context

source

pub fn new() -> Self

source

pub fn intern<T: InternInCx<I>, I>(&self, x: T) -> I

Trait Implementations§

source§

impl Default for Context

source§

fn default() -> Context

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

impl<I: Interned> Index<I> for Context

§

type Output = <I as Interned>::Def

The returned type after indexing.
source§

fn index(&self, interned: I) -> &Self::Output

Performs the indexing (container[index]) operation. 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>,

§

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

§

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.