forked from katzen-cafe/iowo
37 lines
1.3 KiB
Rust
37 lines
1.3 KiB
Rust
use rpl::instructions::{FilterInstruction, Instruction};
|
|
|
|
use crate::value::Dynamic;
|
|
mod instructions;
|
|
|
|
pub struct Executor;
|
|
|
|
impl crate::Executor for Executor {
|
|
fn execute(instruction: Instruction, input: Option<Dynamic>) -> Option<Dynamic> {
|
|
match instruction {
|
|
Instruction::Read(read_instruction) => {
|
|
Some(Dynamic::Image(instructions::read::read(read_instruction)))
|
|
}
|
|
Instruction::Write(write_instruction) => {
|
|
instructions::write::write(
|
|
write_instruction,
|
|
match input {
|
|
Some(Dynamic::Image(ref img)) => img,
|
|
_ => panic!("awawwawwa"),
|
|
},
|
|
);
|
|
None
|
|
}
|
|
Instruction::Math(_) => todo!(),
|
|
Instruction::Blend(_) => todo!(),
|
|
Instruction::Noise(_) => todo!(),
|
|
Instruction::Filter(filter_instruction) => match filter_instruction {
|
|
FilterInstruction::Invert => Some(Dynamic::Image(
|
|
instructions::filters::invert::invert(match input {
|
|
Some(Dynamic::Image(img)) => img,
|
|
_ => panic!("invalid value type for invert"),
|
|
}),
|
|
)),
|
|
},
|
|
}
|
|
}
|
|
}
|