From 9acc85f4c4b6bb5ef35f2e4747955d43e8c2599e Mon Sep 17 00:00:00 2001 From: CensoredUsername Date: Tue, 10 Dec 2024 01:22:40 +0100 Subject: [PATCH] Update dependencies, update syntax to the 2021 rust edition, and add github actions compilation checking. --- .github/workflows/test.yml | 32 ++++++++++++++++++++++++++++++++ Cargo.toml | 12 +++++++----- src/assembler.rs | 8 ++++---- src/core/allocator.rs | 2 +- src/core/bigint_state.rs | 6 +++--- src/core/cached_map.rs | 2 +- src/core/compiler_x64.rs | 22 +++++++++++----------- src/core/compiler_x86.rs | 2 +- src/core/jit_state.rs | 6 +++--- src/core/mod.rs | 8 ++++---- src/core/simple_state.rs | 6 +++--- src/parser.rs | 10 +++++----- src/program.rs | 4 ++-- 13 files changed, 77 insertions(+), 43 deletions(-) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..708d0aa --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,32 @@ +on: [push, pull_request] + +name: Continuous integration + +jobs: + check: + name: Check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + - uses: actions-rs/cargo@v1 + with: + command: check + + test: + name: Test Suite + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + - uses: actions-rs/cargo@v1 + with: + command: test diff --git a/Cargo.toml b/Cargo.toml index beee92e..6938d99 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,6 +12,8 @@ readme = "README.md" keywords = ["whitespace", "wsc"] license = "MPL-2.0" +edition = "2021" + exclude = [ "commit_docs.sh", ] @@ -26,13 +28,13 @@ path = "src/main.rs" [dependencies] -itertools = "0.12.1" +itertools = "0.13.0" crossbeam = "0.8.4" fnv = "1.0.7" -bitflags = "2.5.0" -num-bigint = "0.4.4" -num-traits = "0.2.18" -dynasmrt = "2.0.0" +bitflags = "2.6.0" +num-bigint = "0.4.6" +num-traits = "0.2.19" +dynasmrt = "3.0.1" [profile.release] debug = true diff --git a/src/assembler.rs b/src/assembler.rs index 9c191a0..40e8ba7 100644 --- a/src/assembler.rs +++ b/src/assembler.rs @@ -2,14 +2,14 @@ use std::str; use std::rc::Rc; use std::ops::Range; -use program::{Program, Command, Integer, BigInteger, SizedInteger, SourceLoc}; -use ::WsError; -use ::WsErrorKind::ParseError; +use crate::program::{Program, Command, Integer, BigInteger, SizedInteger, SourceLoc}; +use crate::WsError; +use crate::WsErrorKind::ParseError; impl Program { /// Disassemble a program into a human-readable whitespace assembly. pub fn disassemble(&self) -> String { - use program::Command::*; + use crate::program::Command::*; let mut buffer = String::new(); for (index, command) in self.commands.iter().enumerate() { diff --git a/src/core/allocator.rs b/src/core/allocator.rs index 7703cf5..598a3b2 100644 --- a/src/core/allocator.rs +++ b/src/core/allocator.rs @@ -3,7 +3,7 @@ use dynasmrt::x64::Assembler; #[cfg(target_arch="x86")] use dynasmrt::x86::Assembler; use dynasmrt::DynasmApi; -use ::program::Integer; +use crate::program::Integer; const DYNAMIC_REGS: usize = 4; diff --git a/src/core/bigint_state.rs b/src/core/bigint_state.rs index 91af613..cbf9ff8 100644 --- a/src/core/bigint_state.rs +++ b/src/core/bigint_state.rs @@ -2,9 +2,9 @@ use std::collections::HashMap; use std::collections::hash_map; use std::io::{BufRead, Write}; -use ::Options; -use ::{WsError, WsErrorKind}; -use ::program::BigInteger; +use crate::Options; +use crate::{WsError, WsErrorKind}; +use crate::program::BigInteger; use super::State; pub struct BigIntState<'a> { diff --git a/src/core/cached_map.rs b/src/core/cached_map.rs index 8240ed8..a2f1ee7 100644 --- a/src/core/cached_map.rs +++ b/src/core/cached_map.rs @@ -4,7 +4,7 @@ use std::collections::HashMap; use std::collections::hash_map; use std::hash::BuildHasherDefault; -use ::program::Integer; +use crate::program::Integer; #[derive(Debug, Clone)] pub struct CachedMap { diff --git a/src/core/compiler_x64.rs b/src/core/compiler_x64.rs index 0b5ef6f..0a8fe40 100644 --- a/src/core/compiler_x64.rs +++ b/src/core/compiler_x64.rs @@ -7,7 +7,7 @@ use std::cmp::{min, max}; use super::cached_map::{CacheEntry, CACHE_MASK}; -use ::program::{Program, Command, Integer}; +use crate::program::{Program, Command, Integer}; use super::{Options}; use super::jit_state::JitState; @@ -23,7 +23,7 @@ pub fn debug_compile(program: &Program, options: Options) -> Vec { // compiler.compile_index(0); // } - use program::Command::*; + use crate::program::Command::*; for (i, c) in program.commands.iter().enumerate() { let i = match *c { Label | Call {..} if i + 1 != program.commands.len() => i + 1, @@ -128,21 +128,21 @@ impl<'a> JitCompiler<'a> { dynasm!(comp.ops ;->buffer_base: ;->cache_bypass_get: - ; .qword JitState::cache_bypass_get as _ + ; .u64 JitState::cache_bypass_get as _ ;->cache_evict: - ; .qword JitState::cache_evict as _ + ; .u64 JitState::cache_evict as _ ;->print_num: - ; .qword JitState::print_num as _ + ; .u64 JitState::print_num as _ ;->print_char: - ; .qword JitState::print_char as _ + ; .u64 JitState::print_char as _ ;->input_char: - ; .qword JitState::input_char as _ + ; .u64 JitState::input_char as _ ;->call: - ; .qword JitState::call as _ + ; .u64 JitState::call as _ ;->ret: - ; .qword JitState::ret as _ + ; .u64 JitState::ret as _ ;->get_stack: - ; .qword JitState::get_stack as _ + ; .u64 JitState::get_stack as _ ); comp @@ -150,7 +150,7 @@ impl<'a> JitCompiler<'a> { /// Compiles an extended basic block starting at command_index pub fn compile(&mut self, start_index: usize) -> Result { - use program::Command::*; + use crate::Command::*; // stack effect calculation accumulators. // stack_effect will always be the change in stack BEFORE the op while the op is matched, diff --git a/src/core/compiler_x86.rs b/src/core/compiler_x86.rs index 441fd67..0488a3d 100644 --- a/src/core/compiler_x86.rs +++ b/src/core/compiler_x86.rs @@ -7,7 +7,7 @@ use std::cmp::{min, max}; use super::cached_map::{CacheEntry, CACHE_MASK}; -use ::program::{Program, Command, Integer}; +use crate::program::{Program, Command, Integer}; use super::{Options}; use super::jit_state::JitState; diff --git a/src/core/jit_state.rs b/src/core/jit_state.rs index 2cf087c..253dce6 100644 --- a/src/core/jit_state.rs +++ b/src/core/jit_state.rs @@ -5,9 +5,9 @@ use std::mem; use super::cached_map::{CachedMap, CacheEntry, Iter}; use super::{State, SmallIntState}; use super::bigint_state::BigIntState; -use ::program::{Integer, BigInteger}; -use ::{Options}; -use ::{WsError, WsErrorKind}; +use crate::program::{Integer, BigInteger}; +use crate::{Options}; +use crate::{WsError, WsErrorKind}; #[cfg(target_arch = "x86_64")] diff --git a/src/core/mod.rs b/src/core/mod.rs index 0423a21..947ce4d 100644 --- a/src/core/mod.rs +++ b/src/core/mod.rs @@ -9,7 +9,7 @@ use std::fmt::Display; use std::str::FromStr; use std::u8; -use program::{Program, Command, Integer, BigInteger}; +use crate::program::{Program, Command, Integer, BigInteger}; use super::{WsError, WsErrorKind, Options}; mod cached_map; @@ -138,7 +138,7 @@ pub trait State<'a> { /// a control flow join is reached. The return value is false if the end /// of the program was reached fn interpret_block(&mut self, commands: &[Command]) -> Result { - use ::program::Command::*; + use crate::program::Command::*; let options = self.options(); // interpret until we hit something that can cause a flow control convergence (jump, call, ret) @@ -516,7 +516,7 @@ impl<'a> Interpreter<'a> { let mut jit_handles = vec![None; program.commands.len()]; // first compile everything (except the starting block as there's no reason to do that) - use program::Command::*; + use crate::program::Command::*; for (i, c) in program.commands.iter().enumerate() { let i = match *c { Label | Call {..} if i + 1 != program.commands.len() => i + 1, @@ -663,7 +663,7 @@ impl<'a> Interpreter<'a> { // this thread compiles our code in the background. scope.spawn(move |_| { - use program::Command::*; + use crate::program::Command::*; for (i, c) in compiler.commands.iter().enumerate() { let i = match *c { Label | Call {..} if i + 1 != compiler.commands.len() => i + 1, diff --git a/src/core/simple_state.rs b/src/core/simple_state.rs index b91aa59..5a26b37 100644 --- a/src/core/simple_state.rs +++ b/src/core/simple_state.rs @@ -3,10 +3,10 @@ use std::collections::hash_map; use std::io::{BufRead, Write}; use super::{State, SmallIntState}; -use ::program::{Integer, BigInteger}; -use ::{Options}; +use crate::program::{Integer, BigInteger}; +use crate::{Options}; use super::bigint_state::BigIntState; -use ::{WsError, WsErrorKind}; +use crate::{WsError, WsErrorKind}; pub struct SimpleState<'a> { options: Options, diff --git a/src/parser.rs b/src/parser.rs index fdb5576..3c7b3e8 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -3,10 +3,10 @@ use num_bigint::Sign; use std::i64; use std::rc::Rc; -use label::Label; -use program::{Program, Command, Integer, BigInteger, SizedInteger, SourceLoc}; -use ::WsError; -use ::WsErrorKind::ParseError; +use crate::label::Label; +use crate::program::{Program, Command, Integer, BigInteger, SizedInteger, SourceLoc}; +use crate::WsError; +use crate::WsErrorKind::ParseError; #[derive(Debug, Clone)] struct ParseState<'a> { @@ -272,7 +272,7 @@ impl Program { pub fn dump(&self) -> Vec { let mut buffer = Vec::::new(); - use program::Command::*; + use crate::program::Command::*; for (index, command) in self.commands.iter().enumerate() { let label = self.locs.as_ref().and_then(|l| l[index].label.as_ref()); let (code, arg): (&[u8], _) = match *command { diff --git a/src/program.rs b/src/program.rs index b2a870a..3774233 100644 --- a/src/program.rs +++ b/src/program.rs @@ -4,9 +4,9 @@ use std::rc::Rc; use std::ops::Range; use std::collections::HashMap; -use label::Label; +use crate::label::Label; -pub use ::Program; +pub use crate::Program; #[derive(Debug, Clone)] pub struct SourceLoc {