iowo/crates/eval/src/lib.rs

35 lines
849 B
Rust
Raw Normal View History

use ir::instruction::Kind;
use value::Dynamic;
2024-01-01 06:30:04 +00:00
mod debug;
mod value;
/// The available executors
/// unused in early dev.
#[derive(Debug, Clone, Copy, clap::ValueEnum)]
pub enum RegisteredExecutor {
2024-01-01 06:30:04 +00:00
/// the debug executor is single threaded and really, *really* slow. And unstable. Don't use. Unless you're a dev working on this.
Debug,
2023-12-13 17:13:43 +00:00
}
2024-01-01 06:30:04 +00:00
trait Executor {
fn execute(instruction: Kind, input: Option<Dynamic>) -> Option<Dynamic>;
2024-01-01 06:30:04 +00:00
}
2023-12-13 17:13:43 +00:00
pub fn execute_all(instructions: Vec<Kind>) {
2024-01-01 06:30:04 +00:00
let mut tmp = None;
for instruction in instructions {
tmp = debug::Executor::execute(instruction, tmp);
2023-12-13 17:13:43 +00:00
}
}
2024-01-01 06:30:04 +00:00
// scratchpad lol:
// execution structure:
// 1. take in rpl
// 2. analyse/validate structure against allowed executors
// 3. assign executors to instructions
// 4. optimize
// 5. prepare memory management patterns
// 6. run