pub struct VarDef {
pub name: String,
pub is_const: bool,
pub is_lexical: bool,
pub kind: VarKind,
pub is_captured: bool,
pub scope_level: u32,
pub scope_next: Option<i32>,
}Expand description
A declared variable: an argument or a local.
Fields§
§name: StringThe name, as written.
is_const: boolWhether the binding is immutable.
is_lexical: boolWhether the binding is block-scoped (let/const/class).
kind: VarKindWhat the binding is used for.
is_captured: boolWhether a closure captures this variable, which forces it into a heap-allocated reference cell.
scope_level: u32The lexical scope the binding belongs to.
Scope 0 is the function scope, where var and hoisted function
declarations live; the body and every block introduce a child scope. A
binding only exists between its scope’s entry and exit, which is what the
runtime uses to swap let/const bindings in and out.
scope_next: Option<i32>Index of the next block-scoped variable in the enclosing scope chain, or
None for a var (which is visible in the whole function).
The reference stores this in JSVarDef::scope_next and only fills it in
when scope_level != 0; the interpreter walks the chain to instantiate
and close the let/const bindings that are live at a given point.