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

Function push_args

objdiff-core/src/arch/mips.rs:381–456  ·  view source on GitHub ↗
(
    instruction: &rabbitizer::Instruction,
    relocation: Option<ResolvedRelocation>,
    display_flags: &rabbitizer::InstructionDisplayFlags,
    mut arg_cb: impl FnMut(InstructionPart) -> Result<

Source from the content-addressed store, hash-verified

379}
380
381fn push_args(
382 instruction: &rabbitizer::Instruction,
383 relocation: Option<ResolvedRelocation>,
384 display_flags: &rabbitizer::InstructionDisplayFlags,
385 mut arg_cb: impl FnMut(InstructionPart) -> Result<()>,
386) -> Result<()> {
387 let operands = instruction.valued_operands_iter();
388 for (idx, op) in operands.enumerate() {
389 if idx > 0 {
390 arg_cb(InstructionPart::separator())?;
391 }
392
393 match op {
394 ValuedOperand::core_imm_i16(imm) => {
395 if let Some(resolved) = relocation {
396 push_reloc(resolved.relocation, &mut arg_cb)?;
397 } else {
398 arg_cb(InstructionPart::signed(imm))?;
399 }
400 }
401 ValuedOperand::core_imm_u16(imm) => {
402 if let Some(resolved) = relocation {
403 push_reloc(resolved.relocation, &mut arg_cb)?;
404 } else {
405 arg_cb(InstructionPart::unsigned(imm))?;
406 }
407 }
408 ValuedOperand::core_label(..) | ValuedOperand::core_branch_target_label(..) => {
409 if let Some(resolved) = relocation {
410 push_reloc(resolved.relocation, &mut arg_cb)?;
411 } else if let Some(branch_dest) = instruction
412 .get_branch_offset_generic()
413 .map(|o| (instruction.vram() + o).inner() as u64)
414 {
415 arg_cb(InstructionPart::branch_dest(branch_dest))?;
416 } else {
417 arg_cb(InstructionPart::opaque(
418 op.display(instruction, display_flags, None::<&str>).to_string(),
419 ))?;
420 }
421 }
422 ValuedOperand::core_imm_rs(imm, base) => {
423 if let Some(resolved) = relocation {
424 push_reloc(resolved.relocation, &mut arg_cb)?;
425 } else {
426 arg_cb(InstructionPart::Arg(InstructionArg::Value(
427 InstructionArgValue::Signed(imm as i64),
428 )))?;
429 }
430 arg_cb(InstructionPart::basic("("))?;
431 arg_cb(InstructionPart::opaque(base.either_name(
432 instruction.flags().abi(),
433 display_flags.named_gpr(),
434 !display_flags.use_dollar(),
435 )))?;
436 arg_cb(InstructionPart::basic(")"))?;
437 }
438 // ValuedOperand::r5900_immediate15(..) => match relocation {

Callers 1

display_instructionMethod · 0.85

Calls 2

push_relocFunction · 0.85
branch_destFunction · 0.85

Tested by

no test coverage detected