Skip to main content

Module type_tracking

Module type_tracking 

Source
Expand description

Type Tracking for Bytecode Compiler

This module tracks known type information during compilation to enable type-specialized code generation. When a variable’s type is known at compile time, the compiler can emit optimized opcodes for field access.

§How Types Become Known

Types are known in these situations:

  • Explicit type annotation: let x: Candle = ...
  • Constructor call: let x = Candle { ... }
  • Object literal: let x = { a: 1, b: 2 } (inline struct type)
  • Function with declared return type: let x = get_candle()

§Usage

The compiler uses this to emit typed field opcodes for dot access:

  • GetFieldTyped (specialized): Direct slot access by precomputed offset
  • SetFieldTyped (specialized): Direct slot update by precomputed offset Generic GetProp/SetProp are reserved for non-dot operations (index/slice).

§Storage Type Hints

For JIT optimization, we track storage types:

  • StorageHint::NullableFloat64: Option uses NaN sentinel
  • StorageHint::Float64: Plain f64, no nullability

§Strict-typing contract: prove_native_kind and ProofGap

Every typed-opcode emission site must call prove_native_kind and handle the ProofGap error. ProofGap’s constructor is private to this module: emit code cannot fabricate “I proved it”. The Rust type system enforces the discipline.

In Phases 2-4, the predicate panics in debug + test, returns a compile error in release. There is no fallback path.

Structs§

BindingSemantics
Ownership/storage metadata for a binding slot.
FrameDescriptor
Typed frame layout metadata.
LocalTypesSnapshot
Sweep phase 3c.1: snapshot of the type-tracker’s local-types state captured before a nested function compilation that clears them. Wraps both the flat local_types map and the per-scope local_type_scopes stack so pop_scope semantics survive the round-trip.
ProofGap
A type-system proof gap — the compiler tried to emit a typed opcode but could not prove the operand kind. Surfaces as E_TYPED_OPCODE_WITHOUT_PROOF in release; panics in debug + test.
TypeTracker
Tracks type information for variables during compilation
VariableTypeInfo
Type information for a variable

Enums§

Aliasability
BindingOwnershipClass
Source-level ownership class for a binding slot.
BindingStorageClass
Planned runtime storage strategy for a binding slot.
EscapeStatus
MutationCapability
NativeKind
Storage discriminator for a single 8-byte typed slot.
NumericType
Numeric type known at compile time for typed opcode emission.
VariableKind
The kind of variable: regular value, typed table, row view, or column.

Functions§

native_kind_from_storage_type
Convert a runtime StorageType to its marshal-layer NativeKind.
proof_gap_unresolved_operand
Surface a ProofGap for an operand whose compile-time type could not be resolved to a concrete kind.
prove_native_kind
Prove that the given slot’s content is a specific NativeKind at emission time, or surface a ProofGap.

Type Aliases§

StorageHint
Backwards-compatible alias. Prefer NativeKind in new code.