summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoriximeow <me@iximeow.net>2020-01-18 14:37:30 -0800
committeriximeow <me@iximeow.net>2020-01-18 14:37:30 -0800
commitf2f4dcd0f1494f21537b84370c7f630720e4494a (patch)
tree631e16ade4aaca3b82c9bc7822acd1e498d8f52a
parent839479895dd9d14de4818270c04df4398c353484 (diff)
use yaxpeax-arch
-rw-r--r--src/lib.rs12
1 files changed, 4 insertions, 8 deletions
diff --git a/src/lib.rs b/src/lib.rs
index fa12750..e83a8b0 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -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();