mirror of
https://github.com/open-goal/jak-project
synced 2026-08-08 18:44:15 -04:00
[Decompiler] WIP Conversion to SSA and variable naming (#195)
* begin ssa algorithm * ssa based splitting appears to work * add merge pass * finish basic implementation * better output * bug fix
This commit is contained in:
@@ -162,7 +162,9 @@ void DecompilerTypeSystem::add_symbol(const std::string& name, const TypeSpec& t
|
||||
/*!
|
||||
* Compute the least common ancestor of two TP Types.
|
||||
*/
|
||||
TP_Type DecompilerTypeSystem::tp_lca(const TP_Type& existing, const TP_Type& add, bool* changed) {
|
||||
TP_Type DecompilerTypeSystem::tp_lca(const TP_Type& existing,
|
||||
const TP_Type& add,
|
||||
bool* changed) const {
|
||||
// starting from most vague to most specific
|
||||
|
||||
// simplist case, no difference.
|
||||
@@ -302,7 +304,7 @@ bool DecompilerTypeSystem::tp_lca(TypeState* combined, const TypeState& add) {
|
||||
return result;
|
||||
}
|
||||
|
||||
int DecompilerTypeSystem::get_format_arg_count(const std::string& str) {
|
||||
int DecompilerTypeSystem::get_format_arg_count(const std::string& str) const {
|
||||
int arg_count = 0;
|
||||
for (size_t i = 0; i < str.length(); i++) {
|
||||
if (str.at(i) == '~') {
|
||||
@@ -317,7 +319,7 @@ int DecompilerTypeSystem::get_format_arg_count(const std::string& str) {
|
||||
return arg_count;
|
||||
}
|
||||
|
||||
int DecompilerTypeSystem::get_format_arg_count(const TP_Type& type) {
|
||||
int DecompilerTypeSystem::get_format_arg_count(const TP_Type& type) const {
|
||||
if (type.is_constant_string()) {
|
||||
return get_format_arg_count(type.get_string());
|
||||
} else {
|
||||
|
||||
@@ -38,11 +38,10 @@ class DecompilerTypeSystem {
|
||||
std::string dump_symbol_types();
|
||||
std::string lookup_parent_from_inspects(const std::string& child) const;
|
||||
bool lookup_flags(const std::string& type, u64* dest) const;
|
||||
TP_Type tp_lca(const TP_Type& existing, const TP_Type& add, bool* changed);
|
||||
TP_Type tp_lca_no_simplify(const TP_Type& existing, const TP_Type& add, bool* changed);
|
||||
TP_Type tp_lca(const TP_Type& existing, const TP_Type& add, bool* changed) const;
|
||||
bool tp_lca(TypeState* combined, const TypeState& add);
|
||||
int get_format_arg_count(const std::string& str);
|
||||
int get_format_arg_count(const TP_Type& type);
|
||||
int get_format_arg_count(const std::string& str) const;
|
||||
int get_format_arg_count(const TP_Type& type) const;
|
||||
struct {
|
||||
bool allow_pair;
|
||||
std::string current_method_type;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
#include "common/log/log.h"
|
||||
#include "common/type_system/TypeSpec.h"
|
||||
#include "common/common_types.h"
|
||||
#include "decompiler/Disasm/Register.h"
|
||||
@@ -190,6 +191,7 @@ struct TypeState {
|
||||
case Reg::FPR:
|
||||
return fpr_types[r.get_fpr()];
|
||||
default:
|
||||
lg::die("Cannot use register {} with TypeState.", r.to_charp());
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user