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

Method write_number

objdiff-core/src/arch/x86.rs:461–515  ·  view source on GitHub ↗
(
        &mut self,
        instruction: &Instruction,
        _operand: u32,
        instruction_operand: Option<u32>,
        _text: &str,
        value: u64,
        number_kind: NumberKind,
     

Source from the content-addressed store, hash-verified

459 }
460
461 fn write_number(
462 &mut self,
463 instruction: &Instruction,
464 _operand: u32,
465 instruction_operand: Option<u32>,
466 _text: &str,
467 value: u64,
468 number_kind: NumberKind,
469 kind: FormatterTextKind,
470 ) {
471 if self.error.is_some() {
472 return;
473 }
474
475 if let (Some(operand), Some((target_op_kind, reloc_size, target_value))) =
476 (instruction_operand, self.reloc_replace)
477 {
478 #[allow(clippy::match_like_matches_macro)]
479 if instruction.op_kind(operand) == target_op_kind
480 && match (number_kind, reloc_size) {
481 (NumberKind::Int8 | NumberKind::UInt8, 1)
482 | (NumberKind::Int16 | NumberKind::UInt16, 2)
483 | (NumberKind::Int32 | NumberKind::UInt32, 4)
484 | (NumberKind::Int64 | NumberKind::UInt64, 4) // x86_64
485 | (NumberKind::Int64 | NumberKind::UInt64, 8) => true,
486 _ => false,
487 }
488 && value == target_value
489 {
490 if let Err(e) = (self.cb)(InstructionPart::reloc()) {
491 self.error = Some(e);
492 }
493 return;
494 }
495 }
496
497 if let FormatterTextKind::LabelAddress | FormatterTextKind::FunctionAddress = kind {
498 if let Err(e) = (self.cb)(InstructionPart::branch_dest(value)) {
499 self.error = Some(e);
500 }
501 return;
502 }
503
504 match number_kind {
505 NumberKind::Int8 => self.push_signed(value as i8 as i64),
506 NumberKind::Int16 => self.push_signed(value as i16 as i64),
507 NumberKind::Int32 => self.push_signed(value as i32 as i64),
508 NumberKind::Int64 => self.push_signed(value as i64),
509 NumberKind::UInt8 | NumberKind::UInt16 | NumberKind::UInt32 | NumberKind::UInt64 => {
510 if let Err(e) = (self.cb)(InstructionPart::unsigned(value)) {
511 self.error = Some(e);
512 }
513 }
514 }
515 }
516
517 fn write_decorator(
518 &mut self,

Callers

nothing calls this directly

Calls 3

branch_destFunction · 0.85
is_someMethod · 0.80
push_signedMethod · 0.80

Tested by

no test coverage detected