Skip to content

Commit

Permalink
riscv : Remove uses of BnString per #5244
Browse files Browse the repository at this point in the history
  • Loading branch information
ElykDeer committed Apr 9, 2024
1 parent 193dea9 commit 6a30286
Showing 1 changed file with 17 additions and 18 deletions.
35 changes: 17 additions & 18 deletions arch/riscv/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ use binaryninja::{
CoreRelocationHandler, CustomRelocationHandlerHandle, RelocationHandler, RelocationInfo,
RelocationType,
},
string::BnString,
symbol::{Symbol, SymbolType},
types::{max_confidence, min_confidence, Conf, NameAndType, Type},
};
Expand Down Expand Up @@ -969,36 +968,36 @@ impl<D: 'static + RiscVDisassembler + Send + Sync> architecture::Architecture fo
_ => (),
}

res.push(InstructionTextToken::new(BnString::new(mnem), Instruction));
res.push(InstructionTextToken::new(&mnem, Instruction));

for (i, oper) in operands.iter().enumerate() {
if i == 0 {
res.push(InstructionTextToken::new(
BnString::new(format!("{:1$}", " ", pad_len)),
&format!("{:1$}", " ", pad_len),
Text,
));
} else {
res.push(InstructionTextToken::new(
BnString::new(","),
",",
OperandSeparator,
));
res.push(InstructionTextToken::new(BnString::new(" "), Text));
res.push(InstructionTextToken::new(" ", Text));
}

match *oper {
Operand::R(r) => {
let reg = self::Register::from(r);

res.push(InstructionTextToken::new(
BnString::new(&reg.name()),
&reg.name(),
Register,
));
}
Operand::F(r) => {
let reg = self::Register::from(r);

res.push(InstructionTextToken::new(
BnString::new(&reg.name()),
&reg.name(),
Register,
));
}
Expand All @@ -1015,16 +1014,16 @@ impl<D: 'static + RiscVDisassembler + Send + Sync> architecture::Architecture fo
let target = addr.wrapping_add(i as i64 as u64);

res.push(InstructionTextToken::new(
BnString::new(format!("0x{:x}", target)),
&format!("0x{:x}", target),
CodeRelativeAddress(target),
));
}
_ => {
res.push(InstructionTextToken::new(
BnString::new(match i {
&match i {
-0x8_0000..=-1 => format!("-0x{:x}", -i),
_ => format!("0x{:x}", i),
}),
},
Integer(i as u64),
));
}
Expand All @@ -1034,31 +1033,31 @@ impl<D: 'static + RiscVDisassembler + Send + Sync> architecture::Architecture fo
let reg = self::Register::from(b);

res.push(InstructionTextToken::new(
BnString::new(""),
"",
BeginMemoryOperand,
));
res.push(InstructionTextToken::new(
BnString::new(if i < 0 {
&if i < 0 {
format!("-0x{:x}", -i)
} else {
format!("0x{:x}", i)
}),
},
Integer(i as u64),
));

res.push(InstructionTextToken::new(BnString::new("("), Brace));
res.push(InstructionTextToken::new("(", Brace));
res.push(InstructionTextToken::new(
BnString::new(&reg.name()),
&reg.name(),
Register,
));
res.push(InstructionTextToken::new(BnString::new(")"), Brace));
res.push(InstructionTextToken::new(")", Brace));
res.push(InstructionTextToken::new(
BnString::new(""),
"",
EndMemoryOperand,
));
}
Operand::RM(r) => {
res.push(InstructionTextToken::new(BnString::new(r.name()), Register));
res.push(InstructionTextToken::new(r.name(), Register));
}
}
}
Expand Down

0 comments on commit 6a30286

Please sign in to comment.