Struct gluon::Thread []

pub struct Thread {
    // some fields omitted
}

Representation of the virtual machine

Methods

impl Thread

fn new_thread(&self) -> RootedThread

Spawns a new gluon thread with its own stack and heap but while still sharing the same global environment

fn define_global<'vm, T>(&'vm self, name: &str, value: T) -> Result<(), Error> where T: Pushable<'vm> + VMType

Creates a new global value at name. Fails if a global called name already exists.

fn get_global<'vm, T>(&'vm self, name: &str) -> Result<T, Error> where T: Getable<'vm> + VMType

Retrieves the global called name. Fails if the global does not exist or it does not have the correct type.

fn find_type_info(&self, name: &str) -> Result<Alias<Symbol, ArcType<Symbol>>, Error>

Retrieves type information about the type name. Types inside records can be accessed using dot notation (std.prelude.Option)

fn get_type<T>(&self) -> ArcType<Symbol> where T: Any + ?Sized

Returns the gluon type that was bound to T

fn register_type<T>(&self, name: &str, args: &[&str]) -> Result<ArcType<Symbol>, Error> where T: Any + ?Sized

Registers the type T as being a gluon type called name with generic arguments args

fn get_env(&'b self) -> RwLockReadGuard<'b, VMEnv>

Locks and retrieves the global environment of the vm

fn get_stack(&self) -> MutexGuard<Stack>

Locks and retrives this threads stack

fn get_macros(&self) -> &MacroEnv

Retrieves the macros defined for this vm

fn collect(&self)

Runs a garbage collection.

fn push<'vm, T>(&'vm self, v: T) where T: Pushable<'vm>

Pushes a value to the top of the stack

fn pop(&self)

Removes the top value from the stack

Trait Implementations

impl Traverseable for Thread

fn traverse(&self, gc: &mut Gc)

impl PartialEq<Thread> for Thread

fn eq(&self, other: &Thread) -> bool

impl ThreadInternal for Thread

fn current_frame(&self) -> StackFrame

Returns the current stackframe

fn root<T>(&'vm self, v: GcPtr<Box<Userdata + 'static>>) -> Option<Root<'vm, T>> where T: Userdata

Roots a userdata

fn root_string(&'vm self, ptr: GcPtr<Str>) -> RootStr<'vm>

Roots a string

fn root_value(&self, value: Value) -> RootedValue<RootedThread>

Roots a value

fn root_value_ref(&self, value: Value) -> RootedValue<&Thread>

Roots a value

fn alloc<D>(&self, stack: &Stack, def: D) -> GcPtr<D::Value> where D: DataDef + Traverseable, D::Value: Sized, D::Value: Any

Allocates a new value from a given DataDef. Takes the stack as it may collect if the collection limit has been reached.

fn new_data(&self, tag: u32, fields: &[Value]) -> Value

fn add_bytecode(&self, name: &str, typ: ArcType<Symbol>, args: u32, instructions: Vec<Instruction>)

fn call_module(&self, typ: &ArcType<Symbol>, closure: GcPtr<ClosureData>) -> Result<Value, Error>

Calls a module, allowed to to run IO expressions

fn call_function(&'b self, stack: StackFrame<'b>, args: u32) -> Result<Option<StackFrame<'b>>, Error>

Calls a function on the stack. When this function is called it is expected that the function exists at stack.len() - args - 1 and that the arguments are of the correct type

fn resume(&self) -> Result<(), Error>

fn global_env(&self) -> &Arc<GlobalVMState>

fn deep_clone(&self, value: Value) -> Result<Value, Error>