decomp/goalc: support object references in static data

This commit is contained in:
Tyler Wilding
2022-09-25 21:20:13 -04:00
parent 5c7a3384e5
commit a41f616ff8
4 changed files with 35 additions and 11 deletions
+14
View File
@@ -56,6 +56,20 @@
"jak1"
]
},
{
"type": "default",
"project": "CMakeLists.txt",
"projectTarget": "offline-test.exe (bin\\offline-test.exe)",
"name": "Tests - Offline Tests - Jak 2 - Specific File",
"args": [
"--iso_data_path",
"${workspaceRoot}/iso_data/jak2",
"--game",
"jak2",
"--file",
"progress-static"
]
},
{
"type": "default",
"project": "CMakeLists.txt",
+7 -4
View File
@@ -29087,10 +29087,13 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(deftype hud-scene-info (basic)
((name basic :offset-assert 4)
(continue basic :offset-assert 8)
(info basic :offset-assert 12)
(text uint32 :offset-assert 16)
((name string :offset-assert 4)
(continue string :offset-assert 8)
;; TODO - the decompiler currently doesn't properly handle overlay fields from static data
(info object :offset-assert 12)
(info-str string :offset 12)
(info-list pair :offset 12) ;; a list of strings
(text uint32 :offset-assert 16)
)
:method-count-assert 9
:size-assert #x14
+13 -6
View File
@@ -971,7 +971,7 @@ goos::Object decompile_structure(const TypeSpec& type,
// first, let's see if it's a value or reference
auto field_type_info = ts.lookup_type_allow_partial_def(field.type());
if (!field_type_info->is_reference()) {
if (!field_type_info->is_reference() && field.type() != TypeSpec("object")) {
// value type. need to get bytes.
ASSERT(!field.is_inline());
if (field.is_array()) {
@@ -1159,9 +1159,15 @@ goos::Object decompile_structure(const TypeSpec& type,
if (field.type() == TypeSpec("symbol")) {
continue;
}
field_defs_out.emplace_back(
field.name(), decompile_at_label(field.type(), labels.at(word.label_id()), labels,
words, ts, file));
if (field.type() == TypeSpec("object")) {
field_defs_out.emplace_back(
field.name(),
decompile_at_label_guess_type(labels.at(word.label_id()), labels, words, ts, file));
} else {
field_defs_out.emplace_back(
field.name(), decompile_at_label(field.type(), labels.at(word.label_id()), labels,
words, ts, file));
}
} else if (word.kind() == LinkedWord::PLAIN_DATA && word.data == 0) {
// do nothing, the default is zero?
field_defs_out.emplace_back(field.name(), pretty_print::to_symbol("0"));
@@ -1560,8 +1566,9 @@ goos::Object decompile_pair(const DecompilerLabel& label,
} else {
auto& word = words.at(label.target_segment).at(label.offset / 4);
if (word.kind() != LinkedWord::EMPTY_PTR) {
throw std::runtime_error(
fmt::format("Based on alignment, expected to get empty list for pair, but didn't"));
throw std::runtime_error(fmt::format(
"Based on alignment, expected to get empty list for pair, but didn't. Label - {}",
label.name));
}
return pretty_print::to_symbol("'()");
}
+1 -1
View File
@@ -140,7 +140,7 @@ void Compiler::compile_static_structure_inline(const goos::Object& form,
}
} else if (is_structure(field_info.type) || is_pair(field_info.type) ||
is_symbol(field_info.type)) {
is_symbol(field_info.type) || field_info.type == TypeSpec("object")) {
if (is_pair(field_info.type)) {
ASSERT(!field_info.field.is_inline());
}