pub struct Universe {
    pub interner: Interner,
    pub globals: HashMap<String, Value>,
    pub classpath: Vec<PathBuf>,
    pub core: CoreClasses,
    pub start_time: Instant,
    pub frames: Vec<SOMRef<Frame>>,
}
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<String, Value>

The known global bindings.

§classpath: Vec<PathBuf>

The path to search in for new classes.

§core: CoreClasses

The interpreter’s core classes.

§start_time: Instant

The time record of the universe’s creation.

§frames: Vec<SOMRef<Frame>>

The interpreter’s stack frames.

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( 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 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 with_frame<T>( &mut self, kind: FrameKind, func: impl FnOnce(&mut Self) -> T ) -> T

Execute a piece of code within a new stack frame.

source

pub fn current_frame(&self) -> &SOMRef<Frame>

Get the current frame.

source

pub fn current_method_frame(&self) -> SOMRef<Frame>

Get the method invocation frame for the current frame.

source

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

Intern a symbol.

source

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

Lookup a symbol.

source

pub fn lookup_local(&self, name: impl AsRef<str>) -> Option<Value>

Search for a local binding.

source

pub fn has_global(&self, name: impl AsRef<str>) -> bool

Returns whether a global binding of the specified name exists.

source

pub fn lookup_global(&self, name: impl AsRef<str>) -> Option<Value>

Search for a global binding.

source

pub fn assign_local( &mut self, name: impl AsRef<str>, value: Value ) -> Option<()>

Assign a value to a local binding.

source

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

Assign a value to a global binding.

source§

impl Universe

source

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

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

source

pub fn does_not_understand( &mut self, value: Value, symbol: impl AsRef<str>, args: Vec<Value> ) -> Option<Return>

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

source

pub fn unknown_global( &mut self, value: Value, name: impl AsRef<str> ) -> Option<Return>

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

source

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

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