Struct som_interpreter_ast::universe::Universe
source · 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
impl Universe
sourcepub fn with_classpath(classpath: Vec<PathBuf>) -> Result<Self, Error>
pub fn with_classpath(classpath: Vec<PathBuf>) -> Result<Self, Error>
Initialize the universe from the given classpath.
sourcepub fn load_system_class(
classpath: &[impl AsRef<Path>],
class_name: impl Into<String>
) -> Result<SOMRef<Class>, Error>
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).
sourcepub fn load_class(
&mut self,
class_name: impl Into<String>
) -> Result<SOMRef<Class>, Error>
pub fn load_class( &mut self, class_name: impl Into<String> ) -> Result<SOMRef<Class>, Error>
Load a class from its name into this universe.
sourcepub fn load_class_from_path(
&mut self,
path: impl AsRef<Path>
) -> Result<SOMRef<Class>, Error>
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.
sourcepub fn system_class(&self) -> SOMRef<Class>
pub fn system_class(&self) -> SOMRef<Class>
Get the System class.
sourcepub fn symbol_class(&self) -> SOMRef<Class>
pub fn symbol_class(&self) -> SOMRef<Class>
Get the Symbol class.
sourcepub fn string_class(&self) -> SOMRef<Class>
pub fn string_class(&self) -> SOMRef<Class>
Get the String class.
sourcepub fn array_class(&self) -> SOMRef<Class>
pub fn array_class(&self) -> SOMRef<Class>
Get the Array class.
sourcepub fn integer_class(&self) -> SOMRef<Class>
pub fn integer_class(&self) -> SOMRef<Class>
Get the Integer class.
sourcepub fn double_class(&self) -> SOMRef<Class>
pub fn double_class(&self) -> SOMRef<Class>
Get the Double class.
sourcepub fn block_class(&self) -> SOMRef<Class>
pub fn block_class(&self) -> SOMRef<Class>
Get the Block class.
sourcepub fn block1_class(&self) -> SOMRef<Class>
pub fn block1_class(&self) -> SOMRef<Class>
Get the Block1 class.
sourcepub fn block2_class(&self) -> SOMRef<Class>
pub fn block2_class(&self) -> SOMRef<Class>
Get the Block2 class.
sourcepub fn block3_class(&self) -> SOMRef<Class>
pub fn block3_class(&self) -> SOMRef<Class>
Get the Block3 class.
sourcepub fn true_class(&self) -> SOMRef<Class>
pub fn true_class(&self) -> SOMRef<Class>
Get the True class.
sourcepub fn false_class(&self) -> SOMRef<Class>
pub fn false_class(&self) -> SOMRef<Class>
Get the False class.
sourcepub fn metaclass_class(&self) -> SOMRef<Class>
pub fn metaclass_class(&self) -> SOMRef<Class>
Get the Metaclass class.
sourcepub fn method_class(&self) -> SOMRef<Class>
pub fn method_class(&self) -> SOMRef<Class>
Get the Method class.
sourcepub fn primitive_class(&self) -> SOMRef<Class>
pub fn primitive_class(&self) -> SOMRef<Class>
Get the Primitive class.
source§impl Universe
impl Universe
sourcepub fn with_frame<T>(
&mut self,
kind: FrameKind,
func: impl FnOnce(&mut Self) -> T
) -> T
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.
sourcepub fn current_frame(&self) -> &SOMRef<Frame>
pub fn current_frame(&self) -> &SOMRef<Frame>
Get the current frame.
sourcepub fn current_method_frame(&self) -> SOMRef<Frame>
pub fn current_method_frame(&self) -> SOMRef<Frame>
Get the method invocation frame for the current frame.
sourcepub fn intern_symbol(&mut self, symbol: &str) -> Interned
pub fn intern_symbol(&mut self, symbol: &str) -> Interned
Intern a symbol.
sourcepub fn lookup_symbol(&self, symbol: Interned) -> &str
pub fn lookup_symbol(&self, symbol: Interned) -> &str
Lookup a symbol.
sourcepub fn has_global(&self, name: impl AsRef<str>) -> bool
pub fn has_global(&self, name: impl AsRef<str>) -> bool
Returns whether a global binding of the specified name exists.
sourcepub fn lookup_global(&self, name: impl AsRef<str>) -> Option<Value>
pub fn lookup_global(&self, name: impl AsRef<str>) -> Option<Value>
Search for a global binding.
source§impl Universe
impl Universe
sourcepub fn escaped_block(
&mut self,
value: Value,
block: Rc<Block>
) -> Option<Return>
pub fn escaped_block( &mut self, value: Value, block: Rc<Block> ) -> Option<Return>
Call escapedBlock:
on the given value, if it is defined.
sourcepub fn does_not_understand(
&mut self,
value: Value,
symbol: impl AsRef<str>,
args: Vec<Value>
) -> Option<Return>
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.