Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
tjjfvi committed May 29, 2024
1 parent 740d334 commit eeca832
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 26 deletions.
8 changes: 3 additions & 5 deletions src/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ mod include_files;

pub use include_files::*;

use std::{
collections::{BTreeMap, BTreeSet},
fmt::Write,
hash::{DefaultHasher, Hasher},
};
use alloc::collections::{BTreeMap, BTreeSet};
use core::{fmt::Write, hash::Hasher};
use std::hash::DefaultHasher;

use crate::prelude::*;
use hvm64_host::Host;
Expand Down
32 changes: 14 additions & 18 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,19 @@ mod compile;
mod args;
mod full;

use crate::prelude::*;

use core::time::Duration;
use std::{
env::consts::{DLL_PREFIX, DLL_SUFFIX},
env::{
self,
consts::{DLL_PREFIX, DLL_SUFFIX},
},
ffi::OsStr,
fs, io,
path::PathBuf,
process::{self, Stdio},
time::{Duration, Instant},
time::Instant,
};

use self::full::{CliMode, FullCli};
Expand All @@ -21,12 +27,13 @@ use clap::Parser;

use hvm64_ast::{Book, Net, Tree};
use hvm64_host::Host;
use hvm64_runtime::{DynDef, Heap, Port, Trg};
use hvm64_runtime::{trace, DynDef, Heap, Port, Trg};
use hvm64_transform::Transform;
use hvm64_util::pretty_num;

fn main() {
if cfg!(feature = "trace") {
hvm64_runtime::trace::set_hook();
trace::set_hook();
}

let cli = FullCli::parse();
Expand Down Expand Up @@ -70,7 +77,7 @@ fn main() {
};

if cfg!(feature = "trace") {
hvm64_runtime::trace::_read_traces(usize::MAX);
trace::_read_traces(usize::MAX);
}
}

Expand Down Expand Up @@ -124,7 +131,7 @@ fn load_book(files: &[PathBuf], transform_args: TransformArgs) -> Book {
}

fn load_dylibs(host: &mut Host, include: &[PathBuf]) {
let current_dir = std::env::current_dir().unwrap();
let current_dir = env::current_dir().unwrap();

for file in include {
unsafe {
Expand Down Expand Up @@ -163,7 +170,7 @@ fn load_dylibs(host: &mut Host, include: &[PathBuf]) {
});

// Leak the lib to avoid unloading it, as code from it is still referenced.
std::mem::forget(lib);
mem::forget(lib);
}
}
}
Expand Down Expand Up @@ -198,17 +205,6 @@ fn print_stats(net: &hvm64_runtime::Net, elapsed: Duration) {
eprintln!("RPS : {:.3} M", (net.rwts.total() as f64) / (elapsed.as_millis() as f64) / 1000.0);
}

fn pretty_num(n: u64) -> String {
n.to_string()
.as_bytes()
.rchunks(3)
.rev()
.map(|x| std::str::from_utf8(x).unwrap())
.flat_map(|x| ["_", x])
.skip(1)
.collect()
}

/// Compiles the `.hvm` directory, appending the provided `args` to `cargo`.
fn compile_temp_hvm() -> Result<(), io::Error> {
let output = process::Command::new("cargo")
Expand Down
3 changes: 2 additions & 1 deletion tests/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
use std::{
error::Error,
fs,
io::Read,
process::{Command, ExitStatus, Stdio},
};
Expand Down Expand Up @@ -253,5 +254,5 @@ fn test_cli_compile() {
[#13 #1]
"###);

std::fs::remove_file("examples/arithmetic").unwrap();
fs::remove_file("examples/arithmetic").unwrap();
}
3 changes: 2 additions & 1 deletion tests/tests.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use core::str::FromStr;
use dyntest::{dyntest, DynTester};
use hvm64_transform::pre_reduce::PreReduce;
use std::{fs, path::Path, str::FromStr};
use std::{fs, path::Path};

use hvm64_ast::{self as ast, Book, Net};
use hvm64_host::Host;
Expand Down
2 changes: 1 addition & 1 deletion tests/transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use hvm64_ast::{Book, Net};
use hvm64_transform::{eta_reduce::EtaReduce, inline::Inline, pre_reduce::PreReduce, prune::Prune, TransformError};

use insta::assert_snapshot;
use std::str::FromStr;
use core::str::FromStr;

mod loaders;
use loaders::*;
Expand Down

0 comments on commit eeca832

Please sign in to comment.