Enum oxischeme::value::Value
[-]
[+]
[src]
pub enum Value { EmptyList, Pair(ConsPtr), String(StringPtr), Symbol(StringPtr), Integer(i64), Boolean(bool), Character(char), Procedure(ProcedurePtr), Primitive(Primitive), }
Value
represents a scheme value of any type.
Note that Eq
and PartialEq
are object identity, not structural
comparison, same as with ArenaPtr
.
Variants
Methods
impl Value
fn new_integer(i: i64) -> Value
Create a new integer value.
fn new_boolean(b: bool) -> Value
Create a new boolean value.
fn new_character(c: char) -> Value
Create a new character value.
fn new_pair(heap: &mut Heap, car: &RootedValue, cdr: &RootedValue) -> RootedValue
Create a new cons pair value with the given car and cdr.
fn new_procedure(heap: &mut Heap, arity: u32, act: &RootedActivationPtr, body: Meaning) -> RootedValue
Create a new procedure with the given parameter list and body.
fn new_primitive(name: &'static str, function: PrimitiveFunction) -> Value
fn new_string(heap: &mut Heap, str: String) -> RootedValue
Create a new string value with the given string.
fn new_symbol(heap: &mut Heap, str: RootedStringPtr) -> RootedValue
Create a new symbol value with the given string.
impl Value
fn car(&self, heap: &mut Heap) -> Option<RootedValue>
Assuming this value is a cons pair, get its car value. Otherwise, return
None
.
fn cdr(&self, heap: &mut Heap) -> Option<RootedValue>
Assuming this value is a cons pair, get its cdr value. Otherwise, return
None
.
fn is_pair(&self) -> bool
Return true if this value is a pair, false otherwise.
fn is_atom(&self) -> bool
Return true if this value is an atom, false otherwise.
fn to_symbol(&self, heap: &mut Heap) -> Option<RootedStringPtr>
Coerce this symbol value to a StringPtr
to the symbol's string name.
fn to_pair(&self, heap: &mut Heap) -> Option<RootedConsPtr>
Coerce this pair value to a ConsPtr
to the cons cell this pair is
referring to.
fn to_procedure(&self, heap: &mut Heap) -> Option<RootedProcedurePtr>
Coerce this procedure value to a ProcedurePtr
to the Procedure
this
value is referring to.
fn to_integer(&self) -> Option<i64>
Coerce this integer value to its underlying i64
.
fn len(&self) -> Result<u64, ()>
Assuming that this value is a proper list, get the length of the list.
fn iter(&self) -> ConsIterator
Iterate over this list value.
Trait Implementations
impl ToGcThing for Value
fn to_gc_thing(&self) -> Option<GcThing>
impl Display for Value
fn fmt(&self, f: &mut Formatter) -> Result
Print the given value's text representation to the given writer. This is
the opposite of Read
.