diff options
author | iximeow <me@iximeow.net> | 2020-01-18 14:37:30 -0800 |
---|---|---|
committer | iximeow <me@iximeow.net> | 2020-01-18 14:37:30 -0800 |
commit | f2f4dcd0f1494f21537b84370c7f630720e4494a (patch) | |
tree | 631e16ade4aaca3b82c9bc7822acd1e498d8f52a /src/lib.rs | |
parent | 839479895dd9d14de4818270c04df4398c353484 (diff) |
use yaxpeax-arch
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 12 |
1 files changed, 4 insertions, 8 deletions
@@ -42,15 +42,17 @@ pub struct Instruction { opcode: Opcode, } -impl Instruction { - fn blank() -> Self { +impl Default for Instruction { + fn default() -> Self { Instruction { word: 0, operands: [OperandSpec::Nothing, OperandSpec::Nothing, OperandSpec::Nothing], opcode: Opcode::J, } } +} +impl Instruction { fn operand(&self, op: &OperandSpec) -> Option<Operand> { match op { OperandSpec::Nothing => None, @@ -274,12 +276,6 @@ pub struct MipsDecoder {} impl Decoder<Instruction> for MipsDecoder { type Error = DecodeError; - fn decode<T: IntoIterator<Item=u8>>(&self, bytes: T) -> Result<Instruction, Self::Error> { - let mut blank = Instruction::blank(); - self.decode_into(&mut blank, bytes) - .map(|_: ()| blank) - } - fn decode_into<T: IntoIterator<Item=u8>>(&self, instruction: &mut Instruction, bytes: T) -> Result<(), Self::Error> { let mut bytes_iter = bytes.into_iter(); let word: Vec<u8> = bytes_iter.by_ref().take(4).collect(); |