Expand description
Helpers for the scope family of commands (scope variables, scope commands, …).
§How “what’s in scope” is collected
Permanent (global) bindings live on EngineState overlays. Nested parse scopes throw
away their name maps on exit_scope, so two additional mechanisms recover locals:
-
Variables — each
Variablemay store itsname.ScopeData::collect_varsbuilds a name→id map from permanent overlays, then overwrites with stack-resident VarIds (outer→inner so the live binding wins). Non-const entries without a stack value are skipped (supportsunlet). Permanent names withoutVariable.namestill appear via overlays. -
Commands / aliases / externs / modules — parse snapshots
ScopeBindingsontoBlock. At runtime:- Whole blocks (closures, custom commands) push bindings on
Stack::active_scope_bindingsineval_ir_block. - Keyword bodies inlined into parent IR record
ScopeRegions;scopeincludes regions that contain the current instruction index.
ScopeData::populate_decls/ScopeData::populate_modulesmerge permanent overlays, then active whole-block bindings, then matching IR regions. - Whole blocks (closures, custom commands) push bindings on
scope engine-stats intentionally reports only engine-wide counts and ignores locals.
Structs§
- Scope
Data - Collects name→id maps for the
scopesubcommands.
Functions§
- find_
builtin_ decl - Find the first declaration with
CommandType::Builtinwhose name matchesname, scanning from the most-recently registered declaration backwards.