mirror of
https://github.com/open-goal/jak-project
synced 2026-06-08 12:27:57 -04:00
Recognize auto-generated inspect methods and create deftypes from them (#95)
- Recognize new type definitions/parents/type flags in the decompiler - Analyze autogenerated inspect methods and dump guesses at fields to a file - Utility functions for accessing static data by label - Better ordering in the decompiler to go through functions in the order they appeared in the source - Added a decent number of types to `all-types.gc` based on the new field analyzer - Correct a few `int`/`integer` mistakes in `gcommon.gc` (this should really be a warning) - Correct a few type issues in `gcommon` and `gkernel-h` - Option in the decompiler to be strict about `define-extern` redefining a type of a symbol - Add a test to check consistency in types between `all-types.gc` (used by decompiler) and `goal_src` (used by the compiler)
This commit is contained in:
@@ -57,6 +57,7 @@ class ObjectFileDB {
|
||||
void analyze_functions();
|
||||
ObjectFileData& lookup_record(const ObjectFileRecord& rec);
|
||||
DecompilerTypeSystem dts;
|
||||
std::string all_type_defs;
|
||||
|
||||
private:
|
||||
void load_map_file(const std::string& map_data);
|
||||
@@ -101,6 +102,23 @@ class ObjectFileDB {
|
||||
});
|
||||
}
|
||||
|
||||
template <typename Func>
|
||||
void for_each_function_def_order(Func f) {
|
||||
for_each_obj([&](ObjectFileData& data) {
|
||||
// printf("IN %s\n", data.record.to_unique_name().c_str());
|
||||
for (int i = 0; i < int(data.linked_data.segments); i++) {
|
||||
// printf("seg %d\n", i);
|
||||
int fn = 0;
|
||||
// for (auto& goal_func : data.linked_data.functions_by_seg.at(i)) {
|
||||
for (size_t j = data.linked_data.functions_by_seg.at(i).size(); j-- > 0;) {
|
||||
// printf("fn %d\n", fn);
|
||||
f(data.linked_data.functions_by_seg.at(i).at(j), i, data);
|
||||
fn++;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Danger: after adding all object files, we assume that the vector never reallocates.
|
||||
std::unordered_map<std::string, std::vector<ObjectFileData>> obj_files_by_name;
|
||||
std::unordered_map<std::string, std::vector<ObjectFileRecord>> obj_files_by_dgo;
|
||||
|
||||
Reference in New Issue
Block a user