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
impl Machine
Sourcefn read_in_state(&self, place: &Location) -> Option<Value>
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.
Sourcepub(crate) fn locate(
&self,
place: &Place,
frame: &mut Vec<Slot>,
) -> Result<Location, RuntimeError>
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.
pub(crate) fn read( &self, location: &Location, frame: &Vec<Slot>, span: Span, ) -> Result<Value, RuntimeError>
pub(crate) fn write( &self, location: &Location, frame: &mut Vec<Slot>, value: Value, span: Span, ) -> Result<(), RuntimeError>
Sourcepub(crate) fn write_state(
&self,
location: &Location,
value: Value,
span: Span,
) -> Result<(), RuntimeError>
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.
Sourcepub(crate) fn modify<R>(
&self,
location: &Location,
frame: &mut Vec<Slot>,
span: Span,
change: impl FnOnce(&mut Value) -> Result<R, RuntimeError>,
) -> Result<R, RuntimeError>
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.
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
impl Machine
Source§impl Machine
impl Machine
Sourcepub(crate) fn new(
program: Rc<Program>,
previous: Option<&Machine>,
) -> Result<Self, RuntimeError>
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.
pub(crate) fn program(&self) -> &Rc<Program>
Sourcepub(crate) fn take_changed(&self) -> StateSet
pub(crate) fn take_changed(&self) -> StateSet
The states changed since the last call.
Sourcepub(crate) fn take_downloads(&self) -> Vec<Request<Targets>>
pub(crate) fn take_downloads(&self) -> Vec<Request<Targets>>
The downloads asked for since the last call.
Sourcepub(crate) fn take_download_commands(&self) -> Vec<(DownloadCommand, String)>
pub(crate) fn take_download_commands(&self) -> Vec<(DownloadCommand, String)>
What code asked of running downloads since the last call, in order.
Sourcepub(crate) fn take_dialogs(&self) -> Vec<(FileDialog, Answer)>
pub(crate) fn take_dialogs(&self) -> Vec<(FileDialog, Answer)>
The file dialogs asked for since the last call.
Sourcepub(crate) fn take_window_requests(&self) -> Vec<WindowRequest>
pub(crate) fn take_window_requests(&self) -> Vec<WindowRequest>
The windows asked to open or close since the last call, in order.
Sourcepub(crate) fn answer_dialog(
&self,
answer: &Answer,
picked: Picked,
) -> Result<(), RuntimeError>
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.
Sourcefn ask_dialog(
&self,
dialog: &Dialog,
frame: &mut Vec<Slot>,
span: Span,
) -> Result<(), RuntimeError>
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.
Sourcepub(crate) fn report_download(
&self,
targets: &Targets,
report: &Report,
) -> Result<(), RuntimeError>
pub(crate) fn report_download( &self, targets: &Targets, report: &Report, ) -> Result<(), RuntimeError>
Writes a download’s report into the state its call bound.
Sourcepub(crate) fn follow_download(&self, targets: &mut Targets) -> bool
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.
Sourcefn request_download(
&self,
download: &Download,
frame: &mut Vec<Slot>,
span: Span,
) -> Result<(), RuntimeError>
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.
pub(crate) fn eval( &self, expr: &Expr, frame: &mut Vec<Slot>, ) -> Result<Value, RuntimeError>
fn eval_all( &self, exprs: &[Expr], frame: &mut Vec<Slot>, ) -> Result<Vec<Value>, RuntimeError>
fn read_local( &self, local: LocalId, frame: &Vec<Slot>, span: Span, ) -> Result<Value, RuntimeError>
fn binary_expr( &self, op: BinaryOp, lhs: &Expr, rhs: &Expr, frame: &mut Vec<Slot>, span: Span, ) -> Result<Value, RuntimeError>
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.
impl StateReader for Machine
Reads state without a frame, for finding where a download’s id went.