pub struct TypeTracker { /* private fields */ }Expand description
Tracks type information for variables during compilation
Implementations§
Source§impl TypeTracker
impl TypeTracker
Sourcepub fn new(schema_registry: TypeSchemaRegistry) -> Self
pub fn new(schema_registry: TypeSchemaRegistry) -> Self
Create a new type tracker with the given schema registry
Sourcepub fn with_stdlib() -> Self
pub fn with_stdlib() -> Self
Create a new type tracker with stdlib types pre-registered
Sourcepub fn schema_registry(&self) -> &TypeSchemaRegistry
pub fn schema_registry(&self) -> &TypeSchemaRegistry
Get the schema registry
Sourcepub fn schema_registry_mut(&mut self) -> &mut TypeSchemaRegistry
pub fn schema_registry_mut(&mut self) -> &mut TypeSchemaRegistry
Get mutable schema registry
Sourcepub fn push_scope(&mut self)
pub fn push_scope(&mut self)
Push a new scope for local types
Sourcepub fn set_local_type(&mut self, slot: u16, type_info: VariableTypeInfo)
pub fn set_local_type(&mut self, slot: u16, type_info: VariableTypeInfo)
Set type info for a local variable
Sourcepub fn set_binding_type(&mut self, slot: u16, type_info: VariableTypeInfo)
pub fn set_binding_type(&mut self, slot: u16, type_info: VariableTypeInfo)
Set type info for a module_binding variable
Sourcepub fn set_local_binding_semantics(
&mut self,
slot: u16,
semantics: BindingSemantics,
)
pub fn set_local_binding_semantics( &mut self, slot: u16, semantics: BindingSemantics, )
Set ownership/storage metadata for a local binding.
Sourcepub fn set_binding_semantics(&mut self, slot: u16, semantics: BindingSemantics)
pub fn set_binding_semantics(&mut self, slot: u16, semantics: BindingSemantics)
Set ownership/storage metadata for a module binding.
Sourcepub fn set_local_binding_storage_class(
&mut self,
slot: u16,
storage_class: BindingStorageClass,
)
pub fn set_local_binding_storage_class( &mut self, slot: u16, storage_class: BindingStorageClass, )
Update only the storage strategy for a local binding.
Sourcepub fn set_binding_storage_class(
&mut self,
slot: u16,
storage_class: BindingStorageClass,
)
pub fn set_binding_storage_class( &mut self, slot: u16, storage_class: BindingStorageClass, )
Update only the storage strategy for a module binding.
Sourcepub fn get_local_type(&self, slot: u16) -> Option<&VariableTypeInfo>
pub fn get_local_type(&self, slot: u16) -> Option<&VariableTypeInfo>
Get type info for a local variable
Sourcepub fn get_binding_type(&self, slot: u16) -> Option<&VariableTypeInfo>
pub fn get_binding_type(&self, slot: u16) -> Option<&VariableTypeInfo>
Get type info for a module_binding variable
Sourcepub fn get_local_binding_semantics(
&self,
slot: u16,
) -> Option<&BindingSemantics>
pub fn get_local_binding_semantics( &self, slot: u16, ) -> Option<&BindingSemantics>
Get ownership/storage metadata for a local binding.
Sourcepub fn get_binding_semantics(&self, slot: u16) -> Option<&BindingSemantics>
pub fn get_binding_semantics(&self, slot: u16) -> Option<&BindingSemantics>
Get ownership/storage metadata for a module binding.
Sourcepub fn register_function_return_type(
&mut self,
func_name: &str,
return_type: &str,
)
pub fn register_function_return_type( &mut self, func_name: &str, return_type: &str, )
Register a function’s return type
Sourcepub fn get_function_return_type(&self, func_name: &str) -> Option<&String>
pub fn get_function_return_type(&self, func_name: &str) -> Option<&String>
Get a function’s return type
Sourcepub fn register_object_field_contracts(
&mut self,
schema_id: SchemaId,
fields: HashMap<String, TypeAnnotation>,
)
pub fn register_object_field_contracts( &mut self, schema_id: SchemaId, fields: HashMap<String, TypeAnnotation>, )
Register compile-time field type contracts for an object schema id.
Sourcepub fn get_object_field_contract(
&self,
schema_id: SchemaId,
field_name: &str,
) -> Option<&TypeAnnotation>
pub fn get_object_field_contract( &self, schema_id: SchemaId, field_name: &str, ) -> Option<&TypeAnnotation>
Lookup a compile-time field type contract for a schema field.
Sourcepub fn get_typed_field_info(
&self,
type_name: &str,
field_name: &str,
) -> Option<(SchemaId, usize, u16)>
pub fn get_typed_field_info( &self, type_name: &str, field_name: &str, ) -> Option<(SchemaId, usize, u16)>
Get field offset for typed field access
Returns (schema_id, field_offset, field_index) if type and field are known
Sourcepub fn get_row_view_column_id(
&self,
slot: u16,
is_local: bool,
field_name: &str,
) -> Option<u32>
pub fn get_row_view_column_id( &self, slot: u16, is_local: bool, field_name: &str, ) -> Option<u32>
Get column index for a RowView field access.
Returns the field index (used as col_id for ColumnAccess operand) if the variable is a RowView and the field exists in its schema.
Sourcepub fn can_use_typed_access(
&self,
slot: u16,
is_local: bool,
field_name: &str,
) -> bool
pub fn can_use_typed_access( &self, slot: u16, is_local: bool, field_name: &str, ) -> bool
Check if we can use typed field access for a variable and field
Sourcepub fn get_local_storage_hint(&self, slot: u16) -> StorageHint
pub fn get_local_storage_hint(&self, slot: u16) -> StorageHint
Get storage hint for a local variable
Sourcepub fn get_module_binding_storage_hint(&self, slot: u16) -> StorageHint
pub fn get_module_binding_storage_hint(&self, slot: u16) -> StorageHint
Get storage hint for a module_binding variable
Sourcepub fn local_uses_nan_sentinel(&self, slot: u16) -> bool
pub fn local_uses_nan_sentinel(&self, slot: u16) -> bool
Check if a local variable uses NaN sentinel for nullability
Sourcepub fn module_binding_uses_nan_sentinel(&self, slot: u16) -> bool
pub fn module_binding_uses_nan_sentinel(&self, slot: u16) -> bool
Check if a module_binding variable uses NaN sentinel for nullability
Sourcepub fn clear_locals(&mut self)
pub fn clear_locals(&mut self)
Clear all local type info (for function entry)
Sourcepub fn register_inline_object_schema(
&mut self,
field_names: &[&str],
) -> SchemaId
pub fn register_inline_object_schema( &mut self, field_names: &[&str], ) -> SchemaId
Register an inline object schema from field names
Creates a TypeSchema for an object literal with the given fields.
All fields are assumed to be Any type (NaN-boxed) since we don’t
have full type inference at compile time.
Returns the SchemaId for use with NewTypedObject opcode.
§Example
// For: let x = { a: 1, b: "hello" }
let schema_id = tracker.register_inline_object_schema(&["a", "b"]);
// Now emit NewTypedObject with schema_idSourcepub fn register_inline_object_schema_typed(
&mut self,
fields: &[(&str, FieldType)],
) -> SchemaId
pub fn register_inline_object_schema_typed( &mut self, fields: &[(&str, FieldType)], ) -> SchemaId
Register an inline object schema with typed fields
Like register_inline_object_schema but allows specifying field types
for better JIT optimization. Deduplicates by matching both field names
and types.
Trait Implementations§
Source§impl Debug for TypeTracker
impl Debug for TypeTracker
Auto Trait Implementations§
impl Freeze for TypeTracker
impl RefUnwindSafe for TypeTracker
impl Send for TypeTracker
impl Sync for TypeTracker
impl Unpin for TypeTracker
impl UnsafeUnpin for TypeTracker
impl UnwindSafe for TypeTracker
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more