pub struct ThunkSignature {
pub impl_type_id: u32,
pub trait_id: u32,
pub method_name: String,
pub flags: VTableEntryFlags,
pub wrap_targets: SmallVec<[WrapTarget; 2]>,
pub self_arg_positions: SmallVec<[u8; 4]>,
pub type_param_count: u8,
}Expand description
Per-(impl, method) thunk descriptor — the data the emission tier needs to generate a thunk function for one method of one impl.
The emission tier walks each impl’s method list, runs Erase_T on
each method’s signature, and either emits a VTableEntry::Direct
(no rewriting needed) or a thunk + the corresponding
VTableEntry::{BoxedReturn, SelfArg, Generic, Compound} per
§Q25.C.5.
Per-(impl, method) cardinality. One thunk per pair, NOT one per
trait — different impls of the same trait method may need
different thunks because the concrete return type differs. (E.g.
impl Animal for Dog { fn clone_me(&self) -> Dog } vs
impl Animal for Cat { fn clone_me(&self) -> Cat } — each clones
a different concrete type and boxes it under the same trait id.)
Fields§
§impl_type_id: u32Impl that owns the method (concrete-type id from the impl’s
matching VTable::concrete_type_id).
trait_id: u32Trait the method belongs to (VTable::trait_names first entry,
or the surrounding trait for multi-impl cases).
method_name: StringMethod name as declared in the trait.
flags: VTableEntryFlagsErasure flags — which of (BoxedReturn / SelfArg / Generic)
apply. Empty → emission tier emits VTableEntry::Direct and
no thunk. Single bit → emission emits the corresponding
single-shape VTableEntry::* variant. Multiple bits →
VTableEntry::Compound.
wrap_targets: SmallVec<[WrapTarget; 2]>Wrap-targets if BOXED_RETURN is set (empty otherwise).
self_arg_positions: SmallVec<[u8; 4]>Self-arg positions if SELF_ARG is set (empty otherwise).
type_param_count: u8Number of method-generic parameters if GENERIC is set
(zero otherwise).
Implementations§
Source§impl ThunkSignature
impl ThunkSignature
Sourcepub fn build(
impl_type_id: u32,
trait_id: u32,
method_name: String,
return_wrap_targets: SmallVec<[WrapTarget; 2]>,
self_arg_positions: SmallVec<[u8; 4]>,
type_param_count: u8,
) -> Self
pub fn build( impl_type_id: u32, trait_id: u32, method_name: String, return_wrap_targets: SmallVec<[WrapTarget; 2]>, self_arg_positions: SmallVec<[u8; 4]>, type_param_count: u8, ) -> Self
Build a thunk signature from per-arg / per-return erasure
results. The emission tier calls this once per (impl, method)
pair after running Erase_T on each component of the
signature.
return_wrap_targets—wrap_targetsfrom runningErase_Ton the method’s return type. Non-empty ⇒BOXED_RETURN.self_arg_positions— indices (0-based, excluding receiver) of arguments declared asSelfin the trait signature. Non-empty ⇒SELF_ARG.type_param_count— number of<G>method-generic parameters. Non-zero ⇒GENERIC.
Sourcepub fn to_vtable_entry(&self, function_or_thunk_id: u16) -> VTableEntry
pub fn to_vtable_entry(&self, function_or_thunk_id: u16) -> VTableEntry
Build the corresponding VTableEntry once the emission tier
has assigned function_id (for Direct) / thunk_id
(otherwise). Direct entries get function_id; Compound /
shape entries get the thunk id and the emission-tier-
allocated thunk function id is stored elsewhere.
Trait Implementations§
Source§impl Clone for ThunkSignature
impl Clone for ThunkSignature
Source§fn clone(&self) -> ThunkSignature
fn clone(&self) -> ThunkSignature
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more