pub struct SymbolTable { /* private fields */ }Implementations§
Source§impl SymbolTable
impl SymbolTable
pub fn register_builtins(&mut self)
Source§impl SymbolTable
impl SymbolTable
Sourcepub fn load_nomiscript_defuns(&mut self, source: &str, label: &str)
pub fn load_nomiscript_defuns(&mut self, source: &str, label: &str)
Parses a DEFUN-only nomiscript source and registers each defun into
this table via the eval special-form path (the same mechanism
load_financial_structs uses for DEFSTRUCT). Shared by the universal
prelude here and the rpc host prelude. A parse or non-DEFUN form is a
first-party authoring bug: it is logged and (in debug) asserts, rather
than silently shipping a broken prelude.
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
pub fn define(&mut self, symbol: Symbol)
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 [tests].
Re-registering an existing name overwrites its body in place (matching
[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.
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.
pub fn lookup_mut(&mut self, name: &str) -> Option<&mut Symbol>
pub fn remove(&mut self, name: &str) -> Option<Symbol>
pub fn contains(&self, name: &str) -> bool
pub fn iter(&self) -> impl Iterator<Item = (&String, &Symbol)>
pub fn define_struct_fields( &mut self, name: impl Into<String>, fields: Vec<String>, )
pub fn struct_fields(&self, name: &str) -> Option<&[String]>
Trait Implementations§
Source§impl Clone for SymbolTable
impl Clone for SymbolTable
Source§fn clone(&self) -> SymbolTable
fn clone(&self) -> SymbolTable
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more