mirror of
https://github.com/open-goal/jak-project
synced 2026-05-26 15:46:14 -04:00
jak3: fix all-types file order (#3316)
In #3300, `per_object` in `ObjectFileDB::ir2_analyze_all_types()` was changed to an `unordered_map`, which messed with the object file order in `all-types`. This fixes the issue by going through each object file in order and then looking up the type info from the map instead of iterating through the map. This also removes the method IDs from the old method comments and adds a stub for the `new` method if there is an old method comment for it, in order to stay consistent with the rest of the method list.
This commit is contained in:
@@ -320,6 +320,10 @@ void ObjectFileDB::ir2_top_level_pass(const Config& config) {
|
||||
void ObjectFileDB::ir2_analyze_all_types(const fs::path& output_file,
|
||||
const std::optional<std::string>& previous_game_types,
|
||||
const std::unordered_set<std::string>& bad_types) {
|
||||
auto is_code_file = [](ObjectFileData& data) {
|
||||
return (data.obj_version == 3 ||
|
||||
(data.obj_version == 5 && data.linked_data.has_any_functions()));
|
||||
};
|
||||
std::unordered_map<std::string, PerObjectAllTypeInfo> per_object;
|
||||
|
||||
DecompilerTypeSystem previous_game_ts(GameVersion::Jak2); // version here doesn't matter.
|
||||
@@ -331,7 +335,7 @@ void ObjectFileDB::ir2_analyze_all_types(const fs::path& output_file,
|
||||
|
||||
// Do a first pass to initialize all types and symbols
|
||||
for_each_obj([&](ObjectFileData& data) {
|
||||
if (data.obj_version == 3 || (data.obj_version == 5 && data.linked_data.has_any_functions())) {
|
||||
if (is_code_file(data)) {
|
||||
per_object[data.to_unique_name()] = PerObjectAllTypeInfo();
|
||||
// Go through the top-level segment first to identify the type names associated with each
|
||||
// symbol def
|
||||
@@ -387,7 +391,7 @@ void ObjectFileDB::ir2_analyze_all_types(const fs::path& output_file,
|
||||
|
||||
// Then another to actually setup the definitions
|
||||
for_each_obj([&](ObjectFileData& data) {
|
||||
if (data.obj_version == 3 || (data.obj_version == 5 && data.linked_data.has_any_functions())) {
|
||||
if (is_code_file(data)) {
|
||||
auto& object_result = per_object.at(data.to_unique_name());
|
||||
|
||||
// Handle the top level last, which is fine as all symbol_defs are always written after
|
||||
@@ -424,18 +428,22 @@ void ObjectFileDB::ir2_analyze_all_types(const fs::path& output_file,
|
||||
std::string result;
|
||||
result += ";; All Types\n\n";
|
||||
|
||||
for (auto& [obj_name, obj] : per_object) {
|
||||
result += fmt::format(";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n");
|
||||
result += fmt::format(";; {:30s} ;;\n", obj_name);
|
||||
result += fmt::format(";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n");
|
||||
for (const auto& type_name : obj.type_names_in_order) {
|
||||
auto& info = obj.type_info.at(type_name);
|
||||
result += info.type_definition;
|
||||
for_each_obj([&](ObjectFileData& data) {
|
||||
if (is_code_file(data)) {
|
||||
auto& obj = per_object.at(data.to_unique_name());
|
||||
|
||||
result += fmt::format(";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n");
|
||||
result += fmt::format(";; {:30s} ;;\n", data.name_in_dgo);
|
||||
result += fmt::format(";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\n");
|
||||
for (const auto& type_name : obj.type_names_in_order) {
|
||||
auto& info = obj.type_info.at(type_name);
|
||||
result += info.type_definition;
|
||||
result += "\n";
|
||||
}
|
||||
result += obj.symbol_defs;
|
||||
result += "\n";
|
||||
}
|
||||
result += obj.symbol_defs;
|
||||
result += "\n";
|
||||
}
|
||||
});
|
||||
|
||||
file_util::write_text_file(output_file, result);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user