pub struct Universe {
    pub interner: Interner,
    pub globals: HashMap<Interned, Value>,
    pub classpath: Vec<PathBuf>,
    pub core: CoreClasses,
}
Expand description

The central data structure for the interpreter.

It represents the complete state of the interpreter, like the known class definitions, the string interner and the stack frames.

Fields§

§interner: Interner

The string interner for symbols.

§globals: HashMap<Interned, Value>

The known global bindings.

§classpath: Vec<PathBuf>

The path to search in for new classes.

§core: CoreClasses

The interpreter’s core classes.

Implementations§

source§

impl Universe

source

pub fn with_classpath(classpath: Vec<PathBuf>) -> Result<Self, Error>

Initialize the universe from the given classpath.

source

pub fn load_system_class( interner: &mut Interner, classpath: &[impl AsRef<Path>], class_name: impl Into<String> ) -> Result<SOMRef<Class>, Error>

Load a system class (with an incomplete hierarchy).

source

pub fn load_class( &mut self, class_name: impl Into<String> ) -> Result<SOMRef<Class>, Error>

Load a class from its name into this universe.

source

pub fn load_class_from_path( &mut self, path: impl AsRef<Path> ) -> Result<SOMRef<Class>, Error>

Load a class from its path into this universe.

source

pub fn nil_class(&self) -> SOMRef<Class>

Get the Nil class.

source

pub fn system_class(&self) -> SOMRef<Class>

Get the System class.

source

pub fn object_class(&self) -> SOMRef<Class>

Get the Object class.

source

pub fn symbol_class(&self) -> SOMRef<Class>

Get the Symbol class.

source

pub fn string_class(&self) -> SOMRef<Class>

Get the String class.

source

pub fn array_class(&self) -> SOMRef<Class>

Get the Array class.

source

pub fn integer_class(&self) -> SOMRef<Class>

Get the Integer class.

source

pub fn double_class(&self) -> SOMRef<Class>

Get the Double class.

source

pub fn block_class(&self) -> SOMRef<Class>

Get the Block class.

source

pub fn block1_class(&self) -> SOMRef<Class>

Get the Block1 class.

source

pub fn block2_class(&self) -> SOMRef<Class>

Get the Block2 class.

source

pub fn block3_class(&self) -> SOMRef<Class>

Get the Block3 class.

source

pub fn true_class(&self) -> SOMRef<Class>

Get the True class.

source

pub fn false_class(&self) -> SOMRef<Class>

Get the False class.

source

pub fn metaclass_class(&self) -> SOMRef<Class>

Get the Metaclass class.

source

pub fn method_class(&self) -> SOMRef<Class>

Get the Method class.

source

pub fn primitive_class(&self) -> SOMRef<Class>

Get the Primitive class.

source§

impl Universe

source

pub fn intern_symbol(&mut self, symbol: &str) -> Interned

Intern a symbol.

source

pub fn has_global(&self, idx: Interned) -> bool

source

pub fn lookup_symbol(&self, symbol: Interned) -> &str

Lookup a symbol.

source

pub fn lookup_global(&self, idx: Interned) -> Option<Value>

Search for a global binding.

source

pub fn assign_global(&mut self, name: Interned, value: Value) -> Option<()>

Assign a value to a global binding.

source§

impl Universe

source

pub fn escaped_block( &mut self, interpreter: &mut Interpreter, value: Value, block: Rc<Block> ) -> Option<()>

Call escapedBlock: on the given value, if it is defined.

source

pub fn does_not_understand( &mut self, interpreter: &mut Interpreter, value: Value, symbol: Interned, args: Vec<Value> ) -> Option<()>

Call doesNotUnderstand: on the given value, if it is defined.

source

pub fn unknown_global( &mut self, interpreter: &mut Interpreter, value: Value, name: Interned ) -> Option<()>

Call unknownGlobal: on the given value, if it is defined.

source

pub fn initialize( &mut self, interpreter: &mut Interpreter, args: Vec<Value> ) -> Option<()>

Call System>>#initialize: with the given name, if it is defined.

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>,

§

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>,

§

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V