From 2ac46a98585b93f62961fdd82a1f2d1266761305 Mon Sep 17 00:00:00 2001 From: iximeow Date: Sun, 23 Jun 2024 14:36:05 -0700 Subject: forward long deprecation allowances as appropriate --- src/long_mode/display.rs | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) (limited to 'src/long_mode') diff --git a/src/long_mode/display.rs b/src/long_mode/display.rs index 4ffc431..f765fb7 100644 --- a/src/long_mode/display.rs +++ b/src/long_mode/display.rs @@ -1,5 +1,7 @@ use core::fmt; +// allowing these deprecated items for the time being, not yet breaking yaxpeax-x86 apis +#[allow(deprecated)] use yaxpeax_arch::{Colorize, ShowContextual, NoColors, YaxColors}; use crate::MEM_SIZE_STRINGS; @@ -254,10 +256,14 @@ impl fmt::Display for RegSpec { impl fmt::Display for Operand { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + // to reuse one implementation, call the deprecated function for now. + #[allow(deprecated)] self.colorize(&NoColors, fmt) } } +// allowing these deprecated items for the time being, not yet breaking yaxpeax-x86 apis +#[allow(deprecated)] impl Colorize for Operand { fn colorize(&self, _colors: &Y, f: &mut T) -> fmt::Result { let mut f = yaxpeax_arch::display::FmtSink::new(f); @@ -2134,8 +2140,18 @@ impl Opcode { } } +// allowing these deprecated items for the time being, not yet breaking yaxpeax-x86 apis +#[allow(deprecated)] impl Colorize for Opcode { - fn colorize(&self, colors: &Y, out: &mut T) -> fmt::Result { + fn colorize(&self, _colors: &Y, out: &mut T) -> fmt::Result { + out.write_str(self.name()) + // a way to preserve opcode colorization might be to see entering an opcode span, + // collecting text into a buffer, waiting for the span to exit, looking that up in a map + // for opcode types, and then picking a color. this really should be something like "opcode + // information" that can be looked up (including things like operand read/write behavior).. + // + // leaving this commented out as a reminder of what opcode to behavior mapping was like + /* match self { Opcode::VGF2P8AFFINEQB | Opcode::VGF2P8AFFINEINVQB | @@ -3561,17 +3577,22 @@ impl Colorize for Opcode { Opcode::UD2 | Opcode::Invalid => { write!(out, "{}", colors.invalid_op(self)) } } + */ } } impl fmt::Display for Instruction { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + // to reuse one implementation, call the deprecated function for now. + #[allow(deprecated)] self.display_with(DisplayStyle::Intel).colorize(&NoColors, fmt) } } impl<'instr> fmt::Display for InstructionDisplayer<'instr> { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + // to reuse one implementation, call the deprecated function for now. + #[allow(deprecated)] self.colorize(&NoColors, fmt) } } @@ -3618,6 +3639,8 @@ pub struct InstructionDisplayer<'instr> { * UPDATE: really wish i thought of DisplaySink back then, really wish this was bounded as T: * DisplaySink. */ +// allowing these deprecated items for the time being, not yet breaking yaxpeax-x86 apis +#[allow(deprecated)] impl <'instr, T: fmt::Write, Y: YaxColors> Colorize for InstructionDisplayer<'instr> { fn colorize(&self, colors: &Y, out: &mut T) -> fmt::Result { // TODO: I DONT LIKE THIS, there is no address i can give contextualize here, @@ -4129,6 +4152,8 @@ pub(crate) fn contextualize_c(instr: &Instruction, out: &mut T) Ok(()) } +// allowing these deprecated items for the time being, not yet breaking yaxpeax-x86 apis +#[allow(deprecated)] impl <'instr, T: fmt::Write, Y: YaxColors> ShowContextual for InstructionDisplayer<'instr> { fn contextualize(&self, _colors: &Y, _address: u64, _context: Option<&NoContext>, out: &mut T) -> fmt::Result { let InstructionDisplayer { @@ -4149,6 +4174,8 @@ impl <'instr, T: fmt::Write, Y: YaxColors> ShowContextual } } +// allowing these deprecated items for the time being, not yet breaking yaxpeax-x86 apis +#[allow(deprecated)] #[cfg(feature="std")] impl ShowContextual], T, Y> for Instruction { fn contextualize(&self, colors: &Y, _address: u64, context: Option<&[Option]>, out: &mut T) -> fmt::Result { @@ -4161,7 +4188,7 @@ impl ShowContextual