pub struct TypeTableBuilder { /* private fields */ }Expand description
Builds the type metadata, remapping query TypeIds to bytecode BytecodeTypeIds.
Implementations§
Source§impl TypeTableBuilder
impl TypeTableBuilder
pub fn new() -> Self
Sourcepub fn build(
&mut self,
type_ctx: &TypeContext,
interner: &Interner,
strings: &mut StringTableBuilder,
) -> Result<(), EmitError>
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.
Sourcepub fn resolve_type(
&self,
type_id: TypeId,
type_ctx: &TypeContext,
) -> Result<BytecodeTypeId, EmitError>
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.
Sourcepub fn get(&self, type_id: TypeId) -> Option<BytecodeTypeId>
pub fn get(&self, type_id: TypeId) -> Option<BytecodeTypeId>
Get the bytecode BytecodeTypeId for a query TypeId.
Sourcepub fn get_member_base(&self, type_id: TypeId) -> Option<u16>
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).
Sourcepub fn lookup_member(
&self,
field_name: Symbol,
field_type: TypeId,
strings: &StringTableBuilder,
) -> Option<u16>
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.
Sourcepub fn emit(&self) -> (Vec<u8>, Vec<u8>, Vec<u8>)
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).
Sourcepub fn type_defs_count(&self) -> usize
pub fn type_defs_count(&self) -> usize
Number of type definitions.
Sourcepub fn type_members_count(&self) -> usize
pub fn type_members_count(&self) -> usize
Number of type members.
Sourcepub fn type_names_count(&self) -> usize
pub fn type_names_count(&self) -> usize
Number of type names.