@@ -421,6 +421,14 @@ pub enum InstructionTextTokenKind {
421421 } ,
422422 Opcode ,
423423 String {
424+ // TODO: What is this?
425+ // TODO: It seems like people just throw things in here...
426+ value : u64 ,
427+ } ,
428+ /// String content is only present for:
429+ /// - [`InstructionTextTokenContext::StringReference`]
430+ /// - [`InstructionTextTokenContext::StringDisplay`]
431+ StringContent {
424432 ty : StringType ,
425433 } ,
426434 CharacterConstant ,
@@ -588,14 +596,29 @@ impl InstructionTextTokenKind {
588596 Self :: HexDumpText { width : value. value }
589597 }
590598 BNInstructionTextTokenType :: OpcodeToken => Self :: Opcode ,
591- BNInstructionTextTokenType :: StringToken => Self :: String {
592- ty : match value. value {
593- 0 => StringType :: AsciiString ,
594- 1 => StringType :: Utf8String ,
595- 2 => StringType :: Utf16String ,
596- 3 => StringType :: Utf32String ,
597- _ => unreachable ! ( ) ,
598- } ,
599+ BNInstructionTextTokenType :: StringToken => match value. context {
600+ BNInstructionTextTokenContext :: StringReferenceTokenContext
601+ | BNInstructionTextTokenContext :: StringDisplayTokenContext => {
602+ match value. value {
603+ 0 => Self :: StringContent {
604+ ty : StringType :: AsciiString ,
605+ } ,
606+ 1 => Self :: StringContent {
607+ ty : StringType :: Utf8String ,
608+ } ,
609+ 2 => Self :: StringContent {
610+ ty : StringType :: Utf16String ,
611+ } ,
612+ 3 => Self :: StringContent {
613+ ty : StringType :: Utf32String ,
614+ } ,
615+ // If we reach here all hope is lost.
616+ // Reaching here means someone made a ref or display context token with no
617+ // StringType and instead some other random value...
618+ value => Self :: String { value } ,
619+ }
620+ }
621+ _ => Self :: String { value : value. value } ,
599622 } ,
600623 BNInstructionTextTokenType :: CharacterConstantToken => Self :: CharacterConstant ,
601624 BNInstructionTextTokenType :: KeywordToken => Self :: Keyword ,
@@ -712,7 +735,8 @@ impl InstructionTextTokenKind {
712735 InstructionTextTokenKind :: ArgumentName { value, .. } => Some ( * value) ,
713736 InstructionTextTokenKind :: HexDumpByteValue { value, .. } => Some ( * value as u64 ) ,
714737 InstructionTextTokenKind :: HexDumpText { width, .. } => Some ( * width) ,
715- InstructionTextTokenKind :: String { ty, .. } => Some ( * ty as u64 ) ,
738+ InstructionTextTokenKind :: String { value, .. } => Some ( * value) ,
739+ InstructionTextTokenKind :: StringContent { ty, .. } => Some ( * ty as u64 ) ,
716740 InstructionTextTokenKind :: FieldName { offset, .. } => Some ( * offset) ,
717741 InstructionTextTokenKind :: StructOffset { offset, .. } => Some ( * offset) ,
718742 InstructionTextTokenKind :: StructureHexDumpText { width, .. } => Some ( * width) ,
@@ -815,6 +839,7 @@ impl From<InstructionTextTokenKind> for BNInstructionTextTokenType {
815839 }
816840 InstructionTextTokenKind :: Opcode => BNInstructionTextTokenType :: OpcodeToken ,
817841 InstructionTextTokenKind :: String { .. } => BNInstructionTextTokenType :: StringToken ,
842+ InstructionTextTokenKind :: StringContent { .. } => BNInstructionTextTokenType :: StringToken ,
818843 InstructionTextTokenKind :: CharacterConstant => {
819844 BNInstructionTextTokenType :: CharacterConstantToken
820845 }
0 commit comments