pub mod cmd;
pub mod error;
pub mod model;
pub mod repr;
use std::ops::Deref;
pub use model::State;
use crate::{Script, aux::NotOrd};
#[derive(NotOrd!, Default)]
pub struct Runtime {
state: State,
}
impl Runtime {
pub fn state(&self) -> &State {
&self.state
}
pub fn to_state(self) -> State {
self.state
}
}
impl Runtime {
pub fn new() -> Self {
Self::default()
}
pub fn run(&mut self, script: Script) -> Result<(), error::Repr> {
for stmt in script.0 {
let cmd = self.repr(stmt)?;
self.fulfil(cmd);
}
Ok(())
}
}
impl Deref for Runtime {
type Target = State;
fn deref(&self) -> &Self::Target {
&self.state
}
}