From e6bc5b146d8d3783d269fe520e80c315f6ae0f92 Mon Sep 17 00:00:00 2001 From: William Dussault Date: Tue, 24 Feb 2026 21:38:56 -0500 Subject: [PATCH] chore: modernize repo --- .github/workflows/ci.yml | 32 +++++--------------- .github/workflows/coverage.yml | 23 +++++++------- .github/workflows/release.yml | 40 ------------------------- Cargo.toml | 1 + argot/Cargo.toml | 12 ++++---- argot/src/argot/compiler/first_pass.rs | 2 ++ argot/src/argot/compiler/label.rs | 8 ++--- argot/src/argot/compiler/scope.rs | 2 +- argot/src/argot/compiler/second_pass.rs | 2 +- argot/src/argot/syntax/operator.rs | 10 +++---- argot/src/main.rs | 2 +- assembler/Cargo.toml | 8 ++--- instructor/Cargo.toml | 4 +-- instructor/src/instruction.rs | 2 +- justfile | 22 ++++++-------- slang-cli/Cargo.toml | 8 ++--- slang-cli/src/cli.rs | 2 +- vm/Cargo.toml | 10 +++---- vm/src/loader.rs | 3 +- vm/src/memutil.rs | 2 +- vm/src/stack.rs | 4 +-- 21 files changed, 71 insertions(+), 128 deletions(-) delete mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1e8c169..7386a65 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,31 +1,15 @@ name: CI -on: - push: {} +on: [push, pull_request] jobs: - bazel: + test: runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - - - name: Mount build cache - uses: actions/cache@v1 - with: - path: "target" - key: slang-cache - - - name: Test - uses: actions-rs/cargo@v1 - with: - command: test - - - name: Lint - uses: actions-rs/cargo@v1 + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable with: - command: clippy - args: --all-features + components: clippy + - uses: Swatinem/rust-cache@v2 + - run: cargo test + - run: cargo clippy --all-features -- -D warnings diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 04aa5c7..ff46e27 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -8,27 +8,26 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Install stable toolchain - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - override: true + uses: dtolnay/rust-toolchain@stable + + - uses: Swatinem/rust-cache@v2 + + - name: Install cargo-tarpaulin + run: cargo install cargo-tarpaulin - name: Run cargo-tarpaulin - uses: actions-rs/tarpaulin@v0.1 + run: cargo tarpaulin --out xml env: RUST_LOG: trace - with: - version: '0.9.0' - args: '-- --test-threads 1' - name: Upload to codecov.io - uses: codecov/codecov-action@v1.0.7 + uses: codecov/codecov-action@v5 - name: Archive code coverage results - uses: actions/upload-artifact@v1 + uses: actions/upload-artifact@v4 with: name: code-coverage-report - path: cobertura.xml \ No newline at end of file + path: cobertura.xml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 7c71ddb..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: Validate & Release -on: - push: - tags: - - "v*" - -jobs: - build: - name: Release - runs-on: ubuntu-latest - steps: - - name: Check out code - uses: actions/checkout@v2 - - name: Install latest stable - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - override: true - - name: Bootstrap Landlord - run: | - sudo wget https://github.com/purposed/landlord/releases/download/v0.1.7/landlord-linux-amd64.zip -O /usr/local/bin/landlord.zip - cd /usr/local/bin && sudo unzip landlord.zip - sudo mv /usr/local/bin/landlord-linux-amd64 /usr/local/bin/landlord - sudo chmod +x /usr/local/bin/landlord - - name: Mount build cache - uses: actions/cache@v1 - with: - path: "target" - key: slang-cache - - name: Landlord Release - run: | - landlord validate - landlord release --nozip - - name: Release - uses: docker://softprops/action-gh-release - if: startsWith(github.ref, 'refs/tags/') - with: - files: artifacts/linux-amd64/* - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml index 8e7677c..7ce13e8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,4 +1,5 @@ [workspace] +resolver = "3" members = [ "argot", "assembler", diff --git a/argot/Cargo.toml b/argot/Cargo.toml index 516accf..88a72f0 100644 --- a/argot/Cargo.toml +++ b/argot/Cargo.toml @@ -2,7 +2,7 @@ name = "argot" version = "0.1.2" authors = ["William Dussault "] -edition = "2018" +edition = "2024" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -15,12 +15,12 @@ name = "argot" path = "src/argot/lib.rs" [dependencies] -anyhow = "1.0" -clap = {version = "4.0.18", features = ["derive"]} +anyhow = "1" +clap = {version = "4", features = ["derive"]} assembler = {path = "../assembler"} -env_logger = "0.9" -log = {version = "0.4.8", features = ["std"]} +env_logger = "0.11" +log = {version = "0.4", features = ["std"]} instructor = {path = "../instructor"} nom = "7" -snafu = "0.7.0" +snafu = "0.8" diff --git a/argot/src/argot/compiler/first_pass.rs b/argot/src/argot/compiler/first_pass.rs index 3e6f024..7c7bc81 100644 --- a/argot/src/argot/compiler/first_pass.rs +++ b/argot/src/argot/compiler/first_pass.rs @@ -8,8 +8,10 @@ use crate::syntax::types::{Argument, FunctionDeclaration, Program}; #[derive(Clone, Debug)] pub struct FunctionDecl { + #[allow(dead_code)] pub name: String, pub arguments: Vec, + #[allow(dead_code)] pub return_type: String, } diff --git a/argot/src/argot/compiler/label.rs b/argot/src/argot/compiler/label.rs index 4918fb3..d4c231d 100644 --- a/argot/src/argot/compiler/label.rs +++ b/argot/src/argot/compiler/label.rs @@ -25,13 +25,13 @@ impl Iterator for LabelGenerator { type Item = String; fn next(&mut self) -> Option { - if self.current_count != 0 && self.current_count % ASCII_LOWERCASE.len() == 0 { + if self.current_count != 0 && self.current_count.is_multiple_of(ASCII_LOWERCASE.len()) { let prefix = if let Some(x) = self.sub_endless.as_mut() { x.next().unwrap() } else { - let mut gen = Box::new(LabelGenerator::new()); - let prefix = gen.next().unwrap(); - self.sub_endless = Some(gen); + let mut generator = Box::new(LabelGenerator::new()); + let prefix = generator.next().unwrap(); + self.sub_endless = Some(generator); prefix }; diff --git a/argot/src/argot/compiler/scope.rs b/argot/src/argot/compiler/scope.rs index 7c97dfb..b445428 100644 --- a/argot/src/argot/compiler/scope.rs +++ b/argot/src/argot/compiler/scope.rs @@ -16,7 +16,7 @@ pub struct Variable { impl cmp::PartialOrd for Variable { fn partial_cmp(&self, other: &Self) -> Option { - Some(self.offset.cmp(&other.offset)) + Some(self.cmp(other)) } } diff --git a/argot/src/argot/compiler/second_pass.rs b/argot/src/argot/compiler/second_pass.rs index c4f3dad..8b54cd9 100644 --- a/argot/src/argot/compiler/second_pass.rs +++ b/argot/src/argot/compiler/second_pass.rs @@ -338,7 +338,7 @@ impl Visitor for SecondPassVisitor { fn visit_program(&mut self, v: &mut Program) -> Self::Result { let mut function_keys: Vec = - v.functions.iter().map(|(key, _v)| key.clone()).collect(); + v.functions.keys().cloned().collect(); function_keys.sort(); for fn_name in function_keys.into_iter() { diff --git a/argot/src/argot/syntax/operator.rs b/argot/src/argot/syntax/operator.rs index 70617af..9ed963b 100644 --- a/argot/src/argot/syntax/operator.rs +++ b/argot/src/argot/syntax/operator.rs @@ -69,12 +69,12 @@ pub enum FactorOperator { Unknown, // TODO: Get more detail. } -impl ToString for FactorOperator { - fn to_string(&self) -> String { +impl std::fmt::Display for FactorOperator { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - FactorOperator::Div => String::from("/"), - FactorOperator::Mult => String::from("*"), - FactorOperator::Unknown => String::from("IGL"), + FactorOperator::Div => write!(f, "/"), + FactorOperator::Mult => write!(f, "*"), + FactorOperator::Unknown => write!(f, "IGL"), } } } diff --git a/argot/src/main.rs b/argot/src/main.rs index 701e115..98fefe9 100644 --- a/argot/src/main.rs +++ b/argot/src/main.rs @@ -11,6 +11,6 @@ fn main() { let root = cli::CLIRoot::parse(); if let Err(e) = root.run() { - log::error!("{}", e.to_string()); + log::error!("{}", e); } } diff --git a/assembler/Cargo.toml b/assembler/Cargo.toml index 4db6cb8..147c51d 100644 --- a/assembler/Cargo.toml +++ b/assembler/Cargo.toml @@ -2,13 +2,13 @@ name = "assembler" version = "0.1.0" authors = ["William Dussault "] -edition = "2018" +edition = "2024" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -byteorder = "1.3" +byteorder = "1.5" instructor = {path = "../instructor"} -log = {version = "0.4.8", features = ["std"]} +log = {version = "0.4", features = ["std"]} nom = "7" -snafu = "0.7.0" +snafu = "0.8" diff --git a/instructor/Cargo.toml b/instructor/Cargo.toml index c7b11ab..11152bd 100644 --- a/instructor/Cargo.toml +++ b/instructor/Cargo.toml @@ -2,9 +2,9 @@ name = "instructor" version = "0.1.0" authors = ["William Dussault "] -edition = "2018" +edition = "2024" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -byteorder = "1.3" +byteorder = "1.5" diff --git a/instructor/src/instruction.rs b/instructor/src/instruction.rs index bae3825..9d3d3a0 100644 --- a/instructor/src/instruction.rs +++ b/instructor/src/instruction.rs @@ -88,7 +88,7 @@ impl Instruction { // Write all instructions to the stream & gather byte count. let cur_size = &[&self.operand_1, &self.operand_2, &self.operand_3] .iter() - .map(|op| Instruction::write_operand(*op, w, converter)) + .map(|op| Instruction::write_operand(op, w, converter)) .sum::(); debug_assert_eq!(self.opcode.as_ref().unwrap().width() - 1, *cur_size as u16); } diff --git a/justfile b/justfile index b757c51..cad7597 100644 --- a/justfile +++ b/justfile @@ -1,18 +1,14 @@ build +args="": - cargo build {{args}} + cargo build {{ args }} _clippy target: - @cd {{target}} && cargo check && cargo clippy + @cd {{ target }} && cargo check && cargo clippy doc target +args="": - @cd {{target}} && cargo doc {{args}} + @cd {{ target }} && cargo doc {{ args }} lint: - @just _clippy argot - @just _clippy slang-cli - @just _clippy vm - @just _clippy instructor - @just _clippy assembler + @cargo clippy --workspace release: @just build --release @@ -21,16 +17,16 @@ test: cargo nextest run argotc +args="": - @cargo run --bin argotc -- {{args}} + @cargo run --bin argotc -- {{ args }} gtr f: - @cargo run --bin argotc -- --asm {{f}} - @cargo run --bin argotc -- {{f}} + @cargo run --bin argotc -- --asm {{ f }} + @cargo run --bin argotc -- {{ f }} @just trace -f ./a.out @rm ./a.out run +args="": - @cargo run --bin slang -- {{args}} + @cargo run --bin slang -- {{ args }} trace +args="": - @RUST_LOG=trace just run {{args}} + @RUST_LOG=trace just run {{ args }} diff --git a/slang-cli/Cargo.toml b/slang-cli/Cargo.toml index 7873561..31b6b43 100644 --- a/slang-cli/Cargo.toml +++ b/slang-cli/Cargo.toml @@ -2,16 +2,16 @@ name = "slang" version = "0.1.2" authors = ["William Dussault "] -edition = "2018" +edition = "2024" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -anyhow = "1.0" +anyhow = "1" clap = {version = "4", features = ["derive"]} assembler = {path = "../assembler"} -env_logger = "0.9" +env_logger = "0.11" instructor = {path = "../instructor"} -log = {version = "0.4.8", features = ["std", "release_max_level_error", "max_level_trace"]} +log = {version = "0.4", features = ["std", "release_max_level_error", "max_level_trace"]} vm = {path = "../vm"} diff --git a/slang-cli/src/cli.rs b/slang-cli/src/cli.rs index 620d6b9..9e0b79f 100644 --- a/slang-cli/src/cli.rs +++ b/slang-cli/src/cli.rs @@ -22,7 +22,7 @@ impl CLIRoot { match self.file.as_ref() { Some(f) => { // Compile & load the program, and start the VM. - let program = load_program(&f)?; + let program = load_program(f)?; let mut vm = VM::new(); vm.load_bytecode(program)?; vm.run(); diff --git a/vm/Cargo.toml b/vm/Cargo.toml index 8ef4d59..95bafb5 100644 --- a/vm/Cargo.toml +++ b/vm/Cargo.toml @@ -3,19 +3,19 @@ name = "vm" description = "The Slang virtual machine runtime." version = "0.1.0" authors = ["William Dussault "] -edition = "2018" +edition = "2024" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dev-dependencies] assembler = {path = "../assembler"} -criterion = "0.4" +criterion = "0.5" [[bench]] name = "bench" harness = false [dependencies] -byteorder = "1.3" +byteorder = "1.5" instructor = {path = "../instructor"} -log = {version = "0.4.8", features = ["std"]} -snafu = "0.7.0" +log = {version = "0.4", features = ["std"]} +snafu = "0.8" diff --git a/vm/src/loader.rs b/vm/src/loader.rs index 4fea66b..1a088e9 100644 --- a/vm/src/loader.rs +++ b/vm/src/loader.rs @@ -28,6 +28,7 @@ impl Header { } pub struct Program { + #[allow(dead_code)] pub header: Header, pub ro_block: Vec, pub program_text: Vec, @@ -39,7 +40,7 @@ impl Program { let header = Header::from_bytes(&data[0..ELIS_HEADER_LENGTH])?; ensure!( - (header.ro_block_size + ELIS_HEADER_LENGTH) as usize <= data.len(), + (header.ro_block_size + ELIS_HEADER_LENGTH) <= data.len(), ReadOnlySectionTooLongSnafu ); diff --git a/vm/src/memutil.rs b/vm/src/memutil.rs index 6701400..a1494e4 100644 --- a/vm/src/memutil.rs +++ b/vm/src/memutil.rs @@ -14,7 +14,7 @@ pub const WORD_WIDTH: usize = mem::size_of::(); /// ``` #[inline] pub fn align(i: usize) -> usize { - ((i + WORD_WIDTH - 1) / WORD_WIDTH) * WORD_WIDTH + i.div_ceil(WORD_WIDTH) * WORD_WIDTH } #[cfg(test)] diff --git a/vm/src/stack.rs b/vm/src/stack.rs index 90c9a4b..ade2024 100644 --- a/vm/src/stack.rs +++ b/vm/src/stack.rs @@ -24,11 +24,11 @@ impl Stack { #[inline] pub fn pop_i32(&mut self) -> i32 { - if self.data.len() < (mem::size_of::() as usize) { + if self.data.len() < mem::size_of::() { return 0; } - let stack_idx = self.data.len() - (mem::size_of::() as usize); + let stack_idx = self.data.len() - mem::size_of::(); let value = (&self.data[stack_idx..]) .read_i32::() .unwrap(); // Impossible b/c length is at least size_of