Skip to main content

TypeTracker

Struct TypeTracker 

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

Tracks type information for variables during compilation

Implementations§

Source§

impl TypeTracker

Source

pub fn new(schema_registry: TypeSchemaRegistry) -> Self

Create a new type tracker with the given schema registry

Source

pub fn empty() -> Self

Create a new type tracker with an empty registry

Source

pub fn with_stdlib() -> Self

Create a new type tracker with stdlib types pre-registered

Source

pub fn schema_registry(&self) -> &TypeSchemaRegistry

Get the schema registry

Source

pub fn schema_registry_mut(&mut self) -> &mut TypeSchemaRegistry

Get mutable schema registry

Source

pub fn push_scope(&mut self)

Push a new scope for local types

Source

pub fn pop_scope(&mut self)

Pop a scope, removing local type info for that scope

Source

pub fn set_local_type(&mut self, slot: u16, type_info: VariableTypeInfo)

Set type info for a local variable

Source

pub fn set_binding_type(&mut self, slot: u16, type_info: VariableTypeInfo)

Set type info for a module_binding variable

Source

pub fn set_local_binding_semantics( &mut self, slot: u16, semantics: BindingSemantics, )

Set ownership/storage metadata for a local binding.

Source

pub fn set_binding_semantics(&mut self, slot: u16, semantics: BindingSemantics)

Set ownership/storage metadata for a module binding.

Source

pub fn set_local_binding_storage_class( &mut self, slot: u16, storage_class: BindingStorageClass, )

Update only the storage strategy for a local binding.

Source

pub fn set_binding_storage_class( &mut self, slot: u16, storage_class: BindingStorageClass, )

Update only the storage strategy for a module binding.

Source

pub fn get_local_type(&self, slot: u16) -> Option<&VariableTypeInfo>

Get type info for a local variable

Source

pub fn get_binding_type(&self, slot: u16) -> Option<&VariableTypeInfo>

Get type info for a module_binding variable

Source

pub fn get_local_binding_semantics( &self, slot: u16, ) -> Option<&BindingSemantics>

Get ownership/storage metadata for a local binding.

Source

pub fn get_binding_semantics(&self, slot: u16) -> Option<&BindingSemantics>

Get ownership/storage metadata for a module binding.

Source

pub fn register_function_return_type( &mut self, func_name: &str, return_type: &str, )

Register a function’s return type

Source

pub fn get_function_return_type(&self, func_name: &str) -> Option<&String>

Get a function’s return type

Source

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.

Source

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.

Source

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

Source

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.

Source

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

Source

pub fn get_local_storage_hint(&self, slot: u16) -> StorageHint

Get storage hint for a local variable

Source

pub fn get_module_binding_storage_hint(&self, slot: u16) -> StorageHint

Get storage hint for a module_binding variable

Source

pub fn local_uses_nan_sentinel(&self, slot: u16) -> bool

Check if a local variable uses NaN sentinel for nullability

Source

pub fn module_binding_uses_nan_sentinel(&self, slot: u16) -> bool

Check if a module_binding variable uses NaN sentinel for nullability

Source

pub fn clear_locals(&mut self)

Clear all local type info (for function entry)

Source

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_id
Source

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.

Source

pub fn register_named_object_schema( &mut self, type_name: &str, fields: &[(&str, FieldType)], ) -> SchemaId

Register a named struct schema (e.g. Point { x, y })

Unlike register_inline_object_schema which auto-generates names, this uses the actual struct type name so .type() can resolve it.

Source

pub fn register_typed_object_schema( &mut self, field_defs: Vec<(String, FieldType)>, ) -> SchemaId

Register an inline object schema with typed fields

Like register_inline_object_schema but allows specifying field types for better JIT optimization.

Trait Implementations§

Source§

impl Debug for TypeTracker

Source§

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

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

impl Default for TypeTracker

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,