pub struct Symbol { /* private fields */ }Expand description
A name with its two cells: the variable it names and the function it names.
Implementations§
Source§impl Symbol
impl Symbol
Sourcepub fn new(name: impl Into<String>, kind: SymbolKind) -> Self
pub fn new(name: impl Into<String>, kind: SymbolKind) -> Self
A variable gets a value cell, any other kind a function cell.
Sourcepub fn is_variable(&self) -> bool
pub fn is_variable(&self) -> bool
Whether the name is a variable: a value cell that is not the stand-in a host fn keeps in its own.
Sourcepub fn is_local_function(&self) -> bool
pub fn is_local_function(&self) -> bool
Whether the name is a LABELS function.
Sourcepub fn loop_constant(self) -> Self
pub fn loop_constant(self) -> Self
Marks this binding as a statically unrolled loop’s variable.
Sourcepub fn is_loop_constant(&self) -> bool
pub fn is_loop_constant(&self) -> bool
Whether this binding is a statically unrolled loop’s variable.
Sourcepub fn mark_captured(&mut self)
pub fn mark_captured(&mut self)
Marks this binding as copied into a closure’s environment.
Sourcepub fn is_captured(&self) -> bool
pub fn is_captured(&self) -> bool
Whether a closure holds a copy of this binding.
Sourcepub fn set_block_depth(&mut self, depth: usize)
pub fn set_block_depth(&mut self, depth: usize)
Records how many BLOCK labels were visible at the definition.
Sourcepub fn block_depth(&self) -> usize
pub fn block_depth(&self) -> usize
The BLOCK labels visible at the definition.
Sourcepub fn set_lexical_env(&mut self, env: Vec<(String, u32)>)
pub fn set_lexical_env(&mut self, env: Vec<(String, u32)>)
Records the lexical variables visible at the definition.
Sourcepub fn lexical_env(&self) -> &[(String, u32)]
pub fn lexical_env(&self) -> &[(String, u32)]
The lexical variables visible at the definition.
Sourcepub fn set_lexical_values(&mut self, values: Vec<Symbol>)
pub fn set_lexical_values(&mut self, values: Vec<Symbol>)
Records the lexical bindings the body of this function keeps.
pub fn with_value(self, value: Expr) -> Self
pub fn name(&self) -> &str
Sourcepub fn kind(&self) -> SymbolKind
pub fn kind(&self) -> SymbolKind
The kind of the function cell, Variable for a name without one.
pub fn value(&self) -> Option<&Expr>
pub fn set_value(&mut self, value: Expr)
pub fn expansion_value(&self) -> Option<&Expr>
pub fn set_expansion_value(&mut self, value: Expr)
Sourcepub fn with_function(self, func: Expr) -> Self
pub fn with_function(self, func: Expr) -> Self
Gives the name a function cell holding func, of kind Function
unless it already has one.
pub fn function(&self) -> Option<&Expr>
Sourcepub fn local_function(self) -> Self
pub fn local_function(self) -> Self
Marks this function as bound by a LABELS form.
Sourcepub fn with_definition(self, id: u32) -> Self
pub fn with_definition(self, id: u32) -> Self
Keeps the binding identity of the variable this one re-materialises.
Sourcepub fn value_definition(&self) -> u32
pub fn value_definition(&self) -> u32
The id of the variable binding, 0 without one.
Sourcepub fn function_definition(&self) -> u32
pub fn function_definition(&self) -> u32
The id of the function binding, 0 without one.