Skip to content

Commit

Permalink
Fix warnings, publish with all features
Browse files Browse the repository at this point in the history
  • Loading branch information
Gui-Yom committed May 21, 2022
1 parent a6da7be commit aadd3dc
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 35 deletions.
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "hlbc"
version = "0.1.0"
version = "0.1.1"
edition = "2021"
include = ["src/**/*", "LICENSE", "README.md", "build.rs"]
license = "MIT"
Expand Down
2 changes: 1 addition & 1 deletion hlbc-cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "hlbc-cli"
version = "0.1.0"
version = "0.1.1"
edition = "2021"
license = "MIT"
description = "Hashlink bytecode disassembler and analyzer"
Expand Down
15 changes: 9 additions & 6 deletions hlbc-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use termcolor::{Color, ColorChoice, ColorSpec, StandardStream, WriteColor};

use hlbc::analysis::{find_fun_refs, iter_ops};
use hlbc::opcodes::Opcode;
use hlbc::types::{Function, RefFun, RefFunPointee};
use hlbc::types::{RefFun, RefFunPointee};
use hlbc::*;

use crate::utils::read_range;
Expand Down Expand Up @@ -350,13 +350,16 @@ fn main() -> anyhow::Result<()> {
"callgraph" => {
use hlbc::analysis::graph::{call_graph, display_graph};

let [findex, depth] = args
if let [findex, depth] = args
.split(" ")
.map(|s| s.parse::<usize>())
.collect::<Result<Vec<_>, _>>()?;

let graph = call_graph(&code, RefFun(findex), depth);
println!("{}", display_graph(&graph, &code));
.collect::<Result<Vec<_>, _>>()?[..]
{
let graph = call_graph(&code, RefFun(findex), depth);
println!("{}", display_graph(&graph, &code));
} else {
println!("Unrecognized arguments '{args}'");
}
}
_ => {
println!("Unknown command : '{line}'");
Expand Down
6 changes: 0 additions & 6 deletions hlbc-cli/src/utils.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
use std::iter::repeat;

use hlbc::opcodes::Opcode;
use hlbc::types::{Function, RefFun};
use hlbc::Bytecode;

// TODO refactor this
pub fn read_range(arg: &str, max_bound: usize) -> anyhow::Result<Box<dyn Iterator<Item = usize>>> {
if arg == ".." {
Expand Down
2 changes: 1 addition & 1 deletion hlbc-derive/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "hlbc-derive"
version = "0.1.0"
version = "0.1.1"
edition = "2021"
license = "MIT"
description = "Procedural macros for the 'hlbc' crate"
Expand Down
10 changes: 5 additions & 5 deletions hlbc-derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use syn::__private::TokenStream2;
use syn::{Data, DeriveInput, GenericArgument, Ident, PathArguments, Type, Variant};

#[proc_macro_attribute]
pub fn gen_decode(attr: TokenStream, input: TokenStream) -> TokenStream {
pub fn gen_decode(_: TokenStream, input: TokenStream) -> TokenStream {
let ast = syn::parse_macro_input!(input as DeriveInput);
let variants = match &ast.data {
Data::Enum(v) => Some(&v.variants),
Expand Down Expand Up @@ -65,11 +65,11 @@ fn ident(ty: &Type) -> String {
PathArguments::AngleBracketed(a) => {
let a = match &a.args[0] {
GenericArgument::Type(ty) => ident(ty),
other => unreachable!(),
_ => unreachable!(),
};
format!("{}<{}>", seg.ident, a)
}
other => unreachable!(),
_ => unreachable!(),
}
}
other => unreachable!("unkown type {:?}", other),
Expand Down Expand Up @@ -150,7 +150,7 @@ fn gen_initr(enum_name: &Ident, v: &Variant) -> TokenStream2 {
"RefEnumConstruct" => quote! {
RefEnumConstruct(#rvi32 as usize)
},
other => TokenStream2::default(),
_ => TokenStream2::default(),
});
quote! {
Ok(#enum_name::#vname {
Expand Down Expand Up @@ -221,7 +221,7 @@ fn gen_initw(enum_name: &Ident, v: &Variant, i: u8) -> TokenStream2 {
"RefEnumConstruct" => quote! {
w.write_vi32(#fname.0 as i32)?;
},
other => TokenStream2::default(),
_ => TokenStream2::default(),
}
});
quote! {
Expand Down
14 changes: 3 additions & 11 deletions src/analysis/graph.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
use std::fmt;
use std::fmt::{Display, Formatter};

use petgraph::dot::Dot;
use petgraph::graph::NodeIndex;
use petgraph::graphmap::{DiGraphMap, GraphMap};
use petgraph::visit::{
EdgeRef, GraphProp, IntoEdgeReferences, IntoNodeReferences, NodeIndexable, NodeRef,
};
use crate::analysis::find_calls;
use petgraph::graphmap::DiGraphMap;
use petgraph::visit::{EdgeRef, IntoEdgeReferences, IntoNodeReferences, NodeIndexable, NodeRef};

use crate::r#mod::find_calls;
use crate::types::{Function, RefFun, RefFunPointee};
use crate::Bytecode;
use crate::Opcode;

use crate::r#mod::iter_ops;
use crate::utils::find_calls;

type Callgraph = DiGraphMap<RefFun, ()>;

Expand Down
2 changes: 1 addition & 1 deletion src/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ impl Opcode {
Opcode::SetEnumField { value, field, src } => {
op!("{value}.{} = {src}", field.0)
}
other => format!("{self:?}"),
_ => format!("{self:?}"),
}
}
}
Expand Down

0 comments on commit aadd3dc

Please sign in to comment.