Skip to content

Commit

Permalink
Update dependencies, update syntax to the 2021 rust edition, and add …
Browse files Browse the repository at this point in the history
…github actions compilation checking.
  • Loading branch information
CensoredUsername committed Dec 10, 2024
1 parent d98b83b commit 9acc85f
Show file tree
Hide file tree
Showing 13 changed files with 77 additions and 43 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -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
12 changes: 7 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ readme = "README.md"
keywords = ["whitespace", "wsc"]
license = "MPL-2.0"

edition = "2021"

exclude = [
"commit_docs.sh",
]
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/assembler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion src/core/allocator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/core/bigint_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down
2 changes: 1 addition & 1 deletion src/core/cached_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
22 changes: 11 additions & 11 deletions src/core/compiler_x64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -23,7 +23,7 @@ pub fn debug_compile(program: &Program, options: Options) -> Vec<u8> {
// 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,
Expand Down Expand Up @@ -128,29 +128,29 @@ 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
}

/// Compiles an extended basic block starting at command_index
pub fn compile(&mut self, start_index: usize) -> Result<JitBlock, String> {
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,
Expand Down
2 changes: 1 addition & 1 deletion src/core/compiler_x86.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/core/jit_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down
8 changes: 4 additions & 4 deletions src/core/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<bool, WsError> {
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)
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions src/core/simple_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 5 additions & 5 deletions src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down Expand Up @@ -272,7 +272,7 @@ impl Program {
pub fn dump(&self) -> Vec<u8> {
let mut buffer = Vec::<u8>::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 {
Expand Down
4 changes: 2 additions & 2 deletions src/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 9acc85f

Please sign in to comment.