Clippy fix
This commit is contained in:
parent
3effc52981
commit
5152a5c47d
8 changed files with 49 additions and 49 deletions
|
@ -18,7 +18,7 @@ pub trait Device: std::fmt::Debug {
|
|||
fn dei1(&mut self, vm: &mut Uxn, port: u8) -> Result<u8, DeviceError>;
|
||||
|
||||
fn dei2(&mut self, vm: &mut Uxn, port: u8) -> Result<u16, DeviceError> {
|
||||
return Ok(((self.dei1(vm, port)? as u16) << 8) + self.dei1(vm, port + 1)? as u16);
|
||||
Ok(((self.dei1(vm, port)? as u16) << 8) + self.dei1(vm, port + 1)? as u16)
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -30,7 +30,7 @@ impl Device for BuffDevice {
|
|||
"Got write to device {:02X} slot {:02X} val {:02X}",
|
||||
port, slot, val
|
||||
);
|
||||
self.buffer[slot as usize] = val;
|
||||
self.buffer[slot] = val;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
68
src/isa.rs
68
src/isa.rs
|
@ -63,41 +63,41 @@ impl Icode {
|
|||
pub const fn nameof(opcode: u8) -> &'static str {
|
||||
match opcode {
|
||||
// Nonstandard icodes + extensions
|
||||
Icode::LIT | Icode::LIT2 => &"LIT", // AKA keep Yes really. Per spec,
|
||||
Icode::NOP => &"NOP",
|
||||
Icode::LIT | Icode::LIT2 => "LIT", // AKA keep Yes really. Per spec,
|
||||
Icode::NOP => "NOP",
|
||||
// Standard icodes
|
||||
Icode::BRK => &"BRK",
|
||||
Icode::INC => &"INC",
|
||||
Icode::POP => &"POP",
|
||||
Icode::NIP => &"NIP",
|
||||
Icode::SWP => &"SWP",
|
||||
Icode::ROT => &"ROT",
|
||||
Icode::DUP => &"DUP",
|
||||
Icode::OVR => &"OVR",
|
||||
Icode::EQL => &"EQL",
|
||||
Icode::NEQ => &"NEQ",
|
||||
Icode::GTH => &"GTH",
|
||||
Icode::LTH => &"LTH",
|
||||
Icode::JMP => &"JMP",
|
||||
Icode::JCN => &"JNC",
|
||||
Icode::JSR => &"JSR",
|
||||
Icode::STH => &"STH",
|
||||
Icode::LDZ => &"LDZ",
|
||||
Icode::STZ => &"STZ",
|
||||
Icode::LDR => &"LDR",
|
||||
Icode::STR => &"STR",
|
||||
Icode::LDA => &"LDA",
|
||||
Icode::STA => &"STA",
|
||||
Icode::DEI => &"DEI",
|
||||
Icode::DEO => &"DEO",
|
||||
Icode::ADD => &"ADD",
|
||||
Icode::SUB => &"SUB",
|
||||
Icode::MUL => &"MUL",
|
||||
Icode::DIV => &"DIV",
|
||||
Icode::AND => &"AND",
|
||||
Icode::ORA => &"ORA",
|
||||
Icode::EOR => &"EOR",
|
||||
Icode::SFT => &"SFT",
|
||||
Icode::BRK => "BRK",
|
||||
Icode::INC => "INC",
|
||||
Icode::POP => "POP",
|
||||
Icode::NIP => "NIP",
|
||||
Icode::SWP => "SWP",
|
||||
Icode::ROT => "ROT",
|
||||
Icode::DUP => "DUP",
|
||||
Icode::OVR => "OVR",
|
||||
Icode::EQL => "EQL",
|
||||
Icode::NEQ => "NEQ",
|
||||
Icode::GTH => "GTH",
|
||||
Icode::LTH => "LTH",
|
||||
Icode::JMP => "JMP",
|
||||
Icode::JCN => "JNC",
|
||||
Icode::JSR => "JSR",
|
||||
Icode::STH => "STH",
|
||||
Icode::LDZ => "LDZ",
|
||||
Icode::STZ => "STZ",
|
||||
Icode::LDR => "LDR",
|
||||
Icode::STR => "STR",
|
||||
Icode::LDA => "LDA",
|
||||
Icode::STA => "STA",
|
||||
Icode::DEI => "DEI",
|
||||
Icode::DEO => "DEO",
|
||||
Icode::ADD => "ADD",
|
||||
Icode::SUB => "SUB",
|
||||
Icode::MUL => "MUL",
|
||||
Icode::DIV => "DIV",
|
||||
Icode::AND => "AND",
|
||||
Icode::ORA => "ORA",
|
||||
Icode::EOR => "EOR",
|
||||
Icode::SFT => "SFT",
|
||||
_ => Icode::nameof(opcode & 0x1F),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,15 +34,15 @@ impl TrivialMemory {
|
|||
|
||||
impl Memory for TrivialMemory {
|
||||
fn get1(&self, address: u16) -> Result<u8, MemoryError> {
|
||||
return Ok(self.buffer[address as usize]);
|
||||
Ok(self.buffer[address as usize])
|
||||
}
|
||||
|
||||
fn get2(&self, address: u16) -> Result<u16, MemoryError> {
|
||||
if address == 0xFFFFu16 {
|
||||
Err(MemoryError::AddressOverflow)
|
||||
} else {
|
||||
return Ok(((self.buffer[address as usize] as u16) << 8)
|
||||
+ self.buffer[address as usize + 1] as u16);
|
||||
Ok(((self.buffer[address as usize] as u16) << 8)
|
||||
+ self.buffer[address as usize + 1] as u16)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ impl ArrayStack {
|
|||
|
||||
impl Stack for ArrayStack {
|
||||
fn idx(&self) -> u8 {
|
||||
return self._idx;
|
||||
self._idx
|
||||
}
|
||||
fn push1(&mut self, val: u8) -> Result<(), StackError> {
|
||||
if self._idx == 255 {
|
||||
|
@ -182,7 +182,7 @@ mod arrs_test {
|
|||
for i in val.clone().into_iter() {
|
||||
s.push1(i).unwrap();
|
||||
};
|
||||
for i in val.clone().into_iter().rev() {
|
||||
for i in val.into_iter().rev() {
|
||||
match s.pop1() {
|
||||
Ok(j) => if i != j { return false }
|
||||
Err(e) => panic!("{:?}", e)
|
||||
|
@ -214,7 +214,7 @@ mod arrs_test {
|
|||
for i in val.clone().into_iter() {
|
||||
s.push2(i).unwrap();
|
||||
};
|
||||
for i in val.clone().into_iter().rev() {
|
||||
for i in val.into_iter().rev() {
|
||||
match s.pop2() {
|
||||
Ok(j) => if i != j { return false }
|
||||
Err(e) => panic!("{:?}", e)
|
||||
|
|
|
@ -28,7 +28,7 @@ impl PopStack {
|
|||
|
||||
impl Stack for PopStack {
|
||||
fn idx(&self) -> u8 {
|
||||
return self._idx;
|
||||
self._idx
|
||||
}
|
||||
fn push1(&mut self, val: u8) -> Result<(), StackError> {
|
||||
self.wrapped.borrow_mut().push1(val)
|
||||
|
|
|
@ -174,11 +174,11 @@ impl Uxn {
|
|||
} else {
|
||||
print!(" empty")
|
||||
}
|
||||
print!("\n");
|
||||
println!();
|
||||
}
|
||||
|
||||
pub fn debug_symbols(&self) {
|
||||
for (k, v) in self.symbols.borrow().into_iter() {
|
||||
for (k, v) in self.symbols.borrow().iter() {
|
||||
println!(" #{:02X} {}", k, v);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -727,7 +727,7 @@ fn test_dei() {
|
|||
Icode::BRK,
|
||||
]);
|
||||
let dev = Rc::new(RefCell::new(BuffDevice::new()));
|
||||
vm.devices[3] = dev.clone();
|
||||
vm.devices[3] = dev;
|
||||
vm.deo1(0x30, 0xFF).unwrap();
|
||||
}
|
||||
assert_eq!(vm.run(64), Err(UxnError::Break));
|
||||
|
@ -744,7 +744,7 @@ fn test_dei2() {
|
|||
Icode::BRK,
|
||||
]);
|
||||
let dev = Rc::new(RefCell::new(BuffDevice::new()));
|
||||
vm.devices[3] = dev.clone();
|
||||
vm.devices[3] = dev;
|
||||
vm.deo2(0x30, 0xFFEE).unwrap();
|
||||
}
|
||||
assert_eq!(vm.run(64), Err(UxnError::Break));
|
||||
|
@ -759,7 +759,7 @@ fn test_deo() {
|
|||
Icode::LIT | Icode::SHORT, 0xFF, 0x30, Icode::DEO, Icode::BRK,
|
||||
]);
|
||||
let dev = Rc::new(RefCell::new(BuffDevice::new()));
|
||||
vm.devices[3] = dev.clone();
|
||||
vm.devices[3] = dev;
|
||||
}
|
||||
assert_eq!(vm.run(64), Err(UxnError::Break));
|
||||
assert_eq!(vm.wst.borrow().idx(), 0);
|
||||
|
@ -776,7 +776,7 @@ fn test_deo2() {
|
|||
Icode::BRK,
|
||||
]);
|
||||
let dev = Rc::new(RefCell::new(BuffDevice::new()));
|
||||
vm.devices[3] = dev.clone();
|
||||
vm.devices[3] = dev;
|
||||
}
|
||||
assert_eq!(vm.run(64), Err(UxnError::Break));
|
||||
assert_eq!(vm.wst.borrow().idx(), 0);
|
||||
|
|
Loading…
Reference in a new issue