iowo/crates/executor/src/debug/mod.rs

38 lines
1.4 KiB
Rust
Raw Normal View History

2024-01-01 20:18:56 +00:00
use rpl::instructions::{FilterInstruction, Instruction};
2024-01-01 06:30:04 +00:00
use crate::{value::DynamicValue, Executor};
mod instructions;
pub struct DebugExecutor;
impl Executor for DebugExecutor {
2024-01-01 20:18:56 +00:00
fn execute(instruction: Instruction, input: Option<DynamicValue>) -> Option<DynamicValue> {
2024-01-01 06:30:04 +00:00
match instruction {
2024-01-01 20:18:56 +00:00
Instruction::Read(read_instruction) => Some(DynamicValue::Image(
instructions::read::read(read_instruction),
2024-01-01 06:30:04 +00:00
)),
2024-01-01 20:18:56 +00:00
Instruction::Write(write_instruction) => {
instructions::write::write(
2024-01-01 06:30:04 +00:00
write_instruction,
match input {
Some(DynamicValue::Image(img)) => img,
_ => panic!("awawwawwa"),
},
);
None
}
2024-01-01 20:18:56 +00:00
Instruction::Math(_) => todo!(),
Instruction::Blend(_) => todo!(),
Instruction::Noise(_) => todo!(),
Instruction::Filter(filter_instruction) => match filter_instruction {
FilterInstruction::Invert => Some(DynamicValue::Image(
instructions::filters::invert::invert(match input {
Some(DynamicValue::Image(img)) => img,
_ => panic!("invalid value type for invert"),
}),
)),
},
2024-01-01 06:30:04 +00:00
}
}
}