From b92977d8f1734acbe2af0e28f69089739a2e75a5 Mon Sep 17 00:00:00 2001 From: Schrottkatze Date: Mon, 1 Jan 2024 07:30:04 +0100 Subject: [PATCH] basic conversion thing do worky!!! --- Cargo.lock | 532 +++++++++++++++++- Cargo.toml | 11 +- crates/executor/Cargo.toml | 3 + crates/executor/src/cpu/mod.rs | 1 + crates/executor/src/debug/instructions/mod.rs | 30 + crates/executor/src/debug/mod.rs | 30 + crates/executor/src/lib.rs | 42 +- crates/executor/src/value/mod.rs | 5 + crates/pl-cli/Cargo.toml | 3 + crates/pl-cli/src/main.rs | 20 +- crates/rpl/src/lib.rs | 2 +- crates/rpl/src/value/mod.rs | 3 + testfiles/bare.rpl | 12 + 13 files changed, 680 insertions(+), 14 deletions(-) create mode 100644 crates/executor/src/cpu/mod.rs create mode 100644 crates/executor/src/debug/instructions/mod.rs create mode 100644 crates/executor/src/debug/mod.rs create mode 100644 crates/executor/src/value/mod.rs create mode 100644 crates/rpl/src/value/mod.rs create mode 100644 testfiles/bare.rpl diff --git a/Cargo.lock b/Cargo.lock index 83c69ed..b0b723c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,12 +2,84 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + +[[package]] +name = "anstream" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d664a92ecae85fd0a7392615844904654d1d5f5514837f471ddef4a057aba1b6" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87" + +[[package]] +name = "anstyle-parse" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7" +dependencies = [ + "anstyle", + "windows-sys", +] + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + [[package]] name = "base64" version = "0.21.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9" +[[package]] +name = "bit_field" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc827186963e592360843fb5ba4b973e145841266c1357f7180c43526f2e5b61" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + [[package]] name = "bitflags" version = "2.4.1" @@ -17,13 +89,311 @@ dependencies = [ "serde", ] +[[package]] +name = "bytemuck" +version = "1.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "374d28ec25809ee0e23827c2ab573d729e293f281dfe393500e7ad618baa61c6" + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "clap" +version = "4.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcfab8ba68f3668e89f6ff60f5b205cea56aa7b769451a59f34b8682f51c056d" +dependencies = [ + "clap_builder", + "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb7fb5e4e979aec3be7791562fcba452f94ad85e954da024396433e0e25a79e9" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim", +] + +[[package]] +name = "clap_derive" +version = "4.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf9804afaaf59a91e75b022a30fb7229a7901f60c755489cc61c9b423b836442" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "clap_lex" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1" + +[[package]] +name = "color_quant" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" + +[[package]] +name = "colorchoice" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" + +[[package]] +name = "crc32fast" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "crossbeam-deque" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fca89a0e215bab21874660c67903c5f143333cab1da83d041c7ded6053774751" +dependencies = [ + "cfg-if", + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e3681d554572a651dda4186cd47240627c3d0114d45a95f6ad27f2f22e7548d" +dependencies = [ + "autocfg", + "cfg-if", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3a430a770ebd84726f584a90ee7f020d28db52c6d02138900f22341f866d39c" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "crunchy" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" + +[[package]] +name = "either" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" + [[package]] name = "executor" version = "0.1.0" +dependencies = [ + "clap", + "image", + "rpl", +] + +[[package]] +name = "exr" +version = "1.71.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "832a761f35ab3e6664babfbdc6cef35a4860e816ec3916dcfd0882954e98a8a8" +dependencies = [ + "bit_field", + "flume", + "half", + "lebe", + "miniz_oxide", + "rayon-core", + "smallvec", + "zune-inflate", +] + +[[package]] +name = "fdeflate" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "209098dd6dfc4445aa6111f0e98653ac323eaa4dfd212c9ca3931bf9955c31bd" +dependencies = [ + "simd-adler32", +] + +[[package]] +name = "flate2" +version = "1.0.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46303f565772937ffe1d394a4fac6f411c6013172fadde9dcdb1e147a086940e" +dependencies = [ + "crc32fast", + "miniz_oxide", +] + +[[package]] +name = "flume" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55ac459de2512911e4b674ce33cf20befaba382d05b62b008afc1c8b57cbf181" +dependencies = [ + "spin", +] + +[[package]] +name = "gif" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80792593675e051cf94a4b111980da2ba60d4a83e43e0048c5693baab3977045" +dependencies = [ + "color_quant", + "weezl", +] + +[[package]] +name = "half" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02b4af3693f1b705df946e9fe5631932443781d0aabb423b62fcd4d73f6d2fd0" +dependencies = [ + "crunchy", +] + +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" + +[[package]] +name = "image" +version = "0.24.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f3dfdbdd72063086ff443e297b61695500514b1e41095b6fb9a5ab48a70a711" +dependencies = [ + "bytemuck", + "byteorder", + "color_quant", + "exr", + "gif", + "jpeg-decoder", + "num-rational", + "num-traits", + "png", + "qoi", + "tiff", +] + +[[package]] +name = "jpeg-decoder" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc0000e42512c92e31c2252315bda326620a4e034105e900c98ec492fa077b3e" +dependencies = [ + "rayon", +] + +[[package]] +name = "lebe" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03087c2bad5e1034e8cace5926dec053fb3790248370865f5117a7d0213354c8" + +[[package]] +name = "lock_api" +version = "0.4.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "miniz_oxide" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" +dependencies = [ + "adler", + "simd-adler32", +] + +[[package]] +name = "num-integer" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +dependencies = [ + "autocfg", + "num-traits", +] + +[[package]] +name = "num-rational" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" +dependencies = [ + "autocfg", +] [[package]] name = "pl-cli" version = "0.1.0" +dependencies = [ + "clap", + "executor", + "rpl", +] + +[[package]] +name = "png" +version = "0.17.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd75bf2d8dd3702b9707cdbc56a5b9ef42cec752eb8b3bafc01234558442aa64" +dependencies = [ + "bitflags 1.3.2", + "crc32fast", + "fdeflate", + "flate2", + "miniz_oxide", +] [[package]] name = "proc-macro2" @@ -34,6 +404,15 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "qoi" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f6d64c71eb498fe9eae14ce4ec935c555749aef511cca85b5568910d6e48001" +dependencies = [ + "bytemuck", +] + [[package]] name = "quote" version = "1.0.33" @@ -43,6 +422,26 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "rayon" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c27db03db7734835b3f53954b534c91069375ce6ccaa2e065441e07d9b6cdb1" +dependencies = [ + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ce3fb6ad83f861aac485e76e1985cd109d9a3713802152be56c3b1f0e0658ed" +dependencies = [ + "crossbeam-deque", + "crossbeam-utils", +] + [[package]] name = "ron" version = "0.8.1" @@ -50,7 +449,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b91f7eff05f748767f183df4320a63d6936e9c6107d97c9e6bdd9784f4289c94" dependencies = [ "base64", - "bitflags", + "bitflags 2.4.1", "serde", "serde_derive", ] @@ -63,6 +462,12 @@ dependencies = [ "serde", ] +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + [[package]] name = "serde" version = "1.0.193" @@ -83,6 +488,33 @@ dependencies = [ "syn", ] +[[package]] +name = "simd-adler32" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe" + +[[package]] +name = "smallvec" +version = "1.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" + +[[package]] +name = "spin" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" +dependencies = [ + "lock_api", +] + +[[package]] +name = "strsim" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" + [[package]] name = "syn" version = "2.0.41" @@ -94,8 +526,106 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "tiff" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d172b0f4d3fba17ba89811858b9d3d97f928aece846475bbda076ca46736211" +dependencies = [ + "flate2", + "jpeg-decoder", + "weezl", +] + [[package]] name = "unicode-ident" version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "utf8parse" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" + +[[package]] +name = "weezl" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9193164d4de03a926d909d3bc7c30543cecb35400c02114792c2cae20d5e2dbb" + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" + +[[package]] +name = "zune-inflate" +version = "0.2.54" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73ab332fe2f6680068f3582b16a24f90ad7096d5d39b974d1c0aff0125116f02" +dependencies = [ + "simd-adler32", +] diff --git a/Cargo.toml b/Cargo.toml index d5fdd00..6aa4943 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,4 +1,13 @@ -workspace = { members = [ "crates/executor", "crates/pl-cli","crates/rpl"] } +[workspace] +members = [ + "crates/executor", + "crates/pl-cli", + "crates/rpl" +] +resolver = "2" + +[workspace.dependencies] +clap = { version = "4", features = [ "derive" ] } [lints.rust] unsafe_code = "deny" diff --git a/crates/executor/Cargo.toml b/crates/executor/Cargo.toml index cd74c92..fc01c27 100644 --- a/crates/executor/Cargo.toml +++ b/crates/executor/Cargo.toml @@ -6,3 +6,6 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +clap = { workspace = true, features = [ "derive" ] } +image = "0.24" +rpl = { path = "../rpl" } diff --git a/crates/executor/src/cpu/mod.rs b/crates/executor/src/cpu/mod.rs new file mode 100644 index 0000000..e82d20a --- /dev/null +++ b/crates/executor/src/cpu/mod.rs @@ -0,0 +1 @@ +pub(crate) struct CpuExecutor; diff --git a/crates/executor/src/debug/instructions/mod.rs b/crates/executor/src/debug/instructions/mod.rs new file mode 100644 index 0000000..85ec631 --- /dev/null +++ b/crates/executor/src/debug/instructions/mod.rs @@ -0,0 +1,30 @@ +pub mod Read { + use image::{io::Reader as ImageReader, DynamicImage}; + use rpl::instructions::read::{Read, SourceType}; + + pub fn read(Read { source, format }: Read) -> DynamicImage { + let mut img = ImageReader::open(match source { + SourceType::File(path) => path, + }) + .expect("something went wrong :((("); + + img.decode().expect("couldn't decode image") + } +} + +pub mod Write { + use image::{io::Reader as ImageReader, DynamicImage, ImageFormat}; + use rpl::instructions::write::{TargetFormat, TargetType, Write}; + + pub fn write(Write { target, format }: Write, input_data: DynamicImage) { + input_data.save_with_format( + match target { + TargetType::File(path) => path, + }, + match format { + TargetFormat::Jpeg => ImageFormat::Jpeg, + TargetFormat::Png => ImageFormat::Png, + }, + ); + } +} diff --git a/crates/executor/src/debug/mod.rs b/crates/executor/src/debug/mod.rs new file mode 100644 index 0000000..61cae27 --- /dev/null +++ b/crates/executor/src/debug/mod.rs @@ -0,0 +1,30 @@ +use crate::{value::DynamicValue, Executor}; +mod instructions; + +pub struct DebugExecutor; + +impl Executor for DebugExecutor { + fn execute( + instruction: rpl::instructions::Instruction, + input: Option, + ) -> Option { + match instruction { + rpl::instructions::Instruction::Read(read_instruction) => Some(DynamicValue::Image( + instructions::Read::read(read_instruction), + )), + rpl::instructions::Instruction::Write(write_instruction) => { + instructions::Write::write( + write_instruction, + match input { + Some(DynamicValue::Image(img)) => img, + _ => panic!("awawwawwa"), + }, + ); + None + } + rpl::instructions::Instruction::Math(_) => todo!(), + rpl::instructions::Instruction::Blend(_) => todo!(), + rpl::instructions::Instruction::Noise(_) => todo!(), + } + } +} diff --git a/crates/executor/src/lib.rs b/crates/executor/src/lib.rs index 7d12d9a..fb55029 100644 --- a/crates/executor/src/lib.rs +++ b/crates/executor/src/lib.rs @@ -1,14 +1,38 @@ -pub fn add(left: usize, right: usize) -> usize { - left + right +use rpl::instructions::Instruction; +use value::DynamicValue; + +mod debug; +mod value; + +/// The available executors +/// unused in early dev. +#[derive(Debug, Clone, Copy, clap::ValueEnum)] +pub enum Executors { + /// the debug executor is single threaded and really, *really* slow. And unstable. Don't use. Unless you're a dev working on this. + Debug, + /// the CPU executor primarily uses the CPU. Most likely most feature complete, and the fallback. + Cpu, + /// the Vulkan executor (obviously) uses vulkan. there's a good chance this isn't implemented yet as you're reading this. + Vulkan, } -#[cfg(test)] -mod tests { - use super::*; +trait Executor { + fn execute(instruction: Instruction, input: Option) -> Option; +} - #[test] - fn it_works() { - let result = add(2, 2); - assert_eq!(result, 4); +pub fn execute_all(instructions: Vec) { + let mut tmp = None; + + for instruction in instructions { + tmp = debug::DebugExecutor::execute(instruction, tmp); } } + +// 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 diff --git a/crates/executor/src/value/mod.rs b/crates/executor/src/value/mod.rs new file mode 100644 index 0000000..daf0dd2 --- /dev/null +++ b/crates/executor/src/value/mod.rs @@ -0,0 +1,5 @@ +use image::DynamicImage; + +pub enum DynamicValue { + Image(DynamicImage), +} diff --git a/crates/pl-cli/Cargo.toml b/crates/pl-cli/Cargo.toml index d4b95e9..e6f8cc8 100644 --- a/crates/pl-cli/Cargo.toml +++ b/crates/pl-cli/Cargo.toml @@ -6,3 +6,6 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +clap = { workspace = true, features = [ "derive" ] } +rpl = { path = "../rpl" } +executor = { path = "../executor" } diff --git a/crates/pl-cli/src/main.rs b/crates/pl-cli/src/main.rs index e7a11a9..9e84d33 100644 --- a/crates/pl-cli/src/main.rs +++ b/crates/pl-cli/src/main.rs @@ -1,3 +1,19 @@ -fn main() { - println!("Hello, world!"); +use std::{fs, path::PathBuf}; + +use clap::Parser; +use executor::{execute_all, Executors}; + +#[derive(Parser, Debug)] +pub struct Args { + file: PathBuf, + primary_executor: Executors, +} + +fn main() { + let args = dbg!(Args::parse()); + + let f = fs::read_to_string(args.file).unwrap(); + let pl = rpl::from_ron(&f); + + execute_all(pl.0); } diff --git a/crates/rpl/src/lib.rs b/crates/rpl/src/lib.rs index c5102f3..dbecd0a 100644 --- a/crates/rpl/src/lib.rs +++ b/crates/rpl/src/lib.rs @@ -14,7 +14,7 @@ pub fn from_ron(raw: &str) -> Rpl { } #[derive(Serialize, Deserialize, PartialEq, Eq, Debug)] -pub struct Rpl(Vec); +pub struct Rpl(pub Vec); #[test] fn test_simple_deserialize() { diff --git a/crates/rpl/src/value/mod.rs b/crates/rpl/src/value/mod.rs new file mode 100644 index 0000000..238b9c2 --- /dev/null +++ b/crates/rpl/src/value/mod.rs @@ -0,0 +1,3 @@ +pub enum DynamicValue { + Image(DynamicImage), +} diff --git a/testfiles/bare.rpl b/testfiles/bare.rpl new file mode 100644 index 0000000..1770e37 --- /dev/null +++ b/testfiles/bare.rpl @@ -0,0 +1,12 @@ +( + [ + Read(( + source: File("/home/jade/example/file.png"), + format: Png + )), + Write(( + target: File("/home/jade/example/out.jpg"), + format: Jpeg + )) + ] +)