pub enum Expr {
Show 20 variants
Nil,
T,
Number(Number),
String(String),
Symbol(String),
Keyword(String),
Bytes(Vec<u8>),
Cons(Box<Expr>, Box<Expr>),
List(Vec<Expr>),
Quote(Box<Expr>),
Datum(Box<Expr>),
Quasiquote(Box<Expr>),
Unquote(Box<Expr>),
UnquoteSplicing(Box<Expr>),
Lambda(LambdaParams, Box<Expr>),
RuntimeValue(Value),
WasmRuntime(WasmType),
WasmLocal(u32, WasmType),
WasmGlobal(u32, WasmType),
Instance(u32, StructId),
}Variants§
Nil
T
Number(Number)
String(String)
Symbol(String)
Keyword(String)
Bytes(Vec<u8>)
Cons(Box<Expr>, Box<Expr>)
List(Vec<Expr>)
Quote(Box<Expr>)
Datum(Box<Expr>)
An evaluated value that is the datum inside; the reader never makes it.
Quasiquote(Box<Expr>)
Unquote(Box<Expr>)
UnquoteSplicing(Box<Expr>)
Lambda(LambdaParams, Box<Expr>)
RuntimeValue(Value)
WasmRuntime(WasmType)
WasmLocal(u32, WasmType)
Value stored in WASM local variable (index, type)
WasmGlobal(u32, WasmType)
Value stored in a mutable module global (index, type)
Instance(u32, StructId)
A session struct instance an earlier unit left (serial, layout): a leaf the unit’s prologue binds to a module global; it never folds.
Implementations§
Source§impl Expr
impl Expr
pub fn cons(car: Expr, cdr: Expr) -> Self
pub fn symbol(name: &str) -> Self
Sourcepub fn wasm_type(&self) -> Option<WasmType>
pub fn wasm_type(&self) -> Option<WasmType>
Returns the WasmType if this expression is a runtime value.
Sourcepub fn is_wasm_runtime(&self) -> bool
pub fn is_wasm_runtime(&self) -> bool
True if this is a runtime value.
Sourcepub fn is_runtime_variable(&self) -> bool
pub fn is_runtime_variable(&self) -> bool
True for a runtime placeholder, local or global, which means nothing outside the function that resolved it; a session instance does.
Sourcepub fn any_form(&self, test: impl Fn(&Expr) -> bool) -> bool
pub fn any_form(&self, test: impl Fn(&Expr) -> bool) -> bool
Whether test holds of the form or of any form inside it. Walked with
an explicit stack, so a deep form cannot overflow.
Sourcepub fn place(&self) -> Option<(Place, WasmType)>
pub fn place(&self) -> Option<(Place, WasmType)>
The storage and type of a runtime variable; None for a placeholder
or a compile-time value.
Sourcepub fn is_function_value(&self) -> bool
pub fn is_function_value(&self) -> bool
Whether the value is a function: a lambda or a closure place.
Source§impl Expr
impl Expr
Sourcepub fn is_nil(&self) -> bool
pub fn is_nil(&self) -> bool
The single compile-time truth test: a value is false exactly when it is nil.
pub fn is_atom(&self) -> bool
pub fn as_symbol(&self) -> Option<&str>
Sourcepub fn symbol_parts(&self) -> Option<(Option<&str>, &str)>
pub fn symbol_parts(&self) -> Option<(Option<&str>, &str)>
Splits a Symbol into (namespace, name). A qualified symbol is
stored canonically as NS:NAME (ADR-0029); an unqualified one has no
: and yields (None, name). Non-symbols yield None. The split is
on the single canonical : — NS::NAME was already folded to NS:NAME
by the reader, so at most one : is ever present here.
Source§impl Expr
impl Expr
Sourcepub fn quoted(datum: Expr) -> Self
pub fn quoted(datum: Expr) -> Self
The one constructor for a value that is a datum (a 'x datum is the
list (QUOTE x)): nil, t, the empty
list, numbers, strings and keywords are the values themselves, anything else
is wrapped in Datum. A list datum holds
its 'x members as the lists (QUOTE x), at every depth.
Sourcepub fn quoted_code(code: Expr) -> Self
pub fn quoted_code(code: Expr) -> Self
The code form 'x, as the reader makes it: the expression is code,
whose 'x members stay quotes.
Sourcepub fn into_code(self) -> Self
pub fn into_code(self) -> Self
A computed value where code is wanted: a datum is the form it holds,
the exact inverse of Expr::into_data, any other value is itself.
Sourcepub fn into_data(self) -> Self
pub fn into_data(self) -> Self
The datum of a quoted list: a 'x member is the list (QUOTE x), at
every depth. The outermost expression is not wrapped.
Sourcepub fn into_datum_member(self) -> Self
pub fn into_datum_member(self) -> Self
A value as a member of list data: its Datum wrapper goes and a quote
is the list (QUOTE x), at every depth.
Sourcepub fn exact_number(&self) -> Option<Ratio<i64>>
pub fn exact_number(&self) -> Option<Ratio<i64>>
The exact value of a numeric constant, whatever its dimension.
pub fn quoted_list(items: Vec<Expr>) -> Self
Source§impl Expr
impl Expr
Sourcepub fn unquoted_forms(&self) -> Vec<&Expr>
pub fn unquoted_forms(&self) -> Vec<&Expr>
The forms the quasiquote template self runs: its unquotes and
unquote-splicings at the template’s own depth, in order.
Sourcepub fn map_unquoted(
&self,
rewrite: &mut impl FnMut(&Expr) -> Result<Expr>,
) -> Result<Expr>
pub fn map_unquoted( &self, rewrite: &mut impl FnMut(&Expr) -> Result<Expr>, ) -> Result<Expr>
The template self with each of its Self::unquoted_forms replaced
by rewrite of it.