Skip to main content

Vm

Struct Vm 

Source
pub struct Vm { /* private fields */ }
Expand description

The virtual machine with a program loaded.

Implementations§

Source§

impl Vm

Source

pub fn set_file_safety(&mut self, read: u8, write: u8)

Set how much of the file system the program may read and write.

Source

pub fn add_resource(&mut self, name: &str, data: &[u8])

Supply a resource for the program to open by name.

Source

pub fn close_files(&mut self)

Finish with every file at the end of the run.

Source§

impl Vm

Source

pub fn push_input_script( &mut self, data: &[u8], quiet: bool, pause_output: bool, )

Read input from a script before asking the player for any. The script is the contents of a command file: a line starting with > is a command, or, in a file that starts with the line <eventscript>, each line is an event such as <line>look.

Source§

impl Vm

Source

pub fn new(image: &Image, host: Box<dyn Host>) -> VmResult<Self>

Load a program image.

Source

pub fn set_image_name(&mut self, name: &str)

Record the name of the image file, which saved states carry so that a saved state can lead back to its program.

Source

pub fn run(&mut self, args: &[String]) -> VmResult<()>

Run the program to its end. The program sees args as the arguments of its main function.

This is for a host that can wait for the player. With one that cannot, use Vm::start and Vm::resume.

Source

pub fn start(&mut self, args: &[String]) -> VmResult<RunState>

Start the program, and run it until it ends or has to wait for the host. The program sees args as the arguments of its main function.

Source

pub fn resume(&mut self) -> VmResult<RunState>

Carry on with a program that stopped to wait for the host, until it ends or has to wait again.

Source

pub fn error_message( &mut self, error: &VmError, unhandled_prefix: bool, ) -> String

Describe an error that ended the program, in the reference VM’s words.

Source§

impl Vm

Source

pub fn set_runtime_symbols( &mut self, symbols: Vec<GlobalSymbol>, macros: Vec<Macro>, )

Give the program the compiler’s table of global symbols and of macros, for globalSymbols, as the compiler does for a program it runs before writing the image. The order is the order of the tables the program sees.

Source

pub fn run_preinit(&mut self, args: &[String]) -> VmResult<()>

Run the program as it is run before its image is written: with inPreinit() true, and with the arguments given.

Source

pub fn rewrite_image(&mut self, original: &[u8]) -> VmResult<RebuiltImage>

Write the program as it now stands as an image, given the image it was loaded from. This is what the reference does after preinitialization.

Source

pub fn rewrite_image_keeping( &mut self, original: &[u8], unspecified: &[(usize, usize)], ) -> VmResult<RebuiltImage>

The same, given the stretches of the image it was loaded from that mean nothing: those in the parts that are copied are carried over to where the parts go.

Source§

impl Vm

Source

pub fn seed_random(&mut self)

Seed the random number generator from the host’s entropy. Without this, every run of a program makes the same random choices.

Source§

impl Vm

Source

pub fn set_error_trace(&mut self, on: bool)

Report each VM error on standard error as it is raised, with the address of the instruction that caused it. This is a debugging aid for work on the VM itself.

Source

pub fn flush_output(&mut self)

Write out any text the console is holding for an unfinished line. Call this when the program ends.

Auto Trait Implementations§

§

impl !Freeze for Vm

§

impl !RefUnwindSafe for Vm

§

impl !Send for Vm

§

impl !Sync for Vm

§

impl !UnwindSafe for Vm

§

impl Forget for Vm

§

impl Move for Vm

§

impl Unpin for Vm
where Rc<[u8]>: Unpin, *const u8 is !null: Unpin, Rc<[ObjId]>: Unpin, Rc<[Value]>: Unpin, Box<Map>: Unpin, Rc<CharMap>: Unpin, Rc<StrComp>: Unpin, Box<GrammarRule>: Unpin, Box<Dictionary>: Unpin, Rc<Zone>: Unpin, Box<FileNameObj>: Unpin, Box<FileObj>: Unpin, Box<Big>: Unpin, Box<CompiledCode>: Unpin, Box<FrameRef>: Unpin, Rc<Pattern>: Unpin, *const LeafNode<u32, SetValZST> is !null: Unpin, Box<(u32, SetValZST)>: Unpin, Box<NativeCall>: Unpin, Box<[u8]>: Unpin, Box<Mt>: Unpin, Box<dyn Host>: Unpin,

§

impl UnsafeUnpin for Vm
where *const RcInner<[u8]> is !null: UnsafeUnpin, PhantomData<RcInner<[u8]>>: UnsafeUnpin, *const u8 is !null: UnsafeUnpin, PhantomData<Slot>: UnsafeUnpin, PhantomData<Vec<(u32, Object)>>: UnsafeUnpin, PhantomData<(u32, u32)>: UnsafeUnpin, *const LeafNode<u32, SetValZST> is !null: UnsafeUnpin, PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin, PhantomData<Box<(u32, SetValZST)>>: UnsafeUnpin, PhantomData<u32>: UnsafeUnpin, PhantomData<(u16, HashMap<u32, Option<(Value, ObjId)>, IdHash>)>: UnsafeUnpin, PhantomData<(u32, u32, u32)>: UnsafeUnpin, PhantomData<(u32, Value)>: UnsafeUnpin, PhantomData<(u32, Object)>: UnsafeUnpin, PhantomData<Object>: UnsafeUnpin, PhantomData<MetaEntry>: UnsafeUnpin, PhantomData<u16>: UnsafeUnpin, PhantomData<FunctionSet>: UnsafeUnpin, PhantomData<Value>: UnsafeUnpin, PhantomData<Frame>: UnsafeUnpin, PhantomData<(ObjId, u16)>: UnsafeUnpin, PhantomData<SourceFile>: UnsafeUnpin, PhantomData<GlobalSymbol>: UnsafeUnpin, PhantomData<Macro>: UnsafeUnpin, PhantomData<u8>: UnsafeUnpin, *const Mt is !null: UnsafeUnpin, PhantomData<Mt>: UnsafeUnpin, PhantomData<(Vec<u8>, Rc<Pattern>)>: UnsafeUnpin, PhantomData<char>: UnsafeUnpin, PhantomData<(String, usize)>: UnsafeUnpin, PhantomData<Script>: UnsafeUnpin, PhantomData<Option<LogFile>>: UnsafeUnpin, PhantomData<Option<Pane>>: UnsafeUnpin, PhantomData<ObjId>: UnsafeUnpin, PhantomData<(String, Rc<[u8]>)>: UnsafeUnpin, PhantomData<Listed>: UnsafeUnpin, PhantomData<(String, Vec<AbbrUse>)>: UnsafeUnpin, PhantomData<(String, Rc<Zone>)>: UnsafeUnpin, *const RcInner<Zone> is !null: UnsafeUnpin, PhantomData<RcInner<Zone>>: UnsafeUnpin, *const dyn Host is !null: UnsafeUnpin, PhantomData<dyn Host>: UnsafeUnpin,

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

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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.