feat(ir): replace Rpl with GraphIr
Semi-broken as atm the CLI just does nothing except printing the parsed IR, instead of actually executing it.
This commit is contained in:
parent
ccbccfb11b
commit
fcf7e909ee
14 changed files with 198 additions and 143 deletions
|
@ -8,7 +8,7 @@ edition = "2021"
|
|||
[dependencies]
|
||||
clap = { workspace = true, features = [ "derive" ] }
|
||||
image = "0.24"
|
||||
rpl = { path = "../rpl" }
|
||||
ir = { path = "../ir" }
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
pub mod read {
|
||||
use image::{io::Reader as ImageReader, DynamicImage};
|
||||
use rpl::instructions::read::{Read, SourceType};
|
||||
use ir::instruction::read::{Read, SourceType};
|
||||
|
||||
pub fn read(Read { source, .. }: Read) -> DynamicImage {
|
||||
// TODO: actual error handling
|
||||
|
@ -15,7 +15,7 @@ pub mod read {
|
|||
|
||||
pub mod write {
|
||||
use image::{DynamicImage, ImageFormat};
|
||||
use rpl::instructions::write::{TargetFormat, TargetType, Write};
|
||||
use ir::instruction::write::{TargetFormat, TargetType, Write};
|
||||
|
||||
pub fn write(Write { target, format }: Write, input_data: &DynamicImage) {
|
||||
input_data
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use rpl::instructions::{Filter, Instruction};
|
||||
use ir::instruction::{Filter, Kind};
|
||||
|
||||
use crate::value::Dynamic;
|
||||
mod instructions;
|
||||
|
@ -6,12 +6,12 @@ mod instructions;
|
|||
pub struct Executor;
|
||||
|
||||
impl crate::Executor for Executor {
|
||||
fn execute(instruction: Instruction, input: Option<Dynamic>) -> Option<Dynamic> {
|
||||
fn execute(instruction: Kind, input: Option<Dynamic>) -> Option<Dynamic> {
|
||||
match instruction {
|
||||
Instruction::Read(read_instruction) => {
|
||||
Kind::Read(read_instruction) => {
|
||||
Some(Dynamic::Image(instructions::read::read(read_instruction)))
|
||||
}
|
||||
Instruction::Write(write_instruction) => {
|
||||
Kind::Write(write_instruction) => {
|
||||
instructions::write::write(
|
||||
write_instruction,
|
||||
match input {
|
||||
|
@ -21,10 +21,10 @@ impl crate::Executor for Executor {
|
|||
);
|
||||
None
|
||||
}
|
||||
Instruction::Math(_) => todo!(),
|
||||
Instruction::Blend(_) => todo!(),
|
||||
Instruction::Noise(_) => todo!(),
|
||||
Instruction::Filter(filter_instruction) => match filter_instruction {
|
||||
Kind::Math(_) => todo!(),
|
||||
Kind::Blend(_) => todo!(),
|
||||
Kind::Noise(_) => todo!(),
|
||||
Kind::Filter(filter_instruction) => match filter_instruction {
|
||||
Filter::Invert => Some(Dynamic::Image(instructions::filters::invert::invert(
|
||||
match input {
|
||||
Some(Dynamic::Image(img)) => img,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use rpl::instructions::Instruction;
|
||||
use ir::instruction::Kind;
|
||||
use value::Dynamic;
|
||||
|
||||
mod debug;
|
||||
|
@ -17,10 +17,10 @@ pub enum Executors {
|
|||
}
|
||||
|
||||
trait Executor {
|
||||
fn execute(instruction: Instruction, input: Option<Dynamic>) -> Option<Dynamic>;
|
||||
fn execute(instruction: Kind, input: Option<Dynamic>) -> Option<Dynamic>;
|
||||
}
|
||||
|
||||
pub fn execute_all(instructions: Vec<Instruction>) {
|
||||
pub fn execute_all(instructions: Vec<Kind>) {
|
||||
let mut tmp = None;
|
||||
|
||||
for instruction in instructions {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue