| 246 | } |
| 247 | |
| 248 | void get_mdebug_mappings(const toml::array* mdebug_mappings_array, |
| 249 | std::unordered_map<std::string, std::string>& mdebug_text_map, |
| 250 | std::unordered_map<std::string, std::string>& mdebug_data_map, |
| 251 | std::unordered_map<std::string, std::string>& mdebug_rodata_map, |
| 252 | std::unordered_map<std::string, std::string>& mdebug_bss_map |
| 253 | ) { |
| 254 | mdebug_mappings_array->for_each([&mdebug_text_map, &mdebug_data_map, &mdebug_rodata_map, &mdebug_bss_map](auto&& el) { |
| 255 | if constexpr (toml::is_table<decltype(el)>) { |
| 256 | std::optional<std::string> filename = el["filename"].template value<std::string>(); |
| 257 | std::optional<std::string> input_section = el["input_section"].template value<std::string>(); |
| 258 | std::optional<std::string> output_section = el["output_section"].template value<std::string>(); |
| 259 | |
| 260 | if (filename.has_value() && input_section.has_value() && output_section.has_value()) { |
| 261 | const std::string& input_section_val = input_section.value(); |
| 262 | if (input_section_val == ".text") { |
| 263 | mdebug_text_map.emplace(filename.value(), output_section.value()); |
| 264 | } |
| 265 | else if (input_section_val == ".data") { |
| 266 | mdebug_data_map.emplace(filename.value(), output_section.value()); |
| 267 | } |
| 268 | else if (input_section_val == ".rodata") { |
| 269 | mdebug_rodata_map.emplace(filename.value(), output_section.value()); |
| 270 | } |
| 271 | else if (input_section_val == ".bss") { |
| 272 | mdebug_bss_map.emplace(filename.value(), output_section.value()); |
| 273 | } |
| 274 | else { |
| 275 | throw toml::parse_error("Invalid input section in mdebug file mapping entry", el.source()); |
| 276 | } |
| 277 | } |
| 278 | else { |
| 279 | throw toml::parse_error("Mdebug file mappings entry is missing required value(s)", el.source()); |
| 280 | } |
| 281 | } |
| 282 | else { |
| 283 | throw toml::parse_error("Invalid mdebug file mappings entry", el.source()); |
| 284 | } |
| 285 | }); |
| 286 | } |
| 287 | |
| 288 | N64Recomp::Config::Config(const char* path) { |
| 289 | // Start this config out as bad so that it has to finish parsing without errors to be good. |