Use let chains (a.k.a. cargo clippy --fix)

This commit is contained in:
Luke Street 2025-08-02 11:26:59 -06:00
parent 0dc123b064
commit c9c3b32376
17 changed files with 507 additions and 507 deletions

View File

@ -248,14 +248,13 @@ fn report_object(
{ {
continue; continue;
} }
if let Some(existing_functions) = &mut existing_functions { if let Some(existing_functions) = &mut existing_functions
if (symbol.flags.contains(SymbolFlag::Global) && (symbol.flags.contains(SymbolFlag::Global)
|| symbol.flags.contains(SymbolFlag::Weak)) || symbol.flags.contains(SymbolFlag::Weak))
&& !existing_functions.insert(symbol.name.clone()) && !existing_functions.insert(symbol.name.clone())
{ {
continue; continue;
} }
}
let match_percent = symbol_diff.match_percent.unwrap_or_else(|| { let match_percent = symbol_diff.match_percent.unwrap_or_else(|| {
// Support cases where we don't have a target object, // Support cases where we don't have a target object,
// assume complete means 100% match // assume complete means 100% match

View File

@ -170,8 +170,8 @@ impl UiView for FunctionDiffUi {
let mut prev_text = None; let mut prev_text = None;
let mut prev_margin_text = None; let mut prev_margin_text = None;
if self.three_way { if self.three_way
if let Some((obj, symbol_idx, symbol_diff)) = && let Some((obj, symbol_idx, symbol_diff)) =
get_symbol(state.prev_obj.as_ref(), self.prev_sym) get_symbol(state.prev_obj.as_ref(), self.prev_sym)
{ {
let mut text = Text::default(); let mut text = Text::default();
@ -196,7 +196,6 @@ impl UiView for FunctionDiffUi {
self.print_margin(&mut text, symbol_diff, rect); self.print_margin(&mut text, symbol_diff, rect);
prev_margin_text = Some(text); prev_margin_text = Some(text);
} }
}
let max_scroll_x = let max_scroll_x =
max_width.saturating_sub(content_chunks[0].width.min(content_chunks[2].width) as usize); max_width.saturating_sub(content_chunks[0].width.min(content_chunks[2].width) as usize);
@ -561,11 +560,13 @@ impl FunctionDiffUi {
let len = label_text.len(); let len = label_text.len();
let highlighted = let highlighted =
highlight_kind != HighlightKind::None && *highlight == highlight_kind; highlight_kind != HighlightKind::None && *highlight == highlight_kind;
if let Some((cx, cy)) = result.click_xy { if let Some((cx, cy)) = result.click_xy
if cx >= sx && cx < sx + len as u16 && cy == sy { && cx >= sx
&& cx < sx + len as u16
&& cy == sy
{
new_highlight = Some(highlight_kind); new_highlight = Some(highlight_kind);
} }
}
let mut style = Style::new().fg(match segment.color { let mut style = Style::new().fg(match segment.color {
DiffTextColor::Normal => Color::Gray, DiffTextColor::Normal => Color::Gray,
DiffTextColor::Dim => Color::DarkGray, DiffTextColor::Dim => Color::DarkGray,

View File

@ -509,8 +509,9 @@ where Cb: FnMut(InstructionPart<'static>) {
return "ubfx"; return "ubfx";
} }
Opcode::SBFM => { Opcode::SBFM => {
if let Operand::Immediate(63) = ins.operands[3] { if let Operand::Immediate(63) = ins.operands[3]
if let Operand::Register(SizeCode::X, _) = ins.operands[0] { && let Operand::Register(SizeCode::X, _) = ins.operands[0]
{
push_operand(args, &ins.operands[0], ctx); push_operand(args, &ins.operands[0], ctx);
push_separator(args); push_separator(args);
push_operand(args, &ins.operands[1], ctx); push_operand(args, &ins.operands[1], ctx);
@ -518,9 +519,9 @@ where Cb: FnMut(InstructionPart<'static>) {
push_operand(args, &ins.operands[2], ctx); push_operand(args, &ins.operands[2], ctx);
return "asr"; return "asr";
} }
} if let Operand::Immediate(31) = ins.operands[3]
if let Operand::Immediate(31) = ins.operands[3] { && let Operand::Register(SizeCode::W, _) = ins.operands[0]
if let Operand::Register(SizeCode::W, _) = ins.operands[0] { {
push_operand(args, &ins.operands[0], ctx); push_operand(args, &ins.operands[0], ctx);
push_separator(args); push_separator(args);
push_operand(args, &ins.operands[1], ctx); push_operand(args, &ins.operands[1], ctx);
@ -528,7 +529,6 @@ where Cb: FnMut(InstructionPart<'static>) {
push_operand(args, &ins.operands[2], ctx); push_operand(args, &ins.operands[2], ctx);
return "asr"; return "asr";
} }
}
if let Operand::Immediate(0) = ins.operands[2] { if let Operand::Immediate(0) = ins.operands[2] {
let newsrc = if let Operand::Register(_size, srcnum) = ins.operands[1] { let newsrc = if let Operand::Register(_size, srcnum) = ins.operands[1] {
Operand::Register(SizeCode::W, srcnum) Operand::Register(SizeCode::W, srcnum)
@ -554,8 +554,8 @@ where Cb: FnMut(InstructionPart<'static>) {
} }
if let (Operand::Immediate(imms), Operand::Immediate(immr)) = if let (Operand::Immediate(imms), Operand::Immediate(immr)) =
(ins.operands[2], ins.operands[3]) (ins.operands[2], ins.operands[3])
&& immr < imms
{ {
if immr < imms {
let size = if let Operand::Register(size, _) = ins.operands[0] { let size = if let Operand::Register(size, _) = ins.operands[0] {
if size == SizeCode::W { 32 } else { 64 } if size == SizeCode::W { 32 } else { 64 }
} else { } else {
@ -570,7 +570,6 @@ where Cb: FnMut(InstructionPart<'static>) {
push_unsigned(args, (immr + 1) as u64); push_unsigned(args, (immr + 1) as u64);
return "sbfiz"; return "sbfiz";
} }
}
// `sbfm` is never actually displayed: in the remaining case, it is always aliased to `sbfx` // `sbfm` is never actually displayed: in the remaining case, it is always aliased to `sbfx`
let width = if let (Operand::Immediate(lsb), Operand::Immediate(width)) = let width = if let (Operand::Immediate(lsb), Operand::Immediate(width)) =
(ins.operands[2], ins.operands[3]) (ins.operands[2], ins.operands[3])
@ -593,8 +592,8 @@ where Cb: FnMut(InstructionPart<'static>) {
Opcode::EXTR => { Opcode::EXTR => {
if let (Operand::Register(_, rn), Operand::Register(_, rm)) = if let (Operand::Register(_, rn), Operand::Register(_, rm)) =
(ins.operands[1], ins.operands[2]) (ins.operands[1], ins.operands[2])
&& rn == rm
{ {
if rn == rm {
push_operand(args, &ins.operands[0], ctx); push_operand(args, &ins.operands[0], ctx);
push_separator(args); push_separator(args);
push_operand(args, &ins.operands[2], ctx); push_operand(args, &ins.operands[2], ctx);
@ -602,7 +601,6 @@ where Cb: FnMut(InstructionPart<'static>) {
push_operand(args, &ins.operands[3], ctx); push_operand(args, &ins.operands[3], ctx);
return "ror"; return "ror";
} }
}
"extr" "extr"
} }
Opcode::LDAR => "ldar", Opcode::LDAR => "ldar",
@ -804,13 +802,11 @@ where Cb: FnMut(InstructionPart<'static>) {
"csneg" "csneg"
} }
Opcode::CSINC => { Opcode::CSINC => {
if let ( if let (Operand::Register(_, n), Operand::Register(_, m), Operand::ConditionCode(cond)) =
Operand::Register(_, n), (ins.operands[1], ins.operands[2], ins.operands[3])
Operand::Register(_, m), && n == m
Operand::ConditionCode(cond), && cond < 0b1110
) = (ins.operands[1], ins.operands[2], ins.operands[3])
{ {
if n == m && cond < 0b1110 {
return if n == 31 { return if n == 31 {
push_operand(args, &ins.operands[0], ctx); push_operand(args, &ins.operands[0], ctx);
push_separator(args); push_separator(args);
@ -825,7 +821,6 @@ where Cb: FnMut(InstructionPart<'static>) {
"cinc" "cinc"
}; };
} }
}
"csinc" "csinc"
} }
Opcode::CSINV => { Opcode::CSINV => {
@ -1200,16 +1195,14 @@ where Cb: FnMut(InstructionPart<'static>) {
Operand::Register(reg_sz, _), Operand::Register(reg_sz, _),
Operand::SIMDRegisterElementsLane(_, _, elem_sz, _), Operand::SIMDRegisterElementsLane(_, _, elem_sz, _),
) = (ins.operands[0], ins.operands[1]) ) = (ins.operands[0], ins.operands[1])
{ && ((reg_sz == SizeCode::W && elem_sz == SIMDSizeCode::S)
if (reg_sz == SizeCode::W && elem_sz == SIMDSizeCode::S) || (reg_sz == SizeCode::X && elem_sz == SIMDSizeCode::D))
|| (reg_sz == SizeCode::X && elem_sz == SIMDSizeCode::D)
{ {
push_operand(args, &ins.operands[0], ctx); push_operand(args, &ins.operands[0], ctx);
push_separator(args); push_separator(args);
push_operand(args, &ins.operands[1], ctx); push_operand(args, &ins.operands[1], ctx);
return "mov"; return "mov";
} }
}
"umov" "umov"
} }
Opcode::SQSHRN2 => "sqshrn2", Opcode::SQSHRN2 => "sqshrn2",
@ -1308,15 +1301,16 @@ where Cb: FnMut(InstructionPart<'static>) {
} }
} }
Opcode::LDADDB(ar) => { Opcode::LDADDB(ar) => {
if let Operand::Register(_, rt) = ins.operands[1] { if let Operand::Register(_, rt) = ins.operands[1]
if rt == 31 && ar & 0b10 == 0b00 { && rt == 31
&& ar & 0b10 == 0b00
{
let inst = if ar & 0b01 == 0b00 { "staddb" } else { "staddlb" }; let inst = if ar & 0b01 == 0b00 { "staddb" } else { "staddlb" };
push_operand(args, &ins.operands[0], ctx); push_operand(args, &ins.operands[0], ctx);
push_separator(args); push_separator(args);
push_operand(args, &ins.operands[2], ctx); push_operand(args, &ins.operands[2], ctx);
return inst; return inst;
} }
}
if ar == 0 { if ar == 0 {
"ldaddb" "ldaddb"
} else if ar == 0b01 { } else if ar == 0b01 {
@ -1328,15 +1322,16 @@ where Cb: FnMut(InstructionPart<'static>) {
} }
} }
Opcode::LDCLRB(ar) => { Opcode::LDCLRB(ar) => {
if let Operand::Register(_, rt) = ins.operands[1] { if let Operand::Register(_, rt) = ins.operands[1]
if rt == 31 && ar & 0b10 == 0b00 { && rt == 31
&& ar & 0b10 == 0b00
{
let inst = if ar & 0b01 == 0b00 { "stclrb" } else { "stclrlb" }; let inst = if ar & 0b01 == 0b00 { "stclrb" } else { "stclrlb" };
push_operand(args, &ins.operands[0], ctx); push_operand(args, &ins.operands[0], ctx);
push_separator(args); push_separator(args);
push_operand(args, &ins.operands[2], ctx); push_operand(args, &ins.operands[2], ctx);
return inst; return inst;
} }
}
if ar == 0 { if ar == 0 {
"ldclrb" "ldclrb"
} else if ar == 0b01 { } else if ar == 0b01 {
@ -1348,15 +1343,16 @@ where Cb: FnMut(InstructionPart<'static>) {
} }
} }
Opcode::LDEORB(ar) => { Opcode::LDEORB(ar) => {
if let Operand::Register(_, rt) = ins.operands[1] { if let Operand::Register(_, rt) = ins.operands[1]
if rt == 31 && ar & 0b10 == 0b00 { && rt == 31
&& ar & 0b10 == 0b00
{
let inst = if ar & 0b01 == 0b00 { "steorb" } else { "steorlb" }; let inst = if ar & 0b01 == 0b00 { "steorb" } else { "steorlb" };
push_operand(args, &ins.operands[0], ctx); push_operand(args, &ins.operands[0], ctx);
push_separator(args); push_separator(args);
push_operand(args, &ins.operands[2], ctx); push_operand(args, &ins.operands[2], ctx);
return inst; return inst;
} }
}
if ar == 0 { if ar == 0 {
"ldeorb" "ldeorb"
} else if ar == 0b01 { } else if ar == 0b01 {
@ -1368,15 +1364,16 @@ where Cb: FnMut(InstructionPart<'static>) {
} }
} }
Opcode::LDSETB(ar) => { Opcode::LDSETB(ar) => {
if let Operand::Register(_, rt) = ins.operands[1] { if let Operand::Register(_, rt) = ins.operands[1]
if rt == 31 && ar & 0b10 == 0b00 { && rt == 31
&& ar & 0b10 == 0b00
{
let inst = if ar & 0b01 == 0b00 { "stsetb" } else { "stsetlb" }; let inst = if ar & 0b01 == 0b00 { "stsetb" } else { "stsetlb" };
push_operand(args, &ins.operands[0], ctx); push_operand(args, &ins.operands[0], ctx);
push_separator(args); push_separator(args);
push_operand(args, &ins.operands[2], ctx); push_operand(args, &ins.operands[2], ctx);
return inst; return inst;
} }
}
if ar == 0 { if ar == 0 {
"ldsetb" "ldsetb"
} else if ar == 0b01 { } else if ar == 0b01 {
@ -1388,15 +1385,16 @@ where Cb: FnMut(InstructionPart<'static>) {
} }
} }
Opcode::LDSMAXB(ar) => { Opcode::LDSMAXB(ar) => {
if let Operand::Register(_, rt) = ins.operands[1] { if let Operand::Register(_, rt) = ins.operands[1]
if rt == 31 && ar & 0b10 == 0b00 { && rt == 31
&& ar & 0b10 == 0b00
{
let inst = if ar & 0b01 == 0b00 { "stsmaxb" } else { "stsmaxlb" }; let inst = if ar & 0b01 == 0b00 { "stsmaxb" } else { "stsmaxlb" };
push_operand(args, &ins.operands[0], ctx); push_operand(args, &ins.operands[0], ctx);
push_separator(args); push_separator(args);
push_operand(args, &ins.operands[2], ctx); push_operand(args, &ins.operands[2], ctx);
return inst; return inst;
} }
}
if ar == 0 { if ar == 0 {
"ldsmaxb" "ldsmaxb"
} else if ar == 0b01 { } else if ar == 0b01 {
@ -1408,15 +1406,16 @@ where Cb: FnMut(InstructionPart<'static>) {
} }
} }
Opcode::LDSMINB(ar) => { Opcode::LDSMINB(ar) => {
if let Operand::Register(_, rt) = ins.operands[1] { if let Operand::Register(_, rt) = ins.operands[1]
if rt == 31 && ar & 0b10 == 0b00 { && rt == 31
&& ar & 0b10 == 0b00
{
let inst = if ar & 0b01 == 0b00 { "stsminb" } else { "stsminlb" }; let inst = if ar & 0b01 == 0b00 { "stsminb" } else { "stsminlb" };
push_operand(args, &ins.operands[0], ctx); push_operand(args, &ins.operands[0], ctx);
push_separator(args); push_separator(args);
push_operand(args, &ins.operands[2], ctx); push_operand(args, &ins.operands[2], ctx);
return inst; return inst;
} }
}
if ar == 0 { if ar == 0 {
"ldsminb" "ldsminb"
} else if ar == 0b01 { } else if ar == 0b01 {
@ -1428,15 +1427,16 @@ where Cb: FnMut(InstructionPart<'static>) {
} }
} }
Opcode::LDUMAXB(ar) => { Opcode::LDUMAXB(ar) => {
if let Operand::Register(_, rt) = ins.operands[1] { if let Operand::Register(_, rt) = ins.operands[1]
if rt == 31 && ar & 0b10 == 0b00 { && rt == 31
&& ar & 0b10 == 0b00
{
let inst = if ar & 0b01 == 0b00 { "stumaxb" } else { "stumaxlb" }; let inst = if ar & 0b01 == 0b00 { "stumaxb" } else { "stumaxlb" };
push_operand(args, &ins.operands[0], ctx); push_operand(args, &ins.operands[0], ctx);
push_separator(args); push_separator(args);
push_operand(args, &ins.operands[2], ctx); push_operand(args, &ins.operands[2], ctx);
return inst; return inst;
} }
}
if ar == 0 { if ar == 0 {
"ldumaxb" "ldumaxb"
} else if ar == 0b01 { } else if ar == 0b01 {
@ -1448,15 +1448,16 @@ where Cb: FnMut(InstructionPart<'static>) {
} }
} }
Opcode::LDUMINB(ar) => { Opcode::LDUMINB(ar) => {
if let Operand::Register(_, rt) = ins.operands[1] { if let Operand::Register(_, rt) = ins.operands[1]
if rt == 31 && ar & 0b10 == 0b00 { && rt == 31
&& ar & 0b10 == 0b00
{
let inst = if ar & 0b01 == 0b00 { "stuminb" } else { "stuminlb" }; let inst = if ar & 0b01 == 0b00 { "stuminb" } else { "stuminlb" };
push_operand(args, &ins.operands[0], ctx); push_operand(args, &ins.operands[0], ctx);
push_separator(args); push_separator(args);
push_operand(args, &ins.operands[2], ctx); push_operand(args, &ins.operands[2], ctx);
return inst; return inst;
} }
}
// write!(fmt, "{}", self.opcode)?; // write!(fmt, "{}", self.opcode)?;
if ar == 0 { if ar == 0 {
"lduminb" "lduminb"
@ -1469,15 +1470,16 @@ where Cb: FnMut(InstructionPart<'static>) {
} }
} }
Opcode::LDADDH(ar) => { Opcode::LDADDH(ar) => {
if let Operand::Register(_, rt) = ins.operands[1] { if let Operand::Register(_, rt) = ins.operands[1]
if rt == 31 && ar & 0b10 == 0b00 { && rt == 31
&& ar & 0b10 == 0b00
{
let inst = if ar & 0b01 == 0b00 { "staddh" } else { "staddlh" }; let inst = if ar & 0b01 == 0b00 { "staddh" } else { "staddlh" };
push_operand(args, &ins.operands[0], ctx); push_operand(args, &ins.operands[0], ctx);
push_separator(args); push_separator(args);
push_operand(args, &ins.operands[2], ctx); push_operand(args, &ins.operands[2], ctx);
return inst; return inst;
} }
}
if ar == 0 { if ar == 0 {
"ldaddh" "ldaddh"
} else if ar == 0b01 { } else if ar == 0b01 {
@ -1489,15 +1491,16 @@ where Cb: FnMut(InstructionPart<'static>) {
} }
} }
Opcode::LDCLRH(ar) => { Opcode::LDCLRH(ar) => {
if let Operand::Register(_, rt) = ins.operands[1] { if let Operand::Register(_, rt) = ins.operands[1]
if rt == 31 && ar & 0b10 == 0b00 { && rt == 31
&& ar & 0b10 == 0b00
{
let inst = if ar & 0b01 == 0b00 { "stclrh" } else { "stclrlh" }; let inst = if ar & 0b01 == 0b00 { "stclrh" } else { "stclrlh" };
push_operand(args, &ins.operands[0], ctx); push_operand(args, &ins.operands[0], ctx);
push_separator(args); push_separator(args);
push_operand(args, &ins.operands[2], ctx); push_operand(args, &ins.operands[2], ctx);
return inst; return inst;
} }
}
if ar == 0 { if ar == 0 {
"ldclrh" "ldclrh"
} else if ar == 0b01 { } else if ar == 0b01 {
@ -1509,15 +1512,16 @@ where Cb: FnMut(InstructionPart<'static>) {
} }
} }
Opcode::LDEORH(ar) => { Opcode::LDEORH(ar) => {
if let Operand::Register(_, rt) = ins.operands[1] { if let Operand::Register(_, rt) = ins.operands[1]
if rt == 31 && ar & 0b10 == 0b00 { && rt == 31
&& ar & 0b10 == 0b00
{
let inst = if ar & 0b01 == 0b00 { "steorh" } else { "steorlh" }; let inst = if ar & 0b01 == 0b00 { "steorh" } else { "steorlh" };
push_operand(args, &ins.operands[0], ctx); push_operand(args, &ins.operands[0], ctx);
push_separator(args); push_separator(args);
push_operand(args, &ins.operands[2], ctx); push_operand(args, &ins.operands[2], ctx);
return inst; return inst;
} }
}
if ar == 0 { if ar == 0 {
"ldeorh" "ldeorh"
} else if ar == 0b01 { } else if ar == 0b01 {
@ -1529,15 +1533,16 @@ where Cb: FnMut(InstructionPart<'static>) {
} }
} }
Opcode::LDSETH(ar) => { Opcode::LDSETH(ar) => {
if let Operand::Register(_, rt) = ins.operands[1] { if let Operand::Register(_, rt) = ins.operands[1]
if rt == 31 && ar & 0b10 == 0b00 { && rt == 31
&& ar & 0b10 == 0b00
{
let inst = if ar & 0b01 == 0b00 { "stseth" } else { "stsetlh" }; let inst = if ar & 0b01 == 0b00 { "stseth" } else { "stsetlh" };
push_operand(args, &ins.operands[0], ctx); push_operand(args, &ins.operands[0], ctx);
push_separator(args); push_separator(args);
push_operand(args, &ins.operands[2], ctx); push_operand(args, &ins.operands[2], ctx);
return inst; return inst;
} }
}
if ar == 0 { if ar == 0 {
"ldseth" "ldseth"
} else if ar == 0b01 { } else if ar == 0b01 {
@ -1549,15 +1554,16 @@ where Cb: FnMut(InstructionPart<'static>) {
} }
} }
Opcode::LDSMAXH(ar) => { Opcode::LDSMAXH(ar) => {
if let Operand::Register(_, rt) = ins.operands[1] { if let Operand::Register(_, rt) = ins.operands[1]
if rt == 31 && ar & 0b10 == 0b00 { && rt == 31
&& ar & 0b10 == 0b00
{
let inst = if ar & 0b01 == 0b00 { "stsmaxh" } else { "stsmaxlh" }; let inst = if ar & 0b01 == 0b00 { "stsmaxh" } else { "stsmaxlh" };
push_operand(args, &ins.operands[0], ctx); push_operand(args, &ins.operands[0], ctx);
push_separator(args); push_separator(args);
push_operand(args, &ins.operands[2], ctx); push_operand(args, &ins.operands[2], ctx);
return inst; return inst;
} }
}
if ar == 0 { if ar == 0 {
"ldsmaxh" "ldsmaxh"
} else if ar == 0b01 { } else if ar == 0b01 {
@ -1569,15 +1575,16 @@ where Cb: FnMut(InstructionPart<'static>) {
} }
} }
Opcode::LDSMINH(ar) => { Opcode::LDSMINH(ar) => {
if let Operand::Register(_, rt) = ins.operands[1] { if let Operand::Register(_, rt) = ins.operands[1]
if rt == 31 && ar & 0b10 == 0b00 { && rt == 31
&& ar & 0b10 == 0b00
{
let inst = if ar & 0b01 == 0b00 { "stsminh" } else { "stsminlh" }; let inst = if ar & 0b01 == 0b00 { "stsminh" } else { "stsminlh" };
push_operand(args, &ins.operands[0], ctx); push_operand(args, &ins.operands[0], ctx);
push_separator(args); push_separator(args);
push_operand(args, &ins.operands[2], ctx); push_operand(args, &ins.operands[2], ctx);
return inst; return inst;
} }
}
if ar == 0 { if ar == 0 {
"ldsminh" "ldsminh"
} else if ar == 0b01 { } else if ar == 0b01 {
@ -1589,15 +1596,16 @@ where Cb: FnMut(InstructionPart<'static>) {
} }
} }
Opcode::LDUMAXH(ar) => { Opcode::LDUMAXH(ar) => {
if let Operand::Register(_, rt) = ins.operands[1] { if let Operand::Register(_, rt) = ins.operands[1]
if rt == 31 && ar & 0b10 == 0b00 { && rt == 31
&& ar & 0b10 == 0b00
{
let inst = if ar & 0b01 == 0b00 { "stumaxh" } else { "stumaxlh" }; let inst = if ar & 0b01 == 0b00 { "stumaxh" } else { "stumaxlh" };
push_operand(args, &ins.operands[0], ctx); push_operand(args, &ins.operands[0], ctx);
push_separator(args); push_separator(args);
push_operand(args, &ins.operands[2], ctx); push_operand(args, &ins.operands[2], ctx);
return inst; return inst;
} }
}
if ar == 0 { if ar == 0 {
"ldumaxh" "ldumaxh"
} else if ar == 0b01 { } else if ar == 0b01 {
@ -1609,15 +1617,16 @@ where Cb: FnMut(InstructionPart<'static>) {
} }
} }
Opcode::LDUMINH(ar) => { Opcode::LDUMINH(ar) => {
if let Operand::Register(_, rt) = ins.operands[1] { if let Operand::Register(_, rt) = ins.operands[1]
if rt == 31 && ar & 0b10 == 0b00 { && rt == 31
&& ar & 0b10 == 0b00
{
let inst = if ar & 0b01 == 0b00 { "stuminh" } else { "stuminlh" }; let inst = if ar & 0b01 == 0b00 { "stuminh" } else { "stuminlh" };
push_operand(args, &ins.operands[0], ctx); push_operand(args, &ins.operands[0], ctx);
push_separator(args); push_separator(args);
push_operand(args, &ins.operands[2], ctx); push_operand(args, &ins.operands[2], ctx);
return inst; return inst;
} }
}
if ar == 0 { if ar == 0 {
"lduminh" "lduminh"
} else if ar == 0b01 { } else if ar == 0b01 {
@ -1629,15 +1638,16 @@ where Cb: FnMut(InstructionPart<'static>) {
} }
} }
Opcode::LDADD(ar) => { Opcode::LDADD(ar) => {
if let Operand::Register(_, rt) = ins.operands[1] { if let Operand::Register(_, rt) = ins.operands[1]
if rt == 31 && ar & 0b10 == 0b00 { && rt == 31
&& ar & 0b10 == 0b00
{
let inst = if ar & 0b01 == 0b00 { "stadd" } else { "staddl" }; let inst = if ar & 0b01 == 0b00 { "stadd" } else { "staddl" };
push_operand(args, &ins.operands[0], ctx); push_operand(args, &ins.operands[0], ctx);
push_separator(args); push_separator(args);
push_operand(args, &ins.operands[2], ctx); push_operand(args, &ins.operands[2], ctx);
return inst; return inst;
} }
}
if ar == 0 { if ar == 0 {
"ldadd" "ldadd"
} else if ar == 0b01 { } else if ar == 0b01 {
@ -1649,15 +1659,16 @@ where Cb: FnMut(InstructionPart<'static>) {
} }
} }
Opcode::LDCLR(ar) => { Opcode::LDCLR(ar) => {
if let Operand::Register(_, rt) = ins.operands[1] { if let Operand::Register(_, rt) = ins.operands[1]
if rt == 31 && ar & 0b10 == 0b00 { && rt == 31
&& ar & 0b10 == 0b00
{
let inst = if ar & 0b01 == 0b00 { "stclr" } else { "stclrl" }; let inst = if ar & 0b01 == 0b00 { "stclr" } else { "stclrl" };
push_operand(args, &ins.operands[0], ctx); push_operand(args, &ins.operands[0], ctx);
push_separator(args); push_separator(args);
push_operand(args, &ins.operands[2], ctx); push_operand(args, &ins.operands[2], ctx);
return inst; return inst;
} }
}
if ar == 0 { if ar == 0 {
"ldclr" "ldclr"
} else if ar == 0b01 { } else if ar == 0b01 {
@ -1669,15 +1680,16 @@ where Cb: FnMut(InstructionPart<'static>) {
} }
} }
Opcode::LDEOR(ar) => { Opcode::LDEOR(ar) => {
if let Operand::Register(_, rt) = ins.operands[1] { if let Operand::Register(_, rt) = ins.operands[1]
if rt == 31 && ar & 0b10 == 0b00 { && rt == 31
&& ar & 0b10 == 0b00
{
let inst = if ar & 0b01 == 0b00 { "steor" } else { "steorl" }; let inst = if ar & 0b01 == 0b00 { "steor" } else { "steorl" };
push_operand(args, &ins.operands[0], ctx); push_operand(args, &ins.operands[0], ctx);
push_separator(args); push_separator(args);
push_operand(args, &ins.operands[2], ctx); push_operand(args, &ins.operands[2], ctx);
return inst; return inst;
} }
}
if ar == 0 { if ar == 0 {
"ldeor" "ldeor"
} else if ar == 0b01 { } else if ar == 0b01 {
@ -1689,15 +1701,16 @@ where Cb: FnMut(InstructionPart<'static>) {
} }
} }
Opcode::LDSET(ar) => { Opcode::LDSET(ar) => {
if let Operand::Register(_, rt) = ins.operands[1] { if let Operand::Register(_, rt) = ins.operands[1]
if rt == 31 && ar & 0b10 == 0b00 { && rt == 31
&& ar & 0b10 == 0b00
{
let inst = if ar & 0b01 == 0b00 { "stset" } else { "stsetl" }; let inst = if ar & 0b01 == 0b00 { "stset" } else { "stsetl" };
push_operand(args, &ins.operands[0], ctx); push_operand(args, &ins.operands[0], ctx);
push_separator(args); push_separator(args);
push_operand(args, &ins.operands[2], ctx); push_operand(args, &ins.operands[2], ctx);
return inst; return inst;
} }
}
if ar == 0 { if ar == 0 {
"ldset" "ldset"
} else if ar == 0b01 { } else if ar == 0b01 {
@ -1709,15 +1722,16 @@ where Cb: FnMut(InstructionPart<'static>) {
} }
} }
Opcode::LDSMAX(ar) => { Opcode::LDSMAX(ar) => {
if let Operand::Register(_, rt) = ins.operands[1] { if let Operand::Register(_, rt) = ins.operands[1]
if rt == 31 && ar & 0b10 == 0b00 { && rt == 31
&& ar & 0b10 == 0b00
{
let inst = if ar & 0b01 == 0b00 { "stsmax" } else { "stsmaxl" }; let inst = if ar & 0b01 == 0b00 { "stsmax" } else { "stsmaxl" };
push_operand(args, &ins.operands[0], ctx); push_operand(args, &ins.operands[0], ctx);
push_separator(args); push_separator(args);
push_operand(args, &ins.operands[2], ctx); push_operand(args, &ins.operands[2], ctx);
return inst; return inst;
} }
}
if ar == 0 { if ar == 0 {
"ldsmax" "ldsmax"
} else if ar == 0b01 { } else if ar == 0b01 {
@ -1729,15 +1743,16 @@ where Cb: FnMut(InstructionPart<'static>) {
} }
} }
Opcode::LDSMIN(ar) => { Opcode::LDSMIN(ar) => {
if let Operand::Register(_, rt) = ins.operands[1] { if let Operand::Register(_, rt) = ins.operands[1]
if rt == 31 && ar & 0b10 == 0b00 { && rt == 31
&& ar & 0b10 == 0b00
{
let inst = if ar & 0b01 == 0b00 { "stsmin" } else { "stsminl" }; let inst = if ar & 0b01 == 0b00 { "stsmin" } else { "stsminl" };
push_operand(args, &ins.operands[0], ctx); push_operand(args, &ins.operands[0], ctx);
push_separator(args); push_separator(args);
push_operand(args, &ins.operands[2], ctx); push_operand(args, &ins.operands[2], ctx);
return inst; return inst;
} }
}
if ar == 0 { if ar == 0 {
"ldsmin" "ldsmin"
} else if ar == 0b01 { } else if ar == 0b01 {
@ -1749,15 +1764,16 @@ where Cb: FnMut(InstructionPart<'static>) {
} }
} }
Opcode::LDUMAX(ar) => { Opcode::LDUMAX(ar) => {
if let Operand::Register(_, rt) = ins.operands[1] { if let Operand::Register(_, rt) = ins.operands[1]
if rt == 31 && ar & 0b10 == 0b00 { && rt == 31
&& ar & 0b10 == 0b00
{
let inst = if ar & 0b01 == 0b00 { "stumax" } else { "stumaxl" }; let inst = if ar & 0b01 == 0b00 { "stumax" } else { "stumaxl" };
push_operand(args, &ins.operands[0], ctx); push_operand(args, &ins.operands[0], ctx);
push_separator(args); push_separator(args);
push_operand(args, &ins.operands[2], ctx); push_operand(args, &ins.operands[2], ctx);
return inst; return inst;
} }
}
if ar == 0 { if ar == 0 {
"ldumax" "ldumax"
} else if ar == 0b01 { } else if ar == 0b01 {
@ -1769,15 +1785,16 @@ where Cb: FnMut(InstructionPart<'static>) {
} }
} }
Opcode::LDUMIN(ar) => { Opcode::LDUMIN(ar) => {
if let Operand::Register(_, rt) = ins.operands[1] { if let Operand::Register(_, rt) = ins.operands[1]
if rt == 31 && ar & 0b10 == 0b00 { && rt == 31
&& ar & 0b10 == 0b00
{
let inst = if ar & 0b01 == 0b00 { "stumin" } else { "stuminl" }; let inst = if ar & 0b01 == 0b00 { "stumin" } else { "stuminl" };
push_operand(args, &ins.operands[0], ctx); push_operand(args, &ins.operands[0], ctx);
push_separator(args); push_separator(args);
push_operand(args, &ins.operands[2], ctx); push_operand(args, &ins.operands[2], ctx);
return inst; return inst;
} }
}
if ar == 0 { if ar == 0 {
"ldumin" "ldumin"
} else if ar == 0b01 { } else if ar == 0b01 {
@ -2067,8 +2084,8 @@ where Cb: FnMut(InstructionPart<'static>) {
/// Relocations that appear in Operand::PCOffset. /// Relocations that appear in Operand::PCOffset.
fn is_pc_offset_reloc(reloc: Option<ResolvedRelocation>) -> Option<ResolvedRelocation> { fn is_pc_offset_reloc(reloc: Option<ResolvedRelocation>) -> Option<ResolvedRelocation> {
if let Some(resolved) = reloc { if let Some(resolved) = reloc
if let RelocationFlags::Elf( && let RelocationFlags::Elf(
elf::R_AARCH64_ADR_PREL_PG_HI21 elf::R_AARCH64_ADR_PREL_PG_HI21
| elf::R_AARCH64_JUMP26 | elf::R_AARCH64_JUMP26
| elf::R_AARCH64_CALL26 | elf::R_AARCH64_CALL26
@ -2077,7 +2094,6 @@ fn is_pc_offset_reloc(reloc: Option<ResolvedRelocation>) -> Option<ResolvedReloc
{ {
return Some(resolved); return Some(resolved);
} }
}
None None
} }

View File

@ -242,8 +242,8 @@ impl Arch for ArchMips {
object::RelocationFlags::Elf { r_type } => { object::RelocationFlags::Elf { r_type } => {
if relocation.has_implicit_addend() { if relocation.has_implicit_addend() {
// Check for paired R_MIPS_HI16 and R_MIPS_LO16 relocations. // Check for paired R_MIPS_HI16 and R_MIPS_LO16 relocations.
if let elf::R_MIPS_HI16 | elf::R_MIPS_LO16 = r_type { if let elf::R_MIPS_HI16 | elf::R_MIPS_LO16 = r_type
if let Some(addend) = self && let Some(addend) = self
.paired_relocations .paired_relocations
.get(section.index().0) .get(section.index().0)
.and_then(|m| m.get(&address).copied()) .and_then(|m| m.get(&address).copied())
@ -253,7 +253,6 @@ impl Arch for ArchMips {
addend, addend,
})); }));
} }
}
let data = section.data()?; let data = section.data()?;
let code = self let code = self

View File

@ -215,12 +215,12 @@ impl dyn Arch {
// Remove any branch destinations that are outside the function range // Remove any branch destinations that are outside the function range
for ins in result.iter_mut() { for ins in result.iter_mut() {
if let Some(branch_dest) = ins.branch_dest { if let Some(branch_dest) = ins.branch_dest
if branch_dest < function_start || branch_dest >= function_end { && (branch_dest < function_start || branch_dest >= function_end)
{
ins.branch_dest = None; ins.branch_dest = None;
} }
} }
}
// Resolve relocation targets within the same function to branch destinations // Resolve relocation targets within the same function to branch destinations
let mut ins_iter = result.iter_mut().peekable(); let mut ins_iter = result.iter_mut().peekable();

View File

@ -514,16 +514,16 @@ pub fn ppc_data_flow_analysis(
} }
fn get_string_data(obj: &Object, symbol_index: usize, offset: Simm) -> Option<&str> { fn get_string_data(obj: &Object, symbol_index: usize, offset: Simm) -> Option<&str> {
if let Some(sym) = obj.symbols.get(symbol_index) { if let Some(sym) = obj.symbols.get(symbol_index)
if sym.name.starts_with("@stringBase") && offset.0 != 0 { && sym.name.starts_with("@stringBase")
if let Some(data) = obj.symbol_data(symbol_index) { && offset.0 != 0
&& let Some(data) = obj.symbol_data(symbol_index)
{
let bytes = &data[offset.0 as usize..]; let bytes = &data[offset.0 as usize..];
if let Ok(Ok(str)) = CStr::from_bytes_until_nul(bytes).map(|x| x.to_str()) { if let Ok(Ok(str)) = CStr::from_bytes_until_nul(bytes).map(|x| x.to_str()) {
return Some(str); return Some(str);
} }
} }
}
}
None None
} }
@ -577,9 +577,9 @@ fn generate_flow_analysis_result(
let registers = register_state_at.get(index as usize).unwrap_or(&default_register_state); let registers = register_state_at.get(index as usize).unwrap_or(&default_register_state);
if let (powerpc::Opcode::Addi, Argument::GPR(rel), Argument::Simm(offset)) = if let (powerpc::Opcode::Addi, Argument::GPR(rel), Argument::Simm(offset)) =
(ins.op, args[1], args[2]) (ins.op, args[1], args[2])
&& let RegisterContent::Symbol(sym_index) = registers[rel]
&& let Some(str) = get_string_data(obj, sym_index, offset)
{ {
if let RegisterContent::Symbol(sym_index) = registers[rel] {
if let Some(str) = get_string_data(obj, sym_index, offset) {
// Show the string constant in the analysis result // Show the string constant in the analysis result
let formatted = format!("\"{str}\""); let formatted = format!("\"{str}\"");
analysis_result.set_argument_value_at_address( analysis_result.set_argument_value_at_address(
@ -589,8 +589,6 @@ fn generate_flow_analysis_result(
); );
// Don't continue, we want to show the stringbase value as well // Don't continue, we want to show the stringbase value as well
} }
}
}
let is_store = is_store_instruction(ins.op); let is_store = is_store_instruction(ins.op);
for (arg_index, arg) in args.into_iter().enumerate() { for (arg_index, arg) in args.into_iter().enumerate() {

View File

@ -866,8 +866,8 @@ fn generate_fake_pool_relocations_for_function(
break; break;
} }
} }
if let Some(branch_dest) = branch_dest { if let Some(branch_dest) = branch_dest
if branch_dest >= func_address as u32 && branch_dest >= func_address as u32
&& (branch_dest - func_address as u32) < code.len() as u32 && (branch_dest - func_address as u32) < code.len() as u32
{ {
let dest_offset_into_func = branch_dest - func_address as u32; let dest_offset_into_func = branch_dest - func_address as u32;
@ -897,14 +897,13 @@ fn generate_fake_pool_relocations_for_function(
_ => unreachable!(), _ => unreachable!(),
} }
} }
} if let Opcode::Bcctr = ins.op
if let Opcode::Bcctr = ins.op { && simplified.mnemonic == "bctr"
if simplified.mnemonic == "bctr" { {
// Unconditional branch to count register. // Unconditional branch to count register.
// Likely a jump table. // Likely a jump table.
gpr_state_at_bctr.insert(cur_addr, gpr_pool_relocs.clone()); gpr_state_at_bctr.insert(cur_addr, gpr_pool_relocs.clone());
} }
}
// Then handle keeping track of which GPR contains which pool relocation. // Then handle keeping track of which GPR contains which pool relocation.
let reloc = relocations.iter().find(|r| (r.address as u32 & !3) == cur_addr); let reloc = relocations.iter().find(|r| (r.address as u32 & !3) == cur_addr);

View File

@ -385,14 +385,14 @@ pub fn symbol_context(obj: &Object, symbol_index: usize) -> Vec<ContextItem> {
if let Some(name) = &symbol.demangled_name { if let Some(name) = &symbol.demangled_name {
out.push(ContextItem::Copy { value: name.clone(), label: None }); out.push(ContextItem::Copy { value: name.clone(), label: None });
} }
if symbol.section.is_some() { if symbol.section.is_some()
if let Some(address) = symbol.virtual_address { && let Some(address) = symbol.virtual_address
{
out.push(ContextItem::Copy { out.push(ContextItem::Copy {
value: format!("{address:x}"), value: format!("{address:x}"),
label: Some("virtual address".to_string()), label: Some("virtual address".to_string()),
}); });
} }
}
out.append(&mut obj.arch.symbol_context(obj, symbol_index)); out.append(&mut obj.arch.symbol_context(obj, symbol_index));
out out
} }

View File

@ -467,16 +467,16 @@ fn apply_symbol_mappings(
) -> Result<()> { ) -> Result<()> {
// If we're selecting a symbol to use as a comparison, mark it as used // If we're selecting a symbol to use as a comparison, mark it as used
// This ensures that we don't match it to another symbol at any point // This ensures that we don't match it to another symbol at any point
if let Some(left_name) = &mapping_config.selecting_left { if let Some(left_name) = &mapping_config.selecting_left
if let Some(left_symbol) = left.symbol_by_name(left_name) { && let Some(left_symbol) = left.symbol_by_name(left_name)
{
left_used.insert(left_symbol); left_used.insert(left_symbol);
} }
} if let Some(right_name) = &mapping_config.selecting_right
if let Some(right_name) = &mapping_config.selecting_right { && let Some(right_symbol) = right.symbol_by_name(right_name)
if let Some(right_symbol) = right.symbol_by_name(right_name) { {
right_used.insert(right_symbol); right_used.insert(right_symbol);
} }
}
// Apply manual symbol mappings // Apply manual symbol mappings
for (left_name, right_name) in &mapping_config.mappings { for (left_name, right_name) in &mapping_config.mappings {
@ -639,18 +639,17 @@ fn find_symbol(
// If they are at the same address in the same section // If they are at the same address in the same section
if in_symbol.name.starts_with('@') if in_symbol.name.starts_with('@')
&& matches!(section_kind, SectionKind::Data | SectionKind::Bss) && matches!(section_kind, SectionKind::Data | SectionKind::Bss)
{ && let Some((symbol_idx, _)) = unmatched_symbols(obj, used).find(|(_, symbol)| {
if let Some((symbol_idx, _)) = unmatched_symbols(obj, used).find(|(_, symbol)| {
let Some(section_index) = symbol.section else { let Some(section_index) = symbol.section else {
return false; return false;
}; };
symbol.name.starts_with('@') symbol.name.starts_with('@')
&& symbol.address == in_symbol.address && symbol.address == in_symbol.address
&& obj.sections[section_index].name == section_name && obj.sections[section_index].name == section_name
}) { })
{
return Some(symbol_idx); return Some(symbol_idx);
} }
}
// Match Metrowerks symbol$1234 against symbol$2345 // Match Metrowerks symbol$1234 against symbol$2345
if let Some((prefix, suffix)) = in_symbol.name.split_once('$') { if let Some((prefix, suffix)) = in_symbol.name.split_once('$') {
if !suffix.chars().all(char::is_numeric) { if !suffix.chars().all(char::is_numeric) {

View File

@ -550,15 +550,14 @@ fn perform_data_flow_analysis(obj: &mut Object, config: &DiffObjConfig) -> Resul
} }
// Optional full data flow analysis // Optional full data flow analysis
if config.analyze_data_flow { if config.analyze_data_flow
if let Some(flow_result) = && let Some(flow_result) =
obj.arch.data_flow_analysis(obj, symbol, code, &section.relocations) obj.arch.data_flow_analysis(obj, symbol, code, &section.relocations)
{ {
generated_flow_results.push((symbol.clone(), flow_result)); generated_flow_results.push((symbol.clone(), flow_result));
} }
} }
} }
}
for (symbol, flow_result) in generated_flow_results { for (symbol, flow_result) in generated_flow_results {
obj.add_flow_analysis_result(&symbol, flow_result); obj.add_flow_analysis_result(&symbol, flow_result);
} }

View File

@ -48,7 +48,7 @@ pub fn align_data_to_4<W: std::io::Write + ?Sized>(
len: usize, len: usize,
) -> std::io::Result<()> { ) -> std::io::Result<()> {
const ALIGN_BYTES: &[u8] = &[0; 4]; const ALIGN_BYTES: &[u8] = &[0; 4];
if len % 4 != 0 { if !len.is_multiple_of(4) {
writer.write_all(&ALIGN_BYTES[..4 - len % 4])?; writer.write_all(&ALIGN_BYTES[..4 - len % 4])?;
} }
Ok(()) Ok(())

View File

@ -526,15 +526,13 @@ impl App {
mod_check = true; mod_check = true;
} }
if mod_check { if mod_check
if let Some(info) = &state.project_config_info { && let Some(info) = &state.project_config_info
if let Some(last_ts) = info.timestamp { && let Some(last_ts) = info.timestamp
if file_modified(&info.path, last_ts) { && file_modified(&info.path, last_ts)
{
state.config_change = true; state.config_change = true;
} }
}
}
}
if state.config_change { if state.config_change {
state.config_change = false; state.config_change = false;
@ -581,24 +579,22 @@ impl App {
state.queue_build = true; state.queue_build = true;
} }
if let Some(result) = &diff_state.build { if let Some(result) = &diff_state.build
if mod_check { && mod_check
if let Some((obj, _)) = &result.first_obj { {
if let (Some(path), Some(timestamp)) = (&obj.path, obj.timestamp) { if let Some((obj, _)) = &result.first_obj
if file_modified(path, timestamp) { && let (Some(path), Some(timestamp)) = (&obj.path, obj.timestamp)
&& file_modified(path, timestamp)
{
state.queue_reload = true; state.queue_reload = true;
} }
} if let Some((obj, _)) = &result.second_obj
} && let (Some(path), Some(timestamp)) = (&obj.path, obj.timestamp)
if let Some((obj, _)) = &result.second_obj { && file_modified(path, timestamp)
if let (Some(path), Some(timestamp)) = (&obj.path, obj.timestamp) { {
if file_modified(path, timestamp) {
state.queue_reload = true; state.queue_reload = true;
} }
} }
}
}
}
// Don't clear `queue_build` if a build is running. A file may have been modified during // Don't clear `queue_build` if a build is running. A file may have been modified during
// the build, so we'll start another build after the current one finishes. // the build, so we'll start another build after the current one finishes.
@ -618,15 +614,14 @@ impl App {
state.queue_reload = false; state.queue_reload = false;
} }
if graphics_state.should_relaunch { if graphics_state.should_relaunch
if let Some(app_path) = &self.app_path { && let Some(app_path) = &self.app_path
if let Ok(mut guard) = self.relaunch_path.lock() { && let Ok(mut guard) = self.relaunch_path.lock()
{
*guard = Some(app_path.clone()); *guard = Some(app_path.clone());
self.should_relaunch = true; self.should_relaunch = true;
} }
} }
}
}
} }
impl eframe::App for App { impl eframe::App for App {

View File

@ -173,8 +173,9 @@ fn main() -> ExitCode {
} }
// Attempt to relaunch application from the updated path // Attempt to relaunch application from the updated path
if let Ok(mut guard) = exec_path.lock() { if let Ok(mut guard) = exec_path.lock()
if let Some(path) = guard.take() { && let Some(path) = guard.take()
{
cfg_if! { cfg_if! {
if #[cfg(unix)] { if #[cfg(unix)] {
let e = exec::Command::new(path) let e = exec::Command::new(path)
@ -192,7 +193,6 @@ fn main() -> ExitCode {
} }
} }
} }
}
}; };
ExitCode::SUCCESS ExitCode::SUCCESS
} }

View File

@ -185,8 +185,8 @@ pub fn config_ui(
if result.update_available { if result.update_available {
ui.colored_label(appearance.insert_color, "Update available"); ui.colored_label(appearance.insert_color, "Update available");
ui.horizontal(|ui| { ui.horizontal(|ui| {
if let Some(bin_name) = &result.found_binary { if let Some(bin_name) = &result.found_binary
if ui && ui
.add_enabled(!config_state.update_running, egui::Button::new("Automatic")) .add_enabled(!config_state.update_running, egui::Button::new("Automatic"))
.on_hover_text_at_pointer( .on_hover_text_at_pointer(
"Automatically download and replace the current build", "Automatically download and replace the current build",
@ -195,7 +195,6 @@ pub fn config_ui(
{ {
config_state.queue_update = Some(bin_name.clone()); config_state.queue_update = Some(bin_name.clone());
} }
}
if ui if ui
.button("Manual") .button("Manual")
.on_hover_text_at_pointer("Open a link to the latest release on GitHub") .on_hover_text_at_pointer("Open a link to the latest release on GitHub")
@ -329,13 +328,13 @@ pub fn config_ui(
}); });
}); });
} }
if new_selected_index != selected_index { if new_selected_index != selected_index
if let Some(idx) = new_selected_index { && let Some(idx) = new_selected_index
{
// Will set obj_changed, which will trigger a rebuild // Will set obj_changed, which will trigger a rebuild
let config = objects[idx].clone(); let config = objects[idx].clone();
state_guard.set_selected_obj(config); state_guard.set_selected_obj(config);
} }
}
} }
fn display_unit( fn display_unit(
@ -374,8 +373,8 @@ fn display_unit(
} }
fn object_context_ui(ui: &mut egui::Ui, object: &ObjectConfig) { fn object_context_ui(ui: &mut egui::Ui, object: &ObjectConfig) {
if let Some(source_path) = &object.source_path { if let Some(source_path) = &object.source_path
if ui && ui
.button("Open source file") .button("Open source file")
.on_hover_text("Open the source file in the default editor") .on_hover_text("Open the source file in the default editor")
.clicked() .clicked()
@ -386,7 +385,6 @@ fn object_context_ui(ui: &mut egui::Ui, object: &ObjectConfig) {
} }
ui.close(); ui.close();
} }
}
} }
#[derive(Default, Copy, Clone, PartialEq, Eq, Debug)] #[derive(Default, Copy, Clone, PartialEq, Eq, Debug)]
@ -835,13 +833,12 @@ fn split_obj_config_ui(
.add_enabled(state.project_config_info.is_none(), egui::Button::new("+").small()) .add_enabled(state.project_config_info.is_none(), egui::Button::new("+").small())
.on_disabled_hover_text(CONFIG_DISABLED_TEXT) .on_disabled_hover_text(CONFIG_DISABLED_TEXT)
.clicked() .clicked()
&& let Ok(glob) = Glob::new(&config_state.watch_pattern_text)
{ {
if let Ok(glob) = Glob::new(&config_state.watch_pattern_text) {
state.config.watch_patterns.push(glob); state.config.watch_patterns.push(glob);
state.watcher_change = true; state.watcher_change = true;
config_state.watch_pattern_text.clear(); config_state.watch_pattern_text.clear();
} }
}
}); });
} }

View File

@ -164,7 +164,7 @@ pub(crate) fn data_row_ui(
write_text(byte_text.as_str(), byte_color, &mut job, appearance.code_font.clone()); write_text(byte_text.as_str(), byte_color, &mut job, appearance.code_font.clone());
cur_addr += 1; cur_addr += 1;
cur_addr_actual += 1; cur_addr_actual += 1;
if cur_addr % 8 == 0 { if cur_addr.is_multiple_of(8) {
write_text(" ", base_color, &mut job, appearance.code_font.clone()); write_text(" ", base_color, &mut job, appearance.code_font.clone());
} }
} }

View File

@ -128,11 +128,11 @@ pub fn diff_view_ui(
let mut navigation = current_navigation.clone(); let mut navigation = current_navigation.clone();
if let Some((_symbol, symbol_diff, _symbol_idx)) = left_ctx.symbol { if let Some((_symbol, symbol_diff, _symbol_idx)) = left_ctx.symbol {
// If a matching symbol appears, select it // If a matching symbol appears, select it
if !right_ctx.has_symbol() { if !right_ctx.has_symbol()
if let Some(target_symbol_ref) = symbol_diff.target_symbol { && let Some(target_symbol_ref) = symbol_diff.target_symbol
{
navigation.right_symbol = Some(target_symbol_ref); navigation.right_symbol = Some(target_symbol_ref);
} }
}
} else if navigation.left_symbol.is_some() } else if navigation.left_symbol.is_some()
&& left_ctx.obj.is_some() && left_ctx.obj.is_some()
&& left_ctx.section.is_none() && left_ctx.section.is_none()
@ -142,11 +142,11 @@ pub fn diff_view_ui(
} }
if let Some((_symbol, symbol_diff, _symbol_idx)) = right_ctx.symbol { if let Some((_symbol, symbol_diff, _symbol_idx)) = right_ctx.symbol {
// If a matching symbol appears, select it // If a matching symbol appears, select it
if !left_ctx.has_symbol() { if !left_ctx.has_symbol()
if let Some(target_symbol_ref) = symbol_diff.target_symbol { && let Some(target_symbol_ref) = symbol_diff.target_symbol
{
navigation.left_symbol = Some(target_symbol_ref); navigation.left_symbol = Some(target_symbol_ref);
} }
}
} else if navigation.right_symbol.is_some() } else if navigation.right_symbol.is_some()
&& right_ctx.obj.is_some() && right_ctx.obj.is_some()
&& right_ctx.section.is_none() && right_ctx.section.is_none()
@ -247,17 +247,16 @@ pub fn diff_view_ui(
// Third row // Third row
if left_ctx.has_symbol() && right_ctx.has_symbol() { if left_ctx.has_symbol() && right_ctx.has_symbol() {
if state.current_view == View::FunctionDiff if (state.current_view == View::FunctionDiff
&& ui && ui
.button("Change target") .button("Change target")
.on_hover_text_at_pointer("Choose a different symbol to use as the target") .on_hover_text_at_pointer("Choose a different symbol to use as the target")
.clicked() .clicked()
|| hotkeys::consume_change_target_shortcut(ui.ctx()) || hotkeys::consume_change_target_shortcut(ui.ctx()))
&& let Some(symbol_ref) = state.symbol_state.right_symbol.as_ref()
{ {
if let Some(symbol_ref) = state.symbol_state.right_symbol.as_ref() {
ret = Some(DiffViewAction::SelectingLeft(symbol_ref.clone())); ret = Some(DiffViewAction::SelectingLeft(symbol_ref.clone()));
} }
}
} else if left_ctx.status.success && !left_ctx.has_symbol() { } else if left_ctx.status.success && !left_ctx.has_symbol() {
ui.horizontal(|ui| { ui.horizontal(|ui| {
let mut search = state.search.clone(); let mut search = state.search.clone();
@ -409,19 +408,18 @@ pub fn diff_view_ui(
if needs_separator { if needs_separator {
ui.separator(); ui.separator();
} }
if ui if (ui
.button("Change base") .button("Change base")
.on_hover_text_at_pointer( .on_hover_text_at_pointer(
"Choose a different symbol to use as the base", "Choose a different symbol to use as the base",
) )
.clicked() .clicked()
|| hotkeys::consume_change_base_shortcut(ui.ctx()) || hotkeys::consume_change_base_shortcut(ui.ctx()))
&& let Some(symbol_ref) = state.symbol_state.left_symbol.as_ref()
{ {
if let Some(symbol_ref) = state.symbol_state.left_symbol.as_ref() {
ret = Some(DiffViewAction::SelectingRight(symbol_ref.clone())); ret = Some(DiffViewAction::SelectingRight(symbol_ref.clone()));
} }
} }
}
} else if right_ctx.status.success && !right_ctx.has_symbol() { } else if right_ctx.status.success && !right_ctx.has_symbol() {
let mut search = state.search.clone(); let mut search = state.search.clone();
let response = let response =
@ -583,8 +581,8 @@ pub fn diff_view_ui(
) { ) {
ret = Some(action); ret = Some(action);
} }
} else if column == 1 { } else if column == 1
if let Some(action) = diff_col_ui( && let Some(action) = diff_col_ui(
ui, ui,
state, state,
appearance, appearance,
@ -594,10 +592,10 @@ pub fn diff_view_ui(
available_width, available_width,
open_sections.1, open_sections.1,
diff_config, diff_config,
) { )
{
ret = Some(action); ret = Some(action);
} }
}
}); });
} }
}); });

View File

@ -211,20 +211,20 @@ impl DiffViewState {
let mut resolved_left = self.resolve_symbol(nav.left_symbol, 0); let mut resolved_left = self.resolve_symbol(nav.left_symbol, 0);
let mut resolved_right = self.resolve_symbol(nav.right_symbol, 1); let mut resolved_right = self.resolve_symbol(nav.right_symbol, 1);
if let Some(resolved_right) = &resolved_right { if let Some(resolved_right) = &resolved_right
if resolved_left.is_none() { && resolved_left.is_none()
{
resolved_left = resolved_right resolved_left = resolved_right
.target_symbol .target_symbol
.and_then(|idx| self.resolve_symbol(Some(idx), 0)); .and_then(|idx| self.resolve_symbol(Some(idx), 0));
} }
} if let Some(resolved_left) = &resolved_left
if let Some(resolved_left) = &resolved_left { && resolved_right.is_none()
if resolved_right.is_none() { {
resolved_right = resolved_left resolved_right = resolved_left
.target_symbol .target_symbol
.and_then(|idx| self.resolve_symbol(Some(idx), 1)); .and_then(|idx| self.resolve_symbol(Some(idx), 1));
} }
}
let resolved_nav = resolve_navigation(nav.kind, resolved_left, resolved_right); let resolved_nav = resolve_navigation(nav.kind, resolved_left, resolved_right);
if (resolved_nav.left_symbol.is_some() && resolved_nav.right_symbol.is_some()) if (resolved_nav.left_symbol.is_some() && resolved_nav.right_symbol.is_some())
|| (resolved_nav.left_symbol.is_none() && resolved_nav.right_symbol.is_none()) || (resolved_nav.left_symbol.is_none() && resolved_nav.right_symbol.is_none())
@ -500,8 +500,9 @@ pub fn symbol_context_menu_ui(
ret = Some(action); ret = Some(action);
} }
if let Some(section) = section { if let Some(section) = section
if ui.button("Map symbol").clicked() { && ui.button("Map symbol").clicked()
{
let symbol_ref = SymbolRefByName::new(symbol, Some(section)); let symbol_ref = SymbolRefByName::new(symbol, Some(section));
if column == 0 { if column == 0 {
ret = Some(DiffViewAction::SelectingRight(symbol_ref)); ret = Some(DiffViewAction::SelectingRight(symbol_ref));
@ -510,7 +511,6 @@ pub fn symbol_context_menu_ui(
} }
ui.close(); ui.close();
} }
}
}); });
ret ret
} }
@ -664,11 +664,11 @@ pub fn symbol_list_ui(
let mut ret = None; let mut ret = None;
ScrollArea::both().auto_shrink([false, false]).show(ui, |ui| { ScrollArea::both().auto_shrink([false, false]).show(ui, |ui| {
let mut show_mapped_symbols = state.show_mapped_symbols; let mut show_mapped_symbols = state.show_mapped_symbols;
if let SymbolFilter::Mapping(_, _) = filter { if let SymbolFilter::Mapping(_, _) = filter
if ui.checkbox(&mut show_mapped_symbols, "Show mapped symbols").changed() { && ui.checkbox(&mut show_mapped_symbols, "Show mapped symbols").changed()
{
ret = Some(DiffViewAction::SetShowMappedSymbols(show_mapped_symbols)); ret = Some(DiffViewAction::SetShowMappedSymbols(show_mapped_symbols));
} }
}
let section_display = display_sections( let section_display = display_sections(
ctx.obj, ctx.obj,
ctx.diff, ctx.diff,