devalang_core/core/debugger/
store.rs1use crate::core::{
2 debugger::Debugger,
3 store::{function::FunctionTable, variable::VariableTable},
4};
5use std::fs::create_dir_all;
6
7pub fn write_variables_log_file(output_dir: &str, file_name: &str, variables: VariableTable) {
8 let debugger = Debugger::new();
9 let mut content = String::new();
10
11 let log_directory = format!("{}/logs", output_dir);
12 create_dir_all(&log_directory).expect("Failed to create log directory");
13
14 for (var_name, var_data) in variables.variables {
15 content.push_str(&format!("{:?} = {:?}\n", var_name, var_data));
16 }
17
18 content.push_str("\n");
19
20 debugger.write_log_file(&log_directory, file_name, &content);
21}
22
23pub fn write_function_log_file(output_dir: &str, file_name: &str, functions: FunctionTable) {
24 let debugger = Debugger::new();
25 let mut content = String::new();
26
27 let log_directory = format!("{}/logs", output_dir);
28 create_dir_all(&log_directory).expect("Failed to create log directory");
29
30 for (_index, function) in functions.functions {
31 content.push_str(&format!(
32 "'{}' = [{:?}] => {:?}\n",
33 function.name, function.parameters, function.body
34 ));
35 }
36
37 content.push_str("\n");
38
39 debugger.write_log_file(&log_directory, file_name, &content);
40}