[Decompiler] Static Data Decomp (#280)

* update all-types

* begin work on static data decompiler

* working for vif disasm array

* mostly working

* finish static data decompilation
This commit is contained in:
water111
2021-02-25 09:51:28 -05:00
committed by GitHub
parent 9d84ba8ca4
commit 791c4abfc0
31 changed files with 2064 additions and 69 deletions
+19 -5
View File
@@ -5,11 +5,11 @@
* A word (4 bytes), possibly with some linking info.
*/
#ifndef JAK2_DISASSEMBLER_LINKEDWORD_H
#define JAK2_DISASSEMBLER_LINKEDWORD_H
#include <cstdint>
#include <string>
#include <cassert>
#include "common/common_types.h"
namespace decompiler {
class LinkedWord {
@@ -31,7 +31,21 @@ class LinkedWord {
int label_id = -1;
std::string symbol_name;
u8 get_byte(int idx) const {
assert(kind == PLAIN_DATA);
switch (idx) {
case 0:
return data & 0xff;
case 1:
return (data >> 8) & 0xff;
case 2:
return (data >> 16) & 0xff;
case 3:
return (data >> 24) & 0xff;
default:
assert(false);
}
}
};
} // namespace decompiler
#endif // JAK2_DISASSEMBLER_LINKEDWORD_H
+8 -1
View File
@@ -456,7 +456,14 @@ std::string ObjectFileDB::ir2_to_file(ObjectFileData& data) {
// functions
for (auto& func : data.linked_data.functions_by_seg.at(seg)) {
result += ir2_function_to_string(data, func, seg);
try {
result += ir2_function_to_string(data, func, seg);
} catch (std::exception& e) {
result += "Failed to write: ";
result += e.what();
result += "\n";
}
if (func.ir2.top_form && func.ir2.env.has_local_vars()) {
result += '\n';
if (func.ir2.env.has_local_vars()) {