[decomp2] game-info, game-task and task-control (#1884)

And everything else needed for them!

A couple functions are bad currently.

- fixes #1929 - untested on linux
- fixes #1924 - now you need to type `,` before a lambda you want to put
in a pair.
- fix debugger symbol table in jak 2
- made the decompiler output `(meters 2)` instead of `(meters 2.0)`
- fixed a bug with the bitfield enum special -1 case
- made bad game text decomp not exit the decompiler
- added `editable-player` and `script`
This commit is contained in:
ManDude
2022-09-28 00:44:20 +01:00
committed by GitHub
parent e3a4627eeb
commit 9351bf782e
129 changed files with 48750 additions and 6299 deletions
+18 -8
View File
@@ -160,12 +160,18 @@ goos::Object decompile_at_label_guess_type(const DecompilerLabel& label,
}
goos::Object decompile_function_at_label(const DecompilerLabel& label,
const LinkedObjectFile* file) {
const LinkedObjectFile* file,
bool in_static_pair) {
if (file) {
auto other_func = file->try_get_function_at_label(label);
if (other_func && other_func->ir2.env.has_local_vars() && other_func->ir2.top_form &&
other_func->ir2.expressions_succeeded) {
return final_output_lambda(*other_func);
auto out = final_output_lambda(*other_func);
if (in_static_pair) {
return pretty_print::build_list("unquote", out);
} else {
return out;
}
}
}
return pretty_print::to_symbol(fmt::format("<lambda at {}>", label.name));
@@ -180,13 +186,14 @@ goos::Object decompile_at_label(const TypeSpec& type,
const std::vector<DecompilerLabel>& labels,
const std::vector<std::vector<LinkedWord>>& words,
const TypeSystem& ts,
const LinkedObjectFile* file) {
const LinkedObjectFile* file,
bool in_static_pair) {
if (type == TypeSpec("string")) {
return decompile_string_at_label(label, words);
}
if (ts.tc(TypeSpec("function"), type)) {
return decompile_function_at_label(label, file);
return decompile_function_at_label(label, file, in_static_pair);
}
if (ts.tc(TypeSpec("array"), type)) {
@@ -721,6 +728,7 @@ goos::Object decompile_sound_spec(const TypeSpec& type,
// volume is fixed point, and floats should round towards zero, so we convert specific ints
// to better-looking floats that end up being the same value.
// there should be a more automated way to do this, but i am a bit lazy.
// TODO try fixed point print i made some time ago
switch (volume) {
case 0x2cc:
volf = 70;
@@ -1528,13 +1536,13 @@ goos::Object decompile_pair_elt(const LinkedWord& word,
return decompile_pair(label, labels, words, ts, false, file);
}
return decompile_at_label(*guessed_type, label, labels, words, ts, file);
return decompile_at_label(*guessed_type, label, labels, words, ts, file, true);
} else if (word.kind() == LinkedWord::PLAIN_DATA && word.data == 0) {
// do nothing, the default is zero?
return pretty_print::to_symbol("0");
} else if (word.kind() == LinkedWord::SYM_PTR) {
// never quote symbols in a list.
return pretty_print::to_symbol(fmt::format("{}", word.symbol_name()));
return pretty_print::to_symbol(word.symbol_name());
} else if (word.kind() == LinkedWord::EMPTY_PTR) {
return pretty_print::to_symbol("'()");
} else if (word.kind() == LinkedWord::PLAIN_DATA && (word.data & 0b111) == 0) {
@@ -1556,12 +1564,14 @@ goos::Object decompile_pair(const DecompilerLabel& label,
const LinkedObjectFile* file) {
if ((label.offset % 8) != 2) {
if ((label.offset % 4) != 0) {
throw std::runtime_error(fmt::format("Invalid alignment for pair {}\n", label.offset % 16));
throw std::runtime_error(
fmt::format("Invalid alignment for pair {} at {}\n", label.offset % 16, label.name));
} 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"));
fmt::format("Based on alignment, expected to get empty list for pair at {}, but didn't",
label.name));
}
return pretty_print::to_symbol("'()");
}