TypeTableBuilder

Struct TypeTableBuilder 

Source
pub struct TypeTableBuilder { /* private fields */ }
Expand description

Builds the type metadata, remapping query TypeIds to bytecode BytecodeTypeIds.

Implementations§

Source§

impl TypeTableBuilder

Source

pub fn new() -> Self

Source

pub fn build( &mut self, type_ctx: &TypeContext, interner: &Interner, strings: &mut StringTableBuilder, ) -> Result<(), EmitError>

Build type table from TypeContext.

Types are collected in definition order, depth-first, to mirror query structure. Used builtins are emitted first, then custom types - no reserved slots.

Source

pub fn resolve_type( &self, type_id: TypeId, type_ctx: &TypeContext, ) -> Result<BytecodeTypeId, EmitError>

Resolve a query TypeId to bytecode BytecodeTypeId.

Handles Ref types by following the reference chain to the actual type.

Source

pub fn validate(&self) -> Result<(), EmitError>

Validate that counts fit in u16.

Source

pub fn get(&self, type_id: TypeId) -> Option<BytecodeTypeId>

Get the bytecode BytecodeTypeId for a query TypeId.

Source

pub fn get_member_base(&self, type_id: TypeId) -> Option<u16>

Get the absolute member base index for a struct/enum type.

For Struct and Enum types, returns the starting index in the TypeMembers table. Fields/variants are at indices [base..base+count).

Source

pub fn lookup_member( &self, field_name: Symbol, field_type: TypeId, strings: &StringTableBuilder, ) -> Option<u16>

Look up member index by field identity (name Symbol, value TypeId).

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

Source

pub fn emit(&self) -> (Vec<u8>, Vec<u8>, Vec<u8>)

Emit type definitions, members, and names as bytes.

Returns (type_defs_bytes, type_members_bytes, type_names_bytes).

Source

pub fn type_defs_count(&self) -> usize

Number of type definitions.

Source

pub fn type_members_count(&self) -> usize

Number of type members.

Source

pub fn type_names_count(&self) -> usize

Number of type names.

Trait Implementations§

Source§

impl Debug for TypeTableBuilder

Source§

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

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

impl Default for TypeTableBuilder

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.