pub struct ClLiteRuntime { /* private fields */ }Expand description
CL-lite evaluation state: lexical environment, macro table, special-variable cells, and the current package.
Each surface form delegates to a shared runtime organ rather than reimplementing behavior.
Implementations§
Source§impl ClLiteRuntime
impl ClLiteRuntime
Sourcepub fn new() -> Result<Self>
pub fn new() -> Result<Self>
Creates an empty runtime with the CL-lite package installed.
§Examples
use sim_lib_lang_cl::ClLiteRuntime;
let runtime = ClLiteRuntime::new().unwrap();
assert_eq!(runtime.package().symbol().to_string(), "common-lisp/lite");Sourcepub fn environment(&self) -> &LexicalEnv
pub fn environment(&self) -> &LexicalEnv
Returns the runtime’s lexical environment.
Sourcepub fn defun(
&mut self,
cx: &mut Cx,
name: Symbol,
body: ClFunctionBody,
) -> Result<Value>
pub fn defun( &mut self, cx: &mut Cx, name: Symbol, body: ClFunctionBody, ) -> Result<Value>
Defines a function in the lexical environment via the binding organ.
Sourcepub fn function(&self, name: &Symbol) -> Result<Value>
pub fn function(&self, name: &Symbol) -> Result<Value>
Looks up a defined function by name in the lexical environment.
Sourcepub fn defmacro(
&mut self,
cx: &mut Cx,
name: Symbol,
body: ClFunctionBody,
) -> Result<Value>
pub fn defmacro( &mut self, cx: &mut Cx, name: Symbol, body: ClFunctionBody, ) -> Result<Value>
Defines a macro function in the macro table via the binding organ.
Sourcepub fn macro_function(&self, name: &Symbol) -> Option<Value>
pub fn macro_function(&self, name: &Symbol) -> Option<Value>
Looks up a macro function by name, if one is defined.
Sourcepub fn let_form(
&self,
cx: &mut Cx,
bindings: Vec<(Symbol, Value)>,
body: impl FnOnce(&mut Cx, &LexicalEnv) -> Result<Value>,
) -> Result<Value>
pub fn let_form( &self, cx: &mut Cx, bindings: Vec<(Symbol, Value)>, body: impl FnOnce(&mut Cx, &LexicalEnv) -> Result<Value>, ) -> Result<Value>
Evaluates body in a lexical frame extended with bindings.
Delegates to the binding organ’s let evaluation.
Sourcepub fn define_variable(
&mut self,
cx: &mut Cx,
name: Symbol,
initial: Value,
) -> Result<Value>
pub fn define_variable( &mut self, cx: &mut Cx, name: Symbol, initial: Value, ) -> Result<Value>
Defines a special variable backed by a mutation cell.
Sourcepub fn setq(
&mut self,
cx: &mut Cx,
name: &Symbol,
value: Value,
) -> Result<Value>
pub fn setq( &mut self, cx: &mut Cx, name: &Symbol, value: Value, ) -> Result<Value>
Updates a defined variable’s cell; requires the mutation capability.
Sourcepub fn variable_value(&self, name: &Symbol) -> Result<Value>
pub fn variable_value(&self, name: &Symbol) -> Result<Value>
Reads the current value of a defined variable’s cell.