Skip to content

Commit

Permalink
More rust cleanup
Browse files Browse the repository at this point in the history
- Fixed the documentation icon using local files (thank you @mkrasnitski)
- Fixed labels being updated and overwriting the label location used to update the label map
  • Loading branch information
emesare committed Jan 20, 2025
1 parent 2a7195f commit da1b04d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 18 deletions.
7 changes: 0 additions & 7 deletions rust/build.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
use std::path::PathBuf;

fn main() {
// TODO : Enable the following when https://github.com/rust-lang/rust/issues/43781 stabilizes
// #[cfg(doc)]
let _ = std::fs::create_dir("target");
let _ = std::fs::create_dir("target/doc");
let _ = std::fs::copy("../docs/img/favicon.ico", "target/doc/favicon.ico");
let _ = std::fs::copy("../docs/img/logo.png", "target/doc/logo.png");

let link_path =
std::env::var_os("DEP_BINARYNINJACORE_PATH").expect("DEP_BINARYNINJACORE_PATH specified");

Expand Down
4 changes: 2 additions & 2 deletions rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
#![allow(clippy::too_many_arguments)]
#![allow(clippy::needless_doctest_main)]
#![doc(html_root_url = "https://dev-rust.binary.ninja/")]
#![doc(html_favicon_url = "/favicon.ico")]
#![doc(html_logo_url = "/logo.png")]
#![doc(html_favicon_url = "https://binary.ninja/icons/favicon-32x32.png")]
#![doc(html_logo_url = "https://binary.ninja/icons/android-chrome-512x512.png")]
#![doc(issue_tracker_base_url = "https://github.com/Vector35/binaryninja-api/issues/")]
#![doc = include_str!("../README.md")]

Expand Down
34 changes: 25 additions & 9 deletions rust/src/low_level_il/lifting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1119,11 +1119,19 @@ where
};

// Update the labels after they have been resolved.
*true_label = LowLevelILLabel::from(raw_true_label);
*false_label = LowLevelILLabel::from(raw_false_label);
self.update_label_map_for_label(true_label);
self.update_label_map_for_label(false_label);

let mut new_true_label = LowLevelILLabel::from(raw_true_label);
let mut new_false_label = LowLevelILLabel::from(raw_false_label);
if let Some(location) = true_label.location {
new_true_label.location = Some(location);
self.update_label_map_for_label(&new_true_label);
}
if let Some(location) = false_label.location {
new_false_label.location = Some(location);
self.update_label_map_for_label(&new_false_label);
}

Check warning on line 1131 in rust/src/low_level_il/lifting.rs

View workflow job for this annotation

GitHub Actions / cargo fmt

Diff in /home/runner/work/binaryninja-api/binaryninja-api/rust/src/low_level_il/lifting.rs

Check warning on line 1131 in rust/src/low_level_il/lifting.rs

View workflow job for this annotation

GitHub Actions / cargo fmt

Diff in /home/runner/work/binaryninja-api/binaryninja-api/rust/src/low_level_il/lifting.rs
*true_label = new_true_label;
*false_label = new_false_label;

LowLevelILExpression::new(self, LowLevelExpressionIndex(expr_idx))
}

Expand All @@ -1138,8 +1146,12 @@ where
let expr_idx = unsafe { BNLowLevelILGoto(self.handle, &mut raw_label) };

// Update the labels after they have been resolved.
*label = LowLevelILLabel::from(raw_label);
self.update_label_map_for_label(label);
let mut new_label = LowLevelILLabel::from(raw_label);
if let Some(location) = label.location {
new_label.location = Some(location);
self.update_label_map_for_label(&new_label);
}
*label = new_label;

LowLevelILExpression::new(self, LowLevelExpressionIndex(expr_idx))
}
Expand Down Expand Up @@ -1594,8 +1606,12 @@ where

let mut raw_label = BNLowLevelILLabel::from(*label);
unsafe { BNLowLevelILMarkLabel(self.handle, &mut raw_label) };
*label = LowLevelILLabel::from(raw_label);
self.update_label_map_for_label(label);
let mut new_label = LowLevelILLabel::from(raw_label);
if let Some(location) = label.location {
new_label.location = Some(location);
self.update_label_map_for_label(&new_label);
}
*label = new_label;
}
}

Expand Down

0 comments on commit da1b04d

Please sign in to comment.