From b7de8016c51f8d48bb3f91eb6d7be191d6b46d55 Mon Sep 17 00:00:00 2001 From: iximeow Date: Sat, 14 Feb 2026 18:33:39 +0000 Subject: type aliases make some of these signatures less egregious.. --- src/long_mode/mod.rs | 47 ++++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 23 deletions(-) (limited to 'src/long_mode') diff --git a/src/long_mode/mod.rs b/src/long_mode/mod.rs index 823221e..5163ba6 100644 --- a/src/long_mode/mod.rs +++ b/src/long_mode/mod.rs @@ -5,6 +5,7 @@ mod display; pub mod uarch; pub use crate::MemoryAccessSize; +use crate::{Address, Word}; #[cfg(feature = "fmt")] pub use self::display::{DisplayStyle, InstructionDisplayer}; @@ -2842,14 +2843,14 @@ impl Default for InstDecoder { } impl Decoder for InstDecoder { - fn decode::Address, ::Word>>(&self, words: &mut T) -> Result::DecodeError> { + fn decode, Word>>(&self, words: &mut T) -> Result::DecodeError> { let mut instr = Instruction::invalid(); self.decode_into(&mut instr, words)?; Ok(instr) } #[inline(always)] - fn decode_into::Address, ::Word>>(&self, instr: &mut Instruction, words: &mut T) -> Result<(), ::DecodeError> { + fn decode_into, Word>>(&self, instr: &mut Instruction, words: &mut T) -> Result<(), ::DecodeError> { self.decode_with_annotation(instr, words, &mut NullSink) } } @@ -2859,7 +2860,7 @@ impl AnnotatingDecoder for InstDecoder { #[inline(always)] fn decode_with_annotation< - T: Reader<::Address, ::Word>, + T: Reader, Word>, S: DescriptionSink >(&self, instr: &mut Instruction, words: &mut T, sink: &mut S) -> Result<(), ::DecodeError> { decode_with_annotation(self, instr, words, sink) @@ -2868,7 +2869,7 @@ impl AnnotatingDecoder for InstDecoder { #[inline(always)] fn decode_with_annotation< - T: Reader<::Address, ::Word>, + T: Reader, Word>, S: DescriptionSink >(decoder: &InstDecoder, instr: &mut Instruction, words: &mut T, sink: &mut S) -> Result<(), ::DecodeError> { DecodeCtx::new().read_with_annotations(decoder, words, instr, sink)?; @@ -4677,7 +4678,7 @@ const OPCODES: [OpcodeRecord; 256] = [ #[cfg_attr(feature="profiling", inline(never))] #[cfg_attr(not(feature="profiling"), inline(always))] pub(self) fn read_E< - T: Reader<::Address, ::Word>, + T: Reader, Word>, S: DescriptionSink, >(words: &mut T, instr: &mut Instruction, modrm: u8, bank: RegisterBank, sink: &mut S) -> Result { if modrm >= 0b11000000 { @@ -4688,7 +4689,7 @@ pub(self) fn read_E< } #[allow(non_snake_case)] pub(self) fn read_E_st< - T: Reader<::Address, ::Word>, + T: Reader, Word>, S: DescriptionSink, >(words: &mut T, instr: &mut Instruction, modrm: u8, sink: &mut S) -> Result { if modrm >= 0b11000000 { @@ -4700,7 +4701,7 @@ pub(self) fn read_E_st< } #[allow(non_snake_case)] pub(self) fn read_E_xmm< - T: Reader<::Address, ::Word>, + T: Reader, Word>, S: DescriptionSink, >(words: &mut T, instr: &mut Instruction, modrm: u8, sink: &mut S) -> Result { if modrm >= 0b11000000 { @@ -4711,7 +4712,7 @@ pub(self) fn read_E_xmm< } #[allow(non_snake_case)] pub(self) fn read_E_ymm< - T: Reader<::Address, ::Word>, + T: Reader, Word>, S: DescriptionSink, >(words: &mut T, instr: &mut Instruction, modrm: u8, sink: &mut S) -> Result { if modrm >= 0b11000000 { @@ -4722,7 +4723,7 @@ pub(self) fn read_E_ymm< } #[allow(non_snake_case)] pub(self) fn read_E_vex< - T: Reader<::Address, ::Word>, + T: Reader, Word>, S: DescriptionSink, >(words: &mut T, instr: &mut Instruction, modrm: u8, bank: RegisterBank, sink: &mut S) -> Result { if modrm >= 0b11000000 { @@ -4739,7 +4740,7 @@ pub(self) fn read_E_vex< #[allow(non_snake_case)] #[inline(always)] fn read_modrm_reg< - T: Reader<::Address, ::Word>, + T: Reader, Word>, S: DescriptionSink, >(instr: &mut Instruction, words: &mut T, modrm: u8, reg_bank: RegisterBank, sink: &mut S) -> Result { instr.regs[1] = RegSpec::from_parts(modrm & 7, instr.prefixes.rex_unchecked().b(), reg_bank); @@ -4754,7 +4755,7 @@ fn read_modrm_reg< #[inline(always)] fn read_sib_disp< - T: Reader<::Address, ::Word>, + T: Reader, Word>, S: DescriptionSink, >(instr: &Instruction, words: &mut T, modrm: u8, sibbyte: u8, sink: &mut S) -> Result { let sib_start = words.offset() as u32 * 8 - 8; @@ -4801,7 +4802,7 @@ fn read_sib_disp< #[allow(non_snake_case)] #[inline(always)] fn read_sib< - T: Reader<::Address, ::Word>, + T: Reader, Word>, S: DescriptionSink, >(words: &mut T, instr: &mut Instruction, modrm: u8, sink: &mut S) -> Result { let modrm_start = words.offset() as u32 * 8 - 8; @@ -4997,7 +4998,7 @@ fn read_sib< #[allow(non_snake_case)] #[inline(always)] fn read_M< - T: Reader<::Address, ::Word>, + T: Reader, Word>, S: DescriptionSink >(words: &mut T, instr: &mut Instruction, modrm: u8, sink: &mut S) -> Result { let modrm_start = words.offset() as u32 * 8 - 8; @@ -5250,7 +5251,7 @@ impl fmt::Display for FieldDescription { #[inline(always)] fn record_opcode_record_found< - T: Reader<::Address, ::Word>, + T: Reader, Word>, S: DescriptionSink, >(words: &mut T, sink: &mut S, opc: Opcode, code: OperandCode, opc_length: u32) { let offset = words.offset() as u32; @@ -5306,7 +5307,7 @@ impl DecodeCtx { #[cfg_attr(feature="profiling", inline(never))] fn read_opc_hotpath< - T: Reader<::Address, ::Word>, + T: Reader, Word>, S: DescriptionSink, >(&mut self, mut b: u8, nextb: &mut u8, record: &mut OpcodeRecord, words: &mut T, instruction: &mut Instruction, sink: &mut S) -> Result { if b >= 0x40 && b < 0x50 { @@ -5364,7 +5365,7 @@ fn read_opc_hotpath< #[cfg_attr(feature="profiling", inline(never))] #[cfg_attr(not(feature="profiling"), inline(always))] fn read_with_annotations< - T: Reader<::Address, ::Word>, + T: Reader, Word>, S: DescriptionSink, >(mut self, decoder: &InstDecoder, words: &mut T, instruction: &mut Instruction, sink: &mut S) -> Result<(), DecodeError> { words.mark(); @@ -5527,7 +5528,7 @@ fn read_with_annotations< #[inline(never)] fn read_avx_prefixed< - T: Reader<::Address, ::Word>, + T: Reader, Word>, S: DescriptionSink, >(self, b: u8, words: &mut T, instruction: &mut Instruction, sink: &mut S) -> Result<(), DecodeError> { if instruction.prefixes.vex_invalid() { @@ -5583,7 +5584,7 @@ fn read_avx_prefixed< #[cfg_attr(feature="profiling", inline(never))] #[cfg_attr(not(feature="profiling"), inline(always))] fn read_operands< - T: Reader<::Address, ::Word>, + T: Reader, Word>, S: DescriptionSink >(&mut self, decoder: &InstDecoder, words: &mut T, instruction: &mut Instruction, operand_code: OperandCode, sink: &mut S) -> Result<(), DecodeError> { sink.record( @@ -9196,7 +9197,7 @@ fn read_0f3a_opcode(&mut self, opcode: u8, prefixes: &mut Prefixes) -> Result::Address, ::Word>, + T: Reader, Word>, S: DescriptionSink, >(words: &mut T, instruction: &mut Instruction, operand_code: OperandCase, sink: &mut S) -> Result<(), DecodeError> { sink.record( @@ -9725,7 +9726,7 @@ fn decode_x87< } #[inline(always)] -fn read_num::Address, ::Word>>(bytes: &mut T, width: u8) -> Result { +fn read_num, Word>>(bytes: &mut T, width: u8) -> Result { match width { 1 => { bytes.next().ok().ok_or(DecodeError::ExhaustedInput).map(|x| x as u64) } 2 => { @@ -9750,7 +9751,7 @@ fn read_num::Address, ::Address, ::Word>>(bytes: &mut T, num_width: u8) -> Result { +fn read_imm_signed, Word>>(bytes: &mut T, num_width: u8) -> Result { if num_width == 1 { Ok(read_num(bytes, 1)? as i8 as i64) } else if num_width == 2 { @@ -9762,7 +9763,7 @@ fn read_imm_signed::Address, ::Address, ::Word>>(bytes: &mut T, width: u8) -> Result { +fn read_imm_unsigned, Word>>(bytes: &mut T, width: u8) -> Result { read_num(bytes, width) } @@ -9793,7 +9794,7 @@ fn bank_from_prefixes_64(interpretation: SizeCode, prefixes: Prefixes) -> Regist } #[inline] -fn read_modrm::Address, ::Word>>(words: &mut T) -> Result { +fn read_modrm, Word>>(words: &mut T) -> Result { words.next().ok().ok_or(DecodeError::ExhaustedInput) } -- cgit v1.1