2024-01-01 21:18:56 +01:00
|
|
|
use rpl::instructions::{FilterInstruction, Instruction};
|
|
|
|
|
2024-01-01 07:30:04 +01:00
|
|
|
use crate::{value::DynamicValue, Executor};
|
|
|
|
mod instructions;
|
|
|
|
|
|
|
|
pub struct DebugExecutor;
|
|
|
|
|
|
|
|
impl Executor for DebugExecutor {
|
2024-01-01 21:18:56 +01:00
|
|
|
fn execute(instruction: Instruction, input: Option<DynamicValue>) -> Option<DynamicValue> {
|
2024-01-01 07:30:04 +01:00
|
|
|
match instruction {
|
2024-01-01 21:18:56 +01:00
|
|
|
Instruction::Read(read_instruction) => Some(DynamicValue::Image(
|
|
|
|
instructions::read::read(read_instruction),
|
2024-01-01 07:30:04 +01:00
|
|
|
)),
|
2024-01-01 21:18:56 +01:00
|
|
|
Instruction::Write(write_instruction) => {
|
|
|
|
instructions::write::write(
|
2024-01-01 07:30:04 +01:00
|
|
|
write_instruction,
|
|
|
|
match input {
|
|
|
|
Some(DynamicValue::Image(img)) => img,
|
|
|
|
_ => panic!("awawwawwa"),
|
|
|
|
},
|
|
|
|
);
|
|
|
|
None
|
|
|
|
}
|
2024-01-01 21:18:56 +01: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 07:30:04 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|