pub struct Variable {
pub value: KindedSlot,
pub kind: VarKind,
pub is_initialized: bool,
pub is_function_scoped: bool,
pub format_hint: Option<String>,
pub format_overrides: Option<HashMap<String, KindedSlot>>,
}Expand description
A variable in the execution context
Fields§
§value: KindedSlotThe variable’s current value. ADR-006 §2.7 GENERIC_CARRIER —
KindedSlot pairs the 8-byte slot with its NativeKind so heap
refcounts are managed by KindedSlot::Drop/Clone.
kind: VarKindThe variable kind (let, var, const)
is_initialized: boolWhether the variable has been initialized
is_function_scoped: boolWhether this is a function-scoped variable (var, Flexible ownership) vs block-scoped (let/const, Owned{Immutable,Mutable} ownership)
format_hint: Option<String>Optional format hint for display (e.g., “Percent” for meta lookup)
format_overrides: Option<HashMap<String, KindedSlot>>Optional format parameter overrides from type alias (e.g.,
{ decimals: 4 } from type Percent4 = Percent { decimals: 4 }).
KindedSlot::Drop releases each value’s refcount when the
HashMap is dropped — no wrapper type required.
Implementations§
Source§impl Variable
impl Variable
Sourcepub fn new(kind: VarKind, value: Option<KindedSlot>) -> Self
pub fn new(kind: VarKind, value: Option<KindedSlot>) -> Self
Create a new variable
Sourcepub fn with_format(
kind: VarKind,
value: Option<KindedSlot>,
format_hint: Option<String>,
format_overrides: Option<HashMap<String, KindedSlot>>,
) -> Self
pub fn with_format( kind: VarKind, value: Option<KindedSlot>, format_hint: Option<String>, format_overrides: Option<HashMap<String, KindedSlot>>, ) -> Self
Create a new variable with format hint and parameter overrides.
Sourcepub fn can_assign(&self) -> bool
pub fn can_assign(&self) -> bool
Check if this variable can be assigned to
Sourcepub fn assign(&mut self, value: KindedSlot) -> Result<()>
pub fn assign(&mut self, value: KindedSlot) -> Result<()>
Assign a value to this variable
Sourcepub fn get_value(&self) -> Result<&KindedSlot>
pub fn get_value(&self) -> Result<&KindedSlot>
Get the value as KindedSlot reference, checking initialization