MemberRef

Enum MemberRef 

Source
pub enum MemberRef {
    Absolute(u16),
    Deferred {
        field_name: Symbol,
        field_type: TypeId,
    },
    DeferredByIndex {
        parent_type: TypeId,
        relative_index: u16,
    },
}
Expand description

Symbolic reference to a struct field or enum variant. Resolved to absolute member index during bytecode emission.

Struct field indices are deduplicated globally: same (name, type) pair → same index. This enables call-site scoping where uncaptured refs share the caller’s scope.

Enum variant indices use the traditional (parent_type, relative_index) approach since enum variants don’t bubble between scopes.

Variants§

§

Absolute(u16)

Already resolved to absolute index (for cases where it’s known).

§

Deferred

Deferred resolution by field identity (for struct fields). The same (field_name, field_type) pair resolves to the same member index regardless of which struct type contains it.

Fields

§field_name: Symbol

The Symbol of the field name (from query interner).

§field_type: TypeId

The TypeId of the field’s value type (from query TypeContext).

§

DeferredByIndex

Deferred resolution by parent type + relative index (for enum variants). Uses the parent enum’s member_base + relative_index.

Fields

§parent_type: TypeId

The TypeId of the parent enum type.

§relative_index: u16

Relative index within the parent type’s members.

Implementations§

Source§

impl MemberRef

Source

pub fn absolute(index: u16) -> Self

Create an absolute reference.

Source

pub fn deferred(field_name: Symbol, field_type: TypeId) -> Self

Create a deferred reference by field identity (for struct fields).

Source

pub fn deferred_by_index(parent_type: TypeId, relative_index: u16) -> Self

Create a deferred reference by parent type + index (for enum variants).

Source

pub fn resolve<F, G>(self, lookup_member: F, get_member_base: G) -> u16
where F: Fn(Symbol, TypeId) -> Option<u16>, G: Fn(TypeId) -> Option<u16>,

Resolve this reference using lookup functions.

  • lookup_member: maps (field_name Symbol, field_type TypeId) to member index
  • get_member_base: maps parent TypeId to member base index

Trait Implementations§

Source§

impl Clone for MemberRef

Source§

fn clone(&self) -> MemberRef

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for MemberRef

Source§

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

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

impl Copy for MemberRef

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