Added documentation for from function
This commit is contained in:
parent
1e2e537ec9
commit
da30122c87
@ -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<BufReader<fs::File>>, pc: &mut usize, sp: &mut usize) -> Vec<String>{
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user