pub struct Env {
pub by_id: MapS<BindId, Bind>,
pub byref_chain: MapS<BindId, BindId>,
pub binds: MapS<ModPath, MapS<CompactString, BindId>>,
pub used: MapS<ModPath, Arc<Vec<ModPath>>>,
pub modules: SetS<ModPath>,
pub typedefs: MapS<ModPath, MapS<CompactString, TypeDef>>,
pub catch: MapS<ModPath, BindId>,
pub ide_binds: MapS<ModPath, MapS<CompactString, Bind>>,
pub lsp_mode: bool,
pub lsp: Option<Arc<Mutex<Lsp>>>,
}Fields§
§by_id: MapS<BindId, Bind>§byref_chain: MapS<BindId, BindId>§binds: MapS<ModPath, MapS<CompactString, BindId>>§used: MapS<ModPath, Arc<Vec<ModPath>>>§modules: SetS<ModPath>§typedefs: MapS<ModPath, MapS<CompactString, TypeDef>>§catch: MapS<ModPath, BindId>§ide_binds: MapS<ModPath, MapS<CompactString, Bind>>Append-only mirror of every (scope, name) → BindId ever
created via bind_variable. Used by IDE tooling for cursor
→ scope completion: it exposes lambda parameters and other
short-lived bindings that binds drops at scope teardown
and unbind_variable removes from by_id. Not consulted by
the compiler. Only populated when lsp_mode is set.
lsp_mode: boolTrue iff the compiler should populate IDE side-channels
(ide_binds, the lsp sinks, etc.). Toggled by the LSP
runtime; normal compiles leave it unset and pay no IDE cost.
lsp: Option<Arc<Mutex<Lsp>>>IDE side-channel sinks for type references, sig→impl links,
and per-module env snapshots. Some(_) only when running
under an LSP-style check; clones share the inner Arc<Mutex>
so reentrant or concurrent compiles within a single check all
drain into the same buffer. The runtime swaps this in/out at
each check boundary.
Implementations§
Source§impl Env
impl Env
Sourcepub fn push_type_ref(&self, site: TypeRefSite)
pub fn push_type_ref(&self, site: TypeRefSite)
Push a TypeRefSite into the active LSP sink, if any. No-op
when self.lsp is None (every non-LSP compile).
Sourcepub fn push_sig_link(&self, link: SigImplLink)
pub fn push_sig_link(&self, link: SigImplLink)
Push a SigImplLink into the active LSP sink, if any.
Sourcepub fn push_module_internal_view(&self, view: ModuleInternalView)
pub fn push_module_internal_view(&self, view: ModuleInternalView)
Push a per-module internal-view snapshot into the active LSP sink, if any.
pub fn apply_sandbox(&self, spec: &Sandbox) -> Result<Self>
pub fn find_visible<T, F: FnMut(&str, &str) -> Option<T>>( &self, scope: &ModPath, name: &ModPath, f: F, ) -> Option<T>
pub fn lookup_bind( &self, scope: &ModPath, name: &ModPath, ) -> Option<(&ModPath, &Bind)>
pub fn lookup_typedef( &self, scope: &ModPath, name: &ModPath, ) -> Option<&TypeDef>
Sourcepub fn lookup_catch(&self, scope: &ModPath) -> Result<BindId>
pub fn lookup_catch(&self, scope: &ModPath) -> Result<BindId>
lookup the bind id of the nearest catch handler in this scope
Sourcepub fn lookup_matching(
&self,
scope: &ModPath,
part: &ModPath,
) -> Vec<(CompactString, BindId)>
pub fn lookup_matching( &self, scope: &ModPath, part: &ModPath, ) -> Vec<(CompactString, BindId)>
lookup binds in scope that match the specified partial name. This is intended to be used for IDEs and interactive shells, and is not used by the compiler.
Sourcepub fn lookup_matching_modules(
&self,
scope: &ModPath,
part: &ModPath,
) -> Vec<ModPath>
pub fn lookup_matching_modules( &self, scope: &ModPath, part: &ModPath, ) -> Vec<ModPath>
lookup modules in scope that match the specified partial name. This is intended to be used for IDEs and interactive shells, and is not used by the compiler.
pub fn canonical_modpath( &self, scope: &ModPath, name: &ModPath, ) -> Option<ModPath>
pub fn deftype( &mut self, scope: &ModPath, name: &str, params: Arc<[(TVar, Option<Type>)]>, typ: Type, doc: Option<ArcStr>, pos: SourcePosition, ori: Arc<Origin>, ) -> Result<()>
pub fn undeftype(&mut self, scope: &ModPath, name: &str)
Sourcepub fn unbind_scope_subtree(&mut self, scope: &ModPath) -> usize
pub fn unbind_scope_subtree(&mut self, scope: &ModPath) -> usize
Drop everything registered at scope or any descendant. Used by
the LSP when re-typechecking a stdlib (or third-party graphix)
package crate’s own source: the runtime’s env was pre-loaded
with that package at startup, but the live edits need to
register fresh under the same scope. Without scrubbing first,
re-registration trips the duplicate-module / duplicate-type
guards.
Returns the number of (scope, name) entries removed across binds and typedefs.
Sourcepub fn bind_variable(
&mut self,
scope: &ModPath,
name: &str,
typ: Type,
pos: SourcePosition,
ori: Arc<Origin>,
) -> &mut Bind
pub fn bind_variable( &mut self, scope: &ModPath, name: &str, typ: Type, pos: SourcePosition, ori: Arc<Origin>, ) -> &mut Bind
create a new binding. If an existing bind exists in the same scope shadow it.
Sourcepub fn alias_variable(&mut self, scope: &ModPath, name: &str, id: BindId)
pub fn alias_variable(&mut self, scope: &ModPath, name: &str, id: BindId)
make the specified name an alias for id