Skip to main content

Machine

Struct Machine 

Source
pub(crate) struct Machine {
    program: Rc<Program>,
    states: RefCell<Vec<Value>>,
    changed: RefCell<StateSet>,
    downloads: RefCell<Vec<Request<Targets>>>,
    download_commands: RefCell<Vec<(DownloadCommand, String)>>,
    dialogs: RefCell<Vec<(FileDialog, Answer)>>,
    window_requests: RefCell<Vec<WindowRequest>>,
    call_depth: Cell<usize>,
}

Fields§

§program: Rc<Program>§states: RefCell<Vec<Value>>§changed: RefCell<StateSet>

States changed since the UI last caught up.

§downloads: RefCell<Vec<Request<Targets>>>

Downloads asked for since the app last started them.

§download_commands: RefCell<Vec<(DownloadCommand, String)>>

What code asked of running downloads since the app last passed it on, by their ids.

§dialogs: RefCell<Vec<(FileDialog, Answer)>>

File dialogs asked for since the app last passed them on.

§window_requests: RefCell<Vec<WindowRequest>>

Windows asked to open or close since the app last passed them on.

§call_depth: Cell<usize>

Implementations§

Source§

impl Machine

Source

fn read_in_state(&self, place: &Location) -> Option<Value>

The value at place in state; None when it is a variable’s, or no longer exists.

Source

pub(crate) fn locate( &self, place: &Place, frame: &mut Vec<Slot>, ) -> Result<Location, RuntimeError>

Resolves place against frame, following for variables to the item they alias.

Source

pub(crate) fn read( &self, location: &Location, frame: &Vec<Slot>, span: Span, ) -> Result<Value, RuntimeError>

Source

pub(crate) fn write( &self, location: &Location, frame: &mut Vec<Slot>, value: Value, span: Span, ) -> Result<(), RuntimeError>

Source

pub(crate) fn write_state( &self, location: &Location, value: Value, span: Span, ) -> Result<(), RuntimeError>

Writes to a location in state, which needs no frame.

§Panics

When the location is a variable’s; check Location::is_in_state first.

Source

pub(crate) fn modify<R>( &self, location: &Location, frame: &mut Vec<Slot>, span: Span, change: impl FnOnce(&mut Value) -> Result<R, RuntimeError>, ) -> Result<R, RuntimeError>

Changes the value at location in place, marking its state changed.

Source

fn modify_state<R>( &self, state: StateId, path: &[Step], span: Span, change: impl FnOnce(&mut Value) -> Result<R, RuntimeError>, ) -> Result<R, RuntimeError>

Source§

impl Machine

Source

pub(crate) fn exec_block( &self, block: &[Stmt], frame: &mut Vec<Slot>, ) -> Result<Flow, RuntimeError>

Source

fn exec(&self, stmt: &Stmt, frame: &mut Vec<Slot>) -> Result<Flow, RuntimeError>

Source§

impl Machine

Source

pub(crate) fn walk( &self, iterable: &Iterable, frame: &mut Vec<Slot>, ) -> Result<Walk, RuntimeError>

Source

pub(crate) fn enter_round( &self, head: &Loop, walk: &Walk, (position, index): (usize, i64), frame: &mut Vec<Slot>, ) -> Result<bool, RuntimeError>

Puts the loop’s variables for the round at position in frame, or returns false once the walk is over.

Source§

impl Machine

Source

pub(crate) fn new( program: Rc<Program>, previous: Option<&Machine>, ) -> Result<Self, RuntimeError>

Sets every state to its starting value, or to its value in previous when it still fits there.

Source

pub(crate) fn program(&self) -> &Rc<Program>

Source

pub(crate) fn take_changed(&self) -> StateSet

The states changed since the last call.

Source

pub(crate) fn take_downloads(&self) -> Vec<Request<Targets>>

The downloads asked for since the last call.

Source

pub(crate) fn take_download_commands(&self) -> Vec<(DownloadCommand, String)>

What code asked of running downloads since the last call, in order.

Source

pub(crate) fn take_dialogs(&self) -> Vec<(FileDialog, Answer)>

The file dialogs asked for since the last call.

Source

pub(crate) fn take_window_requests(&self) -> Vec<WindowRequest>

The windows asked to open or close since the last call, in order.

Source

pub(crate) fn answer_dialog( &self, answer: &Answer, picked: Picked, ) -> Result<(), RuntimeError>

Writes the path or paths the user picked into the state the dialog’s call bound; cancelling changes nothing.

Source

fn ask_dialog( &self, dialog: &Dialog, frame: &mut Vec<Slot>, span: Span, ) -> Result<(), RuntimeError>

Asks for a file dialog, shown once the current event finishes.

Source

pub(crate) fn report_download( &self, targets: &Targets, report: &Report, ) -> Result<(), RuntimeError>

Writes a download’s report into the state its call bound.

Source

pub(crate) fn follow_download(&self, targets: &mut Targets) -> bool

Moves a download’s targets to where the item holding its id is now; false when nothing holds it any more.

Source

fn request_download( &self, download: &Download, frame: &mut Vec<Slot>, span: Span, ) -> Result<(), RuntimeError>

Queues a download for the app to start once the current event finishes, and shows that it has begun.

Source

pub(crate) fn eval( &self, expr: &Expr, frame: &mut Vec<Slot>, ) -> Result<Value, RuntimeError>

Source

fn eval_all( &self, exprs: &[Expr], frame: &mut Vec<Slot>, ) -> Result<Vec<Value>, RuntimeError>

Source

fn read_local( &self, local: LocalId, frame: &Vec<Slot>, span: Span, ) -> Result<Value, RuntimeError>

Source

fn binary_expr( &self, op: BinaryOp, lhs: &Expr, rhs: &Expr, frame: &mut Vec<Slot>, span: Span, ) -> Result<Value, RuntimeError>

Source

pub(crate) fn call( &self, function: FnId, args: &[Expr], frame: &mut Vec<Slot>, span: Span, ) -> Result<Value, RuntimeError>

Trait Implementations§

Source§

impl StateReader for Machine

Reads state without a frame, for finding where a download’s id went.

Source§

type Place = Location

Source§

fn list_len(&self, place: &Location) -> Option<usize>

How many items the list at place has; None when there’s no such place.
Source§

fn holds_text(&self, place: &Location, text: &str) -> bool

Whether the text at place is text; false when there’s no such place.

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

Source§

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

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.