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 offsetSetFieldTyped(specialized): Direct slot update by precomputed offset GenericGetProp/SetPropare reserved for non-dot operations (index/slice).
§Storage Type Hints
For JIT optimization, we track storage types:
StorageHint::NullableFloat64: Optionuses 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§
- Binding
Semantics - Ownership/storage metadata for a binding slot.
- Frame
Descriptor - Typed frame layout metadata.
- Local
Types Snapshot - 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_typesmap and the per-scopelocal_type_scopesstack sopop_scopesemantics survive the round-trip. - Proof
Gap - 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_PROOFin release; panics in debug + test. - Type
Tracker - Tracks type information for variables during compilation
- Variable
Type Info - Type information for a variable
Enums§
- Aliasability
- Binding
Ownership Class - Source-level ownership class for a binding slot.
- Binding
Storage Class - Planned runtime storage strategy for a binding slot.
- Escape
Status - Mutation
Capability - Native
Kind - Storage discriminator for a single 8-byte typed slot.
- Numeric
Type - Numeric type known at compile time for typed opcode emission.
- Variable
Kind - The kind of variable: regular value, typed table, row view, or column.
Functions§
- native_
kind_ from_ storage_ type - Convert a runtime
StorageTypeto its marshal-layerNativeKind. - proof_
gap_ unresolved_ operand - Surface a
ProofGapfor 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
NativeKindat emission time, or surface aProofGap.
Type Aliases§
- Storage
Hint - Backwards-compatible alias. Prefer
NativeKindin new code.