| 128 | } |
| 129 | |
| 130 | std::vector<N64Recomp::FunctionSize> get_func_sizes(const toml::array* func_sizes_array) { |
| 131 | std::vector<N64Recomp::FunctionSize> func_sizes{}; |
| 132 | |
| 133 | // Reserve room for all the funcs in the map. |
| 134 | func_sizes.reserve(func_sizes_array->size()); |
| 135 | func_sizes_array->for_each([&func_sizes](auto&& el) { |
| 136 | if constexpr (toml::is_table<decltype(el)>) { |
| 137 | std::optional<std::string> func_name = el["name"].template value<std::string>(); |
| 138 | std::optional<uint32_t> func_size = el["size"].template value<uint32_t>(); |
| 139 | |
| 140 | if (func_name.has_value() && func_size.has_value()) { |
| 141 | // Make sure the size is divisible by 4 |
| 142 | if (func_size.value() & (4 - 1)) { |
| 143 | // It's not, so throw an error (and make it look like a normal toml one). |
| 144 | throw toml::parse_error("Function size is not divisible by 4", el.source()); |
| 145 | } |
| 146 | func_sizes.emplace_back(func_name.value(), func_size.value()); |
| 147 | } |
| 148 | else { |
| 149 | throw toml::parse_error("Manually sized function is missing required value(s)", el.source()); |
| 150 | } |
| 151 | } |
| 152 | else { |
| 153 | throw toml::parse_error("Missing required value in function_sizes array", el.source()); |
| 154 | } |
| 155 | }); |
| 156 | |
| 157 | return func_sizes; |
| 158 | } |
| 159 | |
| 160 | std::vector<N64Recomp::InstructionPatch> get_instruction_patches(const toml::table* patches_data) { |
| 161 | std::vector<N64Recomp::InstructionPatch> ret; |