pub fn parse(
        name: &str,
        num_clusters: usize,
        has_num_clusters: bool,
        num_cores: usize,
        has_num_cores: bool,
        base_hartid: usize,
        has_base_hartid: bool,
    ) -> Configuration {
        let config: String = std::fs::read_to_string(name)
            .unwrap_or_else(|_| panic!("Could not open file {}", name))
            .parse()
            .unwrap_or_else(|_| panic!("Could not parse file {}", name));
        // Parse the configuration file based on it's name
        let mut config: Configuration = if name.to_lowercase().contains("json") {
            serde_json::from_str(&config).expect("Error while reading json")
        } else {
            serde_yaml::from_str(&config).expect("Error while reading yaml")
        };
        if has_num_cores {
            config.architecture.num_cores = num_cores;
        }
        if has_base_hartid {
            config.architecture.base_hartid = base_hartid;
        }
        if config.architecture.num_clusters == 0 || has_num_clusters {
            config.memory.resize_with(num_clusters, Default::default);
            config.architecture.num_clusters = num_clusters;
        }
        config
    }
/// Parse a json/yaml file into a `Configuration` struct
Parse a json/yaml file into a `Configuration` struct
Parse a json / yaml file into a ` Configuration ` struct
pub fn parse(
        name: &str,
        num_clusters: usize,
        has_num_clusters: bool,
        num_cores: usize,
        has_num_cores: bool,
        base_hartid: usize,
        has_base_hartid: bool,
    ) -> Configuration {
        let config: String = std::fs::read_to_string(name)
            .unwrap_or_else(|_| panic!("Could not open file {}", name))
            .parse()
            .unwrap_or_else(|_| panic!("Could not parse file {}", name));
        // Parse the configuration file based on it's name
        let mut config: Configuration = if name.to_lowercase().contains("json") {
            serde_json::from_str(&config).expect("Error while reading json")
        } else {
            serde_yaml::from_str(&config).expect("Error while reading yaml")
        };
        if has_num_cores {
            config.architecture.num_cores = num_cores;
        }
        if has_base_hartid {
            config.architecture.base_hartid = base_hartid;
        }
        if config.architecture.num_clusters == 0 || has_num_clusters {
            config.memory.resize_with(num_clusters, Default::default);
            config.architecture.num_clusters = num_clusters;
        }
        config
    }
pub fn parse ( name : & str , num_clusters : usize , has_num_clusters : bool , num_cores : usize , has_num_cores : bool , base_hartid : usize , has_base_hartid : bool , ) -> Configuration { let config : String = std :: fs :: read_to_string ( name ) . unwrap_or_else ( | _ | panic ! ( " " name ) ) . parse ( ) . unwrap_or_else ( | _ | panic ! ( " " name ) ) ; // Parse the configuration file based on it's name let mut config : Configuration = if name . to_lowercase ( ) . contains ( " " ) { serde_json :: from_str ( & config ) . expect ( " " ) } else { serde_yaml :: from_str ( & config ) . expect ( " " ) } ; if has_num_cores { config . architecture . num_cores = num_cores ; } if has_base_hartid { config . architecture . base_hartid = base_hartid ; } if config . architecture . num_clusters == 0 || has_num_clusters { config . memory . resize_with ( num_clusters , Default :: default ) ; config . architecture . num_clusters = num_clusters ; } config }
Parse a json/yaml file into a `Configuration` struct
Parse a json / yaml file into a ` Configuration ` struct
name
&str
num_clusters
usize
has_num_clusters
bool
num_cores
usize
has_num_cores
bool
base_hartid
usize
has_base_hartid
bool