mirror of
https://github.com/open-goal/jak-project
synced 2026-06-02 18:19:07 -04:00
[Decompiler] Clean up the output (#245)
* fix parent issue * fix compiler issue * update * add error messages * fix error * fix array access, temporary * more clean * fix * rename arg variables better * fix method name * fix no return value in decompiler * many small fixes * cheat types so it works * name map * fix old test'
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
* This runs the IR2 analysis passes.
|
||||
*/
|
||||
|
||||
#include <common/link_types.h>
|
||||
#include "ObjectFileDB.h"
|
||||
#include "common/log/log.h"
|
||||
#include "common/util/Timer.h"
|
||||
@@ -416,8 +417,11 @@ void ObjectFileDB::ir2_write_results(const std::string& output_dir) {
|
||||
auto file_text = ir2_to_file(obj);
|
||||
total_bytes += file_text.length();
|
||||
auto file_name = file_util::combine_path(output_dir, obj.to_unique_name() + "_ir2.asm");
|
||||
|
||||
file_util::write_text_file(file_name, file_text);
|
||||
|
||||
auto final = ir2_final_out(obj);
|
||||
auto final_name = file_util::combine_path(output_dir, obj.to_unique_name() + "_disasm.gc");
|
||||
file_util::write_text_file(final_name, final);
|
||||
}
|
||||
});
|
||||
lg::info("Wrote {} files ({:.2f} MB) in {:.2f} ms\n", total_files, total_bytes / float(1 << 20),
|
||||
@@ -731,4 +735,19 @@ bool ObjectFileDB::lookup_function_type(const FunctionName& name,
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string ObjectFileDB::ir2_final_out(ObjectFileData& data) {
|
||||
if (data.obj_version == 3) {
|
||||
std::string result;
|
||||
result += ";;-*-Lisp-*-\n";
|
||||
result += "(in-package goal)\n\n";
|
||||
assert(data.linked_data.functions_by_seg.at(TOP_LEVEL_SEGMENT).size() == 1);
|
||||
auto top_level = data.linked_data.functions_by_seg.at(TOP_LEVEL_SEGMENT).at(0);
|
||||
result += write_from_top_level(top_level, dts, data.linked_data);
|
||||
result += "\n\n";
|
||||
return result;
|
||||
} else {
|
||||
return ";; not a code file.";
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace decompiler
|
||||
|
||||
Reference in New Issue
Block a user