From da30122c87126f0068fa4702d5b7577418998119 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Rativel?= Date: Wed, 8 Mar 2023 11:15:13 +0100 Subject: [PATCH] Added documentation for from function --- src/simulator/mem_cmp.rs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/simulator/mem_cmp.rs b/src/simulator/mem_cmp.rs index e1cb7e4..febe371 100644 --- a/src/simulator/mem_cmp.rs +++ b/src/simulator/mem_cmp.rs @@ -93,6 +93,15 @@ pub struct Mem_Checker{ impl Mem_Checker{ + ///Translate lines of a file in e Vector of String + ///We need this method to parse the memory we received + /// + /// ### Parameters + /// + /// - **Lines** The file to parse + /// + /// ### Return + /// - A vector of String where each line of the file os an element of the vector fn vect_from_lines(lines: &mut Lines>, pc: &mut usize, sp: &mut usize) -> Vec{ let mut vector = Vec::new(); for (i,line) in lines.enumerate() { @@ -104,6 +113,14 @@ impl Mem_Checker{ vector } + /// Fill a mem checker from a file (here the mock memory) + /// Extract the values of pc, sp and sections + /// + /// ### Parameter + /// -**path** addr to the file + /// + /// ### Return + /// Mem-checker filled pub fn from(path: &String) -> Mem_Checker { let file = fs::File::open(path).expect("Wrong filename"); @@ -146,6 +163,11 @@ impl Mem_Checker{ } + /// Print the content of a Mem_Checker + /// + /// ### Parameter + /// + /// - **m_c** Contains the data we want to print pub fn print_Mem_Checker(m_c: &Mem_Checker){ println!("PC :: {:x}", m_c.pc); println!("SP :: {:x}", m_c.sp); @@ -157,6 +179,12 @@ impl Mem_Checker{ } + /// Fill a machine's memory from a Mem Chacker + /// + /// ### Parameters + /// + /// - **m_c** contains the data + /// - **machine** contains the memry to fill pub fn fill_memory_from_Mem_Checker(m_c: &Mem_Checker, machine: &mut Machine){ machine.sp = m_c.sp;