:rotating_lights: Small lint fixes

This commit is contained in:
François Autin 2023-03-27 11:35:04 +02:00
parent 939e23883e
commit ba8e36ea90
No known key found for this signature in database
GPG Key ID: 343F5D382E1DD77C
2 changed files with 11 additions and 6 deletions

View File

@ -17,6 +17,7 @@ use kernel::system::System;
use simulator::machine::Machine;
fn main() {
let machine = Machine::init_machine();
let mut machine = Machine::init_machine();
let system = System::default();
machine.run()
}

View File

@ -13,7 +13,7 @@
use std::{
io::Write,
fs::File, ops::Add
fs::File
};
use crate::simulator::{
print,
@ -24,7 +24,10 @@ use crate::simulator::{
register::*
};
/// Exceptions
/// # Exceptions
///
/// Textual names of the exceptions that can be generated by user program
/// execution, for debugging purpose.
/// todo: is this really supposed to stand in machine.rs?
pub enum ExceptionType {
/// Everything ok
@ -46,6 +49,7 @@ pub enum ExceptionType {
NumExceptionTypes
}
/// ID of the stack register
pub const STACK_REG: usize = 2;
/// Number of available Integer registers
pub const NUM_INT_REGS: usize = 32;
@ -154,7 +158,7 @@ impl Machine {
/// ### Parameters
///
/// - **machine** contains the memory
pub fn extract_memory(&self){
pub fn _extract_memory(&self){
let file_path = "burritos_memory.txt";
let write_to_file = |path| -> std::io::Result<File> {
let mut file = File::create(path)?;
@ -228,8 +232,8 @@ impl Machine {
panic!("ERROR : number max of instructions rushed");
}
let mut val: [u8; 4] = [0; 4];
for i in 0..4 {
val[i] = self.main_memory[self.pc as usize + i];
for (i, elem) in val.iter_mut().enumerate() {
*elem = self.main_memory[self.pc as usize + i];
}
let val = u32::from_be_bytes(val) as u64;