pub struct SymbolTable { /* private fields */ }Implementations§
Source§impl SymbolTable
impl SymbolTable
pub fn register_builtins(&mut self)
Source§impl SymbolTable
impl SymbolTable
Sourcepub fn declare_unbound(&mut self, name: &str)
pub fn declare_unbound(&mut self, name: &str)
Keeps the special declaration of name with no value: a DEFVAR of it
ran in the unit but nothing bound it. A name the unit started with a
value no store replaced keeps that value.
Sourcepub fn restore_declaration(&mut self, name: &str, stored: bool)
pub fn restore_declaration(&mut self, name: &str, stored: bool)
Puts the declaration of the global name back as it stood before the
unit, when no DEFVAR of it ran: a global a store gave a value is then
one a SETF created.
Source§impl SymbolTable
impl SymbolTable
Sourcepub fn record_closure_params(&mut self, sig: ClosureSigId, params: &[WasmType])
pub fn record_closure_params(&mut self, sig: ClosureSigId, params: &[WasmType])
Records the parameter WasmTypes for a closure signature id (see
Self::closure_params).
Sourcepub fn closure_params(&self, sig: ClosureSigId) -> Option<&[WasmType]>
pub fn closure_params(&self, sig: ClosureSigId) -> Option<&[WasmType]>
The recorded parameter WasmTypes for a closure signature id, or None
when the closure wasn’t recorded.
Sourcepub fn closure_param(&self, sig: ClosureSigId) -> Option<WasmType>
pub fn closure_param(&self, sig: ClosureSigId) -> Option<WasmType>
The recorded first parameter WasmType for a closure signature id, or
None when the closure takes no parameters or wasn’t recorded.
Sourcepub fn record_closure_body(
&mut self,
place: Place,
params: LambdaParams,
body: Expr,
)
pub fn record_closure_body( &mut self, place: Place, params: LambdaParams, body: Expr, )
Records a value-position lambda’s source for the closure value in place.
Sourcepub fn closure_body(&self, place: Place) -> Option<&(LambdaParams, Expr)>
pub fn closure_body(&self, place: Place) -> Option<&(LambdaParams, Expr)>
The source of the closure value held in place, if one was recorded.
Sourcepub fn forget_closure_body(&mut self, place: Place)
pub fn forget_closure_body(&mut self, place: Place)
Drops the recorded source of place: a setf overwrote the closure, so
the source no longer describes the value now there.
Source§impl SymbolTable
impl SymbolTable
Sourcepub fn closure_source(&self, site: i32) -> Option<&ClosureSource>
pub fn closure_source(&self, site: i32) -> Option<&ClosureSource>
The source of the closure made at site in the unit that last compiled.
Source§impl SymbolTable
impl SymbolTable
Source§impl SymbolTable
impl SymbolTable
Sourcepub fn take_unit_slots(&mut self) -> Vec<UnitSlot>
pub fn take_unit_slots(&mut self) -> Vec<UnitSlot>
Takes the manifest of the unit that just compiled; a host that never takes it leaves it to expire when the next unit starts.
Source§impl SymbolTable
impl SymbolTable
Sourcepub fn next_serial(&self) -> u32
pub fn next_serial(&self) -> u32
The serial the next unit’s first new instance takes.
Sourcepub fn instances(&self) -> impl Iterator<Item = (u32, &StructInstance)>
pub fn instances(&self) -> impl Iterator<Item = (u32, &StructInstance)>
The live instances, by serial.
Sourcepub fn settle_instances(&mut self, found: Found, next_serial: u32)
pub fn settle_instances(&mut self, found: Found, next_serial: u32)
Replaces the heap with what a host read after a unit. An instance that is opaque, or reaches one or one never read, is dropped and so is every global that reaches it, loud when a later unit reads it; an instance no global or carried closure reaches is swept. The serial counter never goes back.
Source§impl SymbolTable
impl SymbolTable
Sourcepub fn local_alias_origin(alias: &str) -> Option<&str>
pub fn local_alias_origin(alias: &str) -> Option<&str>
The LABELS function an alias was made for.
Source§impl SymbolTable
impl SymbolTable
Sourcepub fn register_test(&mut self, name: impl Into<String>, body: Expr)
pub fn register_test(&mut self, name: impl Into<String>, body: Expr)
Register a named test (DEFTEST); RUN-TESTS reads it via Self::tests.
Re-registering an existing name overwrites its body in place (matching
Self::define’s overwrite semantics) rather than appending, so the
two-surface compile — which may evaluate a DEFTEST on both the eval
and codegen passes — stays idempotent and never double-runs a test.
Sourcepub fn tests(&self) -> Vec<(String, Expr)>
pub fn tests(&self) -> Vec<(String, Expr)>
Snapshot of registered tests in declaration order. Cloned so
RUN-TESTS can iterate without holding a borrow on the table
it needs to evaluate against.
Sourcepub fn mark_native_referenced(&mut self, name: &str)
pub fn mark_native_referenced(&mut self, name: &str)
Records a compile-time reference to native fn name. Called
from the compiler’s host_fn::compile_host_fn_for_* whenever
a wasm import call is emitted for name.
Sourcepub fn native_coverage(&self) -> &HashMap<String, u32>
pub fn native_coverage(&self) -> &HashMap<String, u32>
Compile-time reference counts per native fn name. The map only
contains names that were emitted at least once; callers that
need a complete-vs-missing report should cross-reference
against the registered HostFnSpec list.
Sourcepub fn register_host_fns(&mut self, host_fns: &[HostFnSpec])
pub fn register_host_fns(&mut self, host_fns: &[HostFnSpec])
Pre-registers the lisp-side symbol for each host fn so the compiler’s
resolve_arg + native-dispatch path picks them up. The symbol’s value
slot carries a WasmRuntime(result-type) stand-in so callers that
eval the host-fn form during compile-time analysis (CONS element
inference, arithmetic dispatch type lookup, etc.) see the right
result type without needing to actually run the host fn. The
matching wasm import is registered separately by
CompileContext::new_eval_with_host_fns.
Source§impl SymbolTable
impl SymbolTable
Sourcepub fn define_special(&mut self, symbol: Symbol)
pub fn define_special(&mut self, symbol: Symbol)
Defines a global variable: one a callee sees even when a LET rebinds it.
Source§impl SymbolTable
impl SymbolTable
Sourcepub fn load_nomiscript_defuns(&mut self, source: &str) -> Result<()>
pub fn load_nomiscript_defuns(&mut self, source: &str) -> Result<()>
Parses a DEFUN-only nomiscript source and registers each defun into
this table via the eval special-form path. Shared by the universal
prelude here and the rpc host prelude.
§Errors
The source does not parse, a top-level form is not a DEFUN, or a DEFUN is refused.
Source§impl SymbolTable
impl SymbolTable
pub fn new() -> Self
Sourcepub fn record_closure_result(&mut self, sig: ClosureSigId, result: WasmType)
pub fn record_closure_result(&mut self, sig: ClosureSigId, result: WasmType)
Records the result WasmType for a closure signature id (see
Self::closure_results). Called by the closure-emit sites, which hold
the CompileContext and so know the sig’s true result type.
Sourcepub fn closure_result(&self, sig: ClosureSigId) -> Option<WasmType>
pub fn closure_result(&self, sig: ClosureSigId) -> Option<WasmType>
The recorded result WasmType for a closure signature id, or None if
the closure wasn’t emitted through a recording site (e.g. a closure
reaching the eval surface from a path that doesn’t record).
pub fn with_builtins() -> Self
pub fn with_builtins_for_wasm() -> Self
A variable name no program can spell or collide with, unique across
every clone of this table, for the parameter param of factory.
The (factory, parameter) a Self::hidden_name was made for.
pub fn lookup(&self, name: &str) -> Option<&Symbol>
Sourcepub fn lookup_qualified(
&self,
namespace: Option<&str>,
name: &str,
) -> Option<&Symbol>
pub fn lookup_qualified( &self, namespace: Option<&str>, name: &str, ) -> Option<&Symbol>
Looks up a (possibly namespaced) name via its canonical key (ADR-0029).
Resolution is strict and lexical: a qualified (Some(ns), name) looks
up only NS:NAME, an unqualified (None, name) looks up only NAME —
there is no cross-namespace fallback and no ambient “current namespace”.
Most call sites pass the already-canonical Expr::Symbol string straight
to Self::lookup; this helper is for callers that hold the split parts.