mirror of
https://github.com/open-goal/jak-project
synced 2026-05-23 06:54:31 -04:00
[Decompiler] Experimental Expression Stack (#157)
* begin framework for expressions * more * clean up warnings * small fixes * update * wip type prop improvements * see if nasm works * fix format strings
This commit is contained in:
@@ -586,7 +586,7 @@ std::string LinkedObjectFile::print_function_disassembly(Function& func,
|
||||
result += ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n";
|
||||
result += func.prologue.to_string(2) + "\n";
|
||||
if (!func.warnings.empty()) {
|
||||
result += "Warnings: " + func.warnings + "\n";
|
||||
result += ";;Warnings:\n" + func.warnings + "\n";
|
||||
}
|
||||
|
||||
// print each instruction in the function.
|
||||
@@ -784,7 +784,7 @@ std::string LinkedObjectFile::print_type_analysis_debug() {
|
||||
result += "; .function " + func.guessed_name.to_string() + "\n";
|
||||
result += ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n";
|
||||
if (!func.warnings.empty()) {
|
||||
result += ";; WARNING: " + func.warnings + "\n";
|
||||
result += ";; WARNING:\n" + func.warnings + "\n";
|
||||
}
|
||||
|
||||
for (auto& block : func.basic_blocks) {
|
||||
@@ -799,10 +799,12 @@ std::string LinkedObjectFile::print_type_analysis_debug() {
|
||||
// result += func.basic_ops.at(i)->print_with_reguse(*this);
|
||||
// result += func.basic_ops.at(i)->print(*this);
|
||||
if (func.attempted_type_analysis) {
|
||||
result += fmt::format("[{:3d}] ", i);
|
||||
result += func.basic_ops.at(i)->print_with_types(*init_types, *this);
|
||||
result += "\n";
|
||||
init_types = &func.basic_ops.at(i)->end_types;
|
||||
} else {
|
||||
result += fmt::format("[{:3d}] ", i);
|
||||
result += func.basic_ops.at(i)->print(*this);
|
||||
result += "\n";
|
||||
}
|
||||
@@ -817,7 +819,7 @@ std::string LinkedObjectFile::print_type_analysis_debug() {
|
||||
/*!
|
||||
* Hacky way to get a GOAL string object
|
||||
*/
|
||||
std::string LinkedObjectFile::get_goal_string(int seg, int word_idx, bool with_quotes) {
|
||||
std::string LinkedObjectFile::get_goal_string(int seg, int word_idx, bool with_quotes) const {
|
||||
std::string result;
|
||||
if (with_quotes) {
|
||||
result += "\"";
|
||||
@@ -826,7 +828,7 @@ std::string LinkedObjectFile::get_goal_string(int seg, int word_idx, bool with_q
|
||||
if (word_idx + 1 >= int(words_by_seg[seg].size())) {
|
||||
return "invalid string!\n";
|
||||
}
|
||||
LinkedWord& size_word = words_by_seg[seg].at(word_idx + 1);
|
||||
const LinkedWord& size_word = words_by_seg[seg].at(word_idx + 1);
|
||||
if (size_word.kind != LinkedWord::PLAIN_DATA) {
|
||||
// sometimes an array of string pointer triggers this!
|
||||
return "invalid string!\n";
|
||||
@@ -1036,7 +1038,7 @@ u32 LinkedObjectFile::read_data_word(const Label& label) {
|
||||
return word.data;
|
||||
}
|
||||
|
||||
std::string LinkedObjectFile::get_goal_string_by_label(const Label& label) {
|
||||
std::string LinkedObjectFile::get_goal_string_by_label(const Label& label) const {
|
||||
assert(0 == (label.offset % 4));
|
||||
return get_goal_string(label.target_segment, (label.offset / 4) - 1, false);
|
||||
}
|
||||
Reference in New Issue
Block a user