Skip to main content

ClLiteRuntime

Struct ClLiteRuntime 

Source
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

Source

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");
Source

pub fn environment(&self) -> &LexicalEnv

Returns the runtime’s lexical environment.

Source

pub fn package(&self) -> &Namespace

Returns the runtime’s current package namespace.

Source

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.

Source

pub fn function(&self, name: &Symbol) -> Result<Value>

Looks up a defined function by name in the lexical environment.

Source

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.

Source

pub fn macro_function(&self, name: &Symbol) -> Option<Value>

Looks up a macro function by name, if one is defined.

Source

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.

Source

pub fn define_variable( &mut self, cx: &mut Cx, name: Symbol, initial: Value, ) -> Result<Value>

Defines a special variable backed by a mutation cell.

Source

pub fn setq( &mut self, cx: &mut Cx, name: &Symbol, value: Value, ) -> Result<Value>

Updates a defined variable’s cell; requires the mutation capability.

Source

pub fn variable_value(&self, name: &Symbol) -> Result<Value>

Reads the current value of a defined variable’s cell.

Source

pub fn setf_cell( &mut self, cx: &mut Cx, cell: &Cell, value: Value, ) -> Result<Value>

Updates a generalized place by writing into its mutation cell.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.