MCPcopy Index your code
hub / github.com/encounter/objdiff / write_instruction_part

Function write_instruction_part

objdiff-core/src/bindings/diff.rs:205–239  ·  view source on GitHub ↗
(
    out: &mut String,
    part: &InstructionPart,
    separator: &str,
    reloc: Option<obj::ResolvedRelocation>,
)

Source from the content-addressed store, hash-verified

203}
204
205fn write_instruction_part(
206 out: &mut String,
207 part: &InstructionPart,
208 separator: &str,
209 reloc: Option<obj::ResolvedRelocation>,
210) {
211 match part {
212 InstructionPart::Basic(s) => out.push_str(s),
213 InstructionPart::Opcode(s, _) => {
214 out.push_str(s);
215 out.push(' ');
216 }
217 InstructionPart::Arg(arg) => match arg {
218 obj::InstructionArg::Value(v) => {
219 let _ = write!(out, "{}", v);
220 }
221 obj::InstructionArg::Reloc => {
222 if let Some(resolved) = reloc {
223 out.push_str(&resolved.symbol.name);
224 if resolved.relocation.addend != 0 {
225 if resolved.relocation.addend < 0 {
226 let _ = write!(out, "-{:#x}", -resolved.relocation.addend);
227 } else {
228 let _ = write!(out, "+{:#x}", resolved.relocation.addend);
229 }
230 }
231 }
232 }
233 obj::InstructionArg::BranchDest(dest) => {
234 let _ = write!(out, "{:#x}", dest);
235 }
236 },
237 InstructionPart::Separator => out.push_str(separator),
238 }
239}
240
241impl diff_instruction_part::Part {
242 fn from(part: &InstructionPart) -> Self {

Callers 1

newMethod · 0.85

Calls 1

pushMethod · 0.80

Tested by

no test coverage detected