mirror of
https://github.com/open-goal/jak-project
synced 2026-06-26 18:42:01 -04:00
[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:
@@ -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
|
||||
|
||||
@@ -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()) {
|
||||
|
||||
Reference in New Issue
Block a user