@@ -7,7 +7,7 @@ use binaryninja::{
77 Architecture , CoreArchitecture , CustomArchitectureHandle , FlagCondition ,
88 InstructionInfo , UnusedIntrinsic , UnusedRegisterStack , UnusedRegisterStackInfo ,
99 } ,
10- disassembly:: { InstructionTextToken , InstructionTextTokenContents } ,
10+ disassembly:: { InstructionTextToken , InstructionTextTokenKind } ,
1111 llil:: { LiftedExpr , Lifter } ,
1212 Endianness ,
1313} ;
@@ -400,7 +400,7 @@ fn generate_tokens(inst: &Instruction, addr: u64) -> Vec<InstructionTextToken> {
400400 Instruction :: Call ( inst) => generate_single_operand_tokens ( inst, addr, true ) ,
401401 Instruction :: Reti ( _) => vec ! [ InstructionTextToken :: new(
402402 "reti" ,
403- InstructionTextTokenContents :: Instruction ,
403+ InstructionTextTokenKind :: Instruction ,
404404 ) ] ,
405405
406406 // Jxx instructions
@@ -462,14 +462,14 @@ fn generate_single_operand_tokens(
462462) -> Vec < InstructionTextToken > {
463463 let mut res = vec ! [ InstructionTextToken :: new(
464464 inst. mnemonic( ) ,
465- InstructionTextTokenContents :: Instruction ,
465+ InstructionTextTokenKind :: Instruction ,
466466 ) ] ;
467467
468468 if inst. mnemonic ( ) . len ( ) < MIN_MNEMONIC {
469469 let padding = " " . repeat ( MIN_MNEMONIC - inst. mnemonic ( ) . len ( ) ) ;
470470 res. push ( InstructionTextToken :: new (
471471 & padding,
472- InstructionTextTokenContents :: Text ,
472+ InstructionTextTokenKind :: Text ,
473473 ) )
474474 }
475475
@@ -483,20 +483,23 @@ fn generate_jxx_tokens(inst: &impl Jxx, addr: u64) -> Vec<InstructionTextToken>
483483
484484 let mut res = vec ! [ InstructionTextToken :: new(
485485 inst. mnemonic( ) ,
486- InstructionTextTokenContents :: Instruction ,
486+ InstructionTextTokenKind :: Instruction ,
487487 ) ] ;
488488
489489 if inst. mnemonic ( ) . len ( ) < MIN_MNEMONIC {
490490 let padding = " " . repeat ( MIN_MNEMONIC - inst. mnemonic ( ) . len ( ) ) ;
491491 res. push ( InstructionTextToken :: new (
492492 & padding,
493- InstructionTextTokenContents :: Text ,
493+ InstructionTextTokenKind :: Text ,
494494 ) )
495495 }
496496
497497 res. push ( InstructionTextToken :: new (
498498 & format ! ( "0x{fixed_addr:4x}" ) ,
499- InstructionTextTokenContents :: CodeRelativeAddress ( fixed_addr) ,
499+ InstructionTextTokenKind :: CodeRelativeAddress {
500+ value : fixed_addr,
501+ size : None ,
502+ } ,
500503 ) ) ;
501504
502505 res
@@ -505,21 +508,21 @@ fn generate_jxx_tokens(inst: &impl Jxx, addr: u64) -> Vec<InstructionTextToken>
505508fn generate_two_operand_tokens ( inst : & impl TwoOperand , addr : u64 ) -> Vec < InstructionTextToken > {
506509 let mut res = vec ! [ InstructionTextToken :: new(
507510 inst. mnemonic( ) ,
508- InstructionTextTokenContents :: Instruction ,
511+ InstructionTextTokenKind :: Instruction ,
509512 ) ] ;
510513
511514 if inst. mnemonic ( ) . len ( ) < MIN_MNEMONIC {
512515 let padding = " " . repeat ( MIN_MNEMONIC - inst. mnemonic ( ) . len ( ) ) ;
513516 res. push ( InstructionTextToken :: new (
514517 & padding,
515- InstructionTextTokenContents :: Text ,
518+ InstructionTextTokenKind :: Text ,
516519 ) )
517520 }
518521
519522 res. extend_from_slice ( & generate_operand_tokens ( inst. source ( ) , addr, false ) ) ;
520523 res. push ( InstructionTextToken :: new (
521524 ", " ,
522- InstructionTextTokenContents :: OperandSeparator ,
525+ InstructionTextTokenKind :: OperandSeparator ,
523526 ) ) ;
524527 res. extend_from_slice ( & generate_operand_tokens ( inst. destination ( ) , addr, false ) ) ;
525528
@@ -533,14 +536,14 @@ fn generate_emulated_tokens(
533536) -> Vec < InstructionTextToken > {
534537 let mut res = vec ! [ InstructionTextToken :: new(
535538 inst. mnemonic( ) ,
536- InstructionTextTokenContents :: Instruction ,
539+ InstructionTextTokenKind :: Instruction ,
537540 ) ] ;
538541
539542 if inst. mnemonic ( ) . len ( ) < MIN_MNEMONIC {
540543 let padding = " " . repeat ( MIN_MNEMONIC - inst. mnemonic ( ) . len ( ) ) ;
541544 res. push ( InstructionTextToken :: new (
542545 & padding,
543- InstructionTextTokenContents :: Text ,
546+ InstructionTextTokenKind :: Text ,
544547 ) )
545548 }
546549
@@ -560,23 +563,23 @@ fn generate_operand_tokens(source: &Operand, addr: u64, call: bool) -> Vec<Instr
560563 Operand :: RegisterDirect ( r) => match r {
561564 0 => vec ! [ InstructionTextToken :: new(
562565 "pc" ,
563- InstructionTextTokenContents :: Register ,
566+ InstructionTextTokenKind :: Register ,
564567 ) ] ,
565568 1 => vec ! [ InstructionTextToken :: new(
566569 "sp" ,
567- InstructionTextTokenContents :: Register ,
570+ InstructionTextTokenKind :: Register ,
568571 ) ] ,
569572 2 => vec ! [ InstructionTextToken :: new(
570573 "sr" ,
571- InstructionTextTokenContents :: Register ,
574+ InstructionTextTokenKind :: Register ,
572575 ) ] ,
573576 3 => vec ! [ InstructionTextToken :: new(
574577 "cg" ,
575- InstructionTextTokenContents :: Register ,
578+ InstructionTextTokenKind :: Register ,
576579 ) ] ,
577580 _ => vec ! [ InstructionTextToken :: new(
578581 & format!( "r{r}" ) ,
579- InstructionTextTokenContents :: Register ,
582+ InstructionTextTokenKind :: Register ,
580583 ) ] ,
581584 } ,
582585 Operand :: Indexed ( ( r, i) ) => match r {
@@ -589,11 +592,14 @@ fn generate_operand_tokens(source: &Operand, addr: u64, call: bool) -> Vec<Instr
589592 vec ! [
590593 InstructionTextToken :: new(
591594 & num_text,
592- InstructionTextTokenContents :: Integer ( * i as u64 ) ,
595+ InstructionTextTokenKind :: Integer {
596+ value: * i as u64 ,
597+ size: None ,
598+ } ,
593599 ) ,
594- InstructionTextToken :: new( "(" , InstructionTextTokenContents :: Text ) ,
595- InstructionTextToken :: new( "pc" , InstructionTextTokenContents :: Register ) ,
596- InstructionTextToken :: new( ")" , InstructionTextTokenContents :: Text ) ,
600+ InstructionTextToken :: new( "(" , InstructionTextTokenKind :: Text ) ,
601+ InstructionTextToken :: new( "pc" , InstructionTextTokenKind :: Register ) ,
602+ InstructionTextToken :: new( ")" , InstructionTextTokenKind :: Text ) ,
597603 ]
598604 }
599605 1 => {
@@ -605,11 +611,14 @@ fn generate_operand_tokens(source: &Operand, addr: u64, call: bool) -> Vec<Instr
605611 vec ! [
606612 InstructionTextToken :: new(
607613 & num_text,
608- InstructionTextTokenContents :: Integer ( * i as u64 ) ,
614+ InstructionTextTokenKind :: Integer {
615+ value: * i as u64 ,
616+ size: None ,
617+ } ,
609618 ) ,
610- InstructionTextToken :: new( "(" , InstructionTextTokenContents :: Text ) ,
611- InstructionTextToken :: new( "sp" , InstructionTextTokenContents :: Register ) ,
612- InstructionTextToken :: new( ")" , InstructionTextTokenContents :: Text ) ,
619+ InstructionTextToken :: new( "(" , InstructionTextTokenKind :: Text ) ,
620+ InstructionTextToken :: new( "sp" , InstructionTextTokenKind :: Register ) ,
621+ InstructionTextToken :: new( ")" , InstructionTextTokenKind :: Text ) ,
613622 ]
614623 }
615624 2 => {
@@ -621,11 +630,14 @@ fn generate_operand_tokens(source: &Operand, addr: u64, call: bool) -> Vec<Instr
621630 vec ! [
622631 InstructionTextToken :: new(
623632 & num_text,
624- InstructionTextTokenContents :: Integer ( * i as u64 ) ,
633+ InstructionTextTokenKind :: Integer {
634+ value: * i as u64 ,
635+ size: None ,
636+ } ,
625637 ) ,
626- InstructionTextToken :: new( "(" , InstructionTextTokenContents :: Text ) ,
627- InstructionTextToken :: new( "sr" , InstructionTextTokenContents :: Register ) ,
628- InstructionTextToken :: new( ")" , InstructionTextTokenContents :: Text ) ,
638+ InstructionTextToken :: new( "(" , InstructionTextTokenKind :: Text ) ,
639+ InstructionTextToken :: new( "sr" , InstructionTextTokenKind :: Register ) ,
640+ InstructionTextToken :: new( ")" , InstructionTextTokenKind :: Text ) ,
629641 ]
630642 }
631643 3 => {
@@ -637,11 +649,14 @@ fn generate_operand_tokens(source: &Operand, addr: u64, call: bool) -> Vec<Instr
637649 vec ! [
638650 InstructionTextToken :: new(
639651 & num_text,
640- InstructionTextTokenContents :: Integer ( * i as u64 ) ,
652+ InstructionTextTokenKind :: Integer {
653+ value: * i as u64 ,
654+ size: None ,
655+ } ,
641656 ) ,
642- InstructionTextToken :: new( "(" , InstructionTextTokenContents :: Text ) ,
643- InstructionTextToken :: new( "cg" , InstructionTextTokenContents :: Register ) ,
644- InstructionTextToken :: new( ")" , InstructionTextTokenContents :: Text ) ,
657+ InstructionTextToken :: new( "(" , InstructionTextTokenKind :: Text ) ,
658+ InstructionTextToken :: new( "cg" , InstructionTextTokenKind :: Register ) ,
659+ InstructionTextToken :: new( ")" , InstructionTextTokenKind :: Text ) ,
645660 ]
646661 }
647662 _ => {
@@ -653,14 +668,17 @@ fn generate_operand_tokens(source: &Operand, addr: u64, call: bool) -> Vec<Instr
653668 vec ! [
654669 InstructionTextToken :: new(
655670 & num_text,
656- InstructionTextTokenContents :: Integer ( * i as u64 ) ,
671+ InstructionTextTokenKind :: Integer {
672+ value: * i as u64 ,
673+ size: None ,
674+ } ,
657675 ) ,
658- InstructionTextToken :: new( "(" , InstructionTextTokenContents :: Text ) ,
676+ InstructionTextToken :: new( "(" , InstructionTextTokenKind :: Text ) ,
659677 InstructionTextToken :: new(
660678 & format!( "r{r}" ) ,
661- InstructionTextTokenContents :: Register ,
679+ InstructionTextTokenKind :: Register ,
662680 ) ,
663- InstructionTextToken :: new( ")" , InstructionTextTokenContents :: Text ) ,
681+ InstructionTextToken :: new( ")" , InstructionTextTokenKind :: Text ) ,
664682 ]
665683 }
666684 } ,
@@ -672,8 +690,8 @@ fn generate_operand_tokens(source: &Operand, addr: u64, call: bool) -> Vec<Instr
672690 } ;
673691
674692 vec ! [
675- InstructionTextToken :: new( "@" , InstructionTextTokenContents :: Text ) ,
676- InstructionTextToken :: new( & r_text, InstructionTextTokenContents :: Register ) ,
693+ InstructionTextToken :: new( "@" , InstructionTextTokenKind :: Text ) ,
694+ InstructionTextToken :: new( & r_text, InstructionTextTokenKind :: Register ) ,
677695 ]
678696 }
679697 Operand :: RegisterIndirectAutoIncrement ( r) => {
@@ -684,41 +702,56 @@ fn generate_operand_tokens(source: &Operand, addr: u64, call: bool) -> Vec<Instr
684702 } ;
685703
686704 vec ! [
687- InstructionTextToken :: new( "@" , InstructionTextTokenContents :: Text ) ,
688- InstructionTextToken :: new( & r_text, InstructionTextTokenContents :: Register ) ,
689- InstructionTextToken :: new( "+" , InstructionTextTokenContents :: Text ) ,
705+ InstructionTextToken :: new( "@" , InstructionTextTokenKind :: Text ) ,
706+ InstructionTextToken :: new( & r_text, InstructionTextTokenKind :: Register ) ,
707+ InstructionTextToken :: new( "+" , InstructionTextTokenKind :: Text ) ,
690708 ]
691709 }
692710 Operand :: Symbolic ( i) => {
693- let val = ( addr as i64 + * i as i64 ) as u64 ;
711+ let value = ( addr as i64 + * i as i64 ) as u64 ;
694712 vec ! [ InstructionTextToken :: new(
695- & format!( "{val:#x}" ) ,
696- InstructionTextTokenContents :: CodeRelativeAddress ( val) ,
713+ & format!( "{value:#x}" ) ,
714+ InstructionTextTokenKind :: CodeRelativeAddress {
715+ value,
716+ size: None ,
717+ } ,
697718 ) ]
698719 }
699720 Operand :: Immediate ( i) => {
700721 if call {
701722 vec ! [ InstructionTextToken :: new(
702723 & format!( "{i:#x}" ) ,
703- InstructionTextTokenContents :: CodeRelativeAddress ( * i as u64 ) ,
724+ InstructionTextTokenKind :: CodeRelativeAddress {
725+ value: * i as u64 ,
726+ size: None ,
727+ } ,
704728 ) ]
705729 } else {
706730 vec ! [ InstructionTextToken :: new(
707731 & format!( "{i:#x}" ) ,
708- InstructionTextTokenContents :: PossibleAddress ( * i as u64 ) ,
732+ InstructionTextTokenKind :: PossibleAddress {
733+ value: * i as u64 ,
734+ size: None ,
735+ } ,
709736 ) ]
710737 }
711738 }
712739 Operand :: Absolute ( a) => {
713740 if call {
714741 vec ! [ InstructionTextToken :: new(
715742 & format!( "{a:#x}" ) ,
716- InstructionTextTokenContents :: CodeRelativeAddress ( * a as u64 ) ,
743+ InstructionTextTokenKind :: CodeRelativeAddress {
744+ value: * a as u64 ,
745+ size: None ,
746+ } ,
717747 ) ]
718748 } else {
719749 vec ! [ InstructionTextToken :: new(
720750 & format!( "{a:#x}" ) ,
721- InstructionTextTokenContents :: PossibleAddress ( * a as u64 ) ,
751+ InstructionTextTokenKind :: PossibleAddress {
752+ value: * a as u64 ,
753+ size: None ,
754+ } ,
722755 ) ]
723756 }
724757 }
@@ -730,10 +763,13 @@ fn generate_operand_tokens(source: &Operand, addr: u64, call: bool) -> Vec<Instr
730763 } ;
731764
732765 vec ! [
733- InstructionTextToken :: new( "#" , InstructionTextTokenContents :: Text ) ,
766+ InstructionTextToken :: new( "#" , InstructionTextTokenKind :: Text ) ,
734767 InstructionTextToken :: new(
735768 & num_text,
736- InstructionTextTokenContents :: Integer ( * i as u64 ) ,
769+ InstructionTextTokenKind :: Integer {
770+ value: * i as u64 ,
771+ size: None ,
772+ } ,
737773 ) ,
738774 ]
739775 }
0 commit comments