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

EmptyList

The empty list: ().

Pair

The scheme pair type is a pointer to a GC-managed Cons cell.

String

The scheme string type is a pointer to a GC-managed String.

Symbol

Scheme symbols are also implemented as a pointer to a GC-managed String.

Integer

Scheme integers are represented as 64 bit integers.

Boolean

Scheme booleans are represented with bool.

Character

Scheme characters are chars.

Procedure

A user-defined Scheme procedure is a pointer to a GC-managed Procedure.

Primitive

A primitive Scheme procedure is just a pointer to a Primitive type function pointer.

Methods

impl Value

Value Constructors

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

Value Methods

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.

Derived Implementations

impl Debug for Value

fn fmt(&self, __arg_0: &mut Formatter) -> Result

impl PartialEq for Value

fn eq(&self, __arg_0: &Value) -> bool

fn ne(&self, __arg_0: &Value) -> bool

impl<__S: Writer + Hasher> Hash<__S> for Value

fn hash(&self, __arg_0: &mut __S)

impl Eq for Value

fn assert_receiver_is_total_eq(&self)

impl Copy for Value