2020-09-13 21:32:55 -04:00
|
|
|
#pragma once
|
|
|
|
|
2020-08-22 23:30:17 -04:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
#include <unordered_set>
|
2020-12-17 15:48:07 -05:00
|
|
|
#include <unordered_map>
|
2021-02-27 14:40:18 -05:00
|
|
|
#include <optional>
|
2020-12-17 15:48:07 -05:00
|
|
|
#include "decompiler/Disasm/Register.h"
|
|
|
|
|
2021-01-06 20:04:15 -05:00
|
|
|
namespace decompiler {
|
2021-03-13 16:10:39 -05:00
|
|
|
struct TypeCast {
|
|
|
|
int atomic_op_idx = -1;
|
2020-12-17 15:48:07 -05:00
|
|
|
Register reg;
|
|
|
|
std::string type_name;
|
|
|
|
};
|
2020-08-22 23:30:17 -04:00
|
|
|
|
2021-02-20 11:42:46 -05:00
|
|
|
struct LabelType {
|
|
|
|
std::string type_name;
|
|
|
|
bool is_const = false;
|
2021-02-27 14:40:18 -05:00
|
|
|
std::optional<int> array_size;
|
2021-02-20 11:42:46 -05:00
|
|
|
};
|
|
|
|
|
2021-03-13 16:10:39 -05:00
|
|
|
struct LocalVarOverride {
|
|
|
|
std::string name;
|
|
|
|
// this may be left out, indicating that the variable should use the type determined
|
|
|
|
// by the type analysis pass.
|
|
|
|
std::optional<std::string> type;
|
|
|
|
};
|
|
|
|
|
2021-03-27 15:18:59 -04:00
|
|
|
/*!
|
|
|
|
* Information about a variable pointing to some data on the stack.
|
|
|
|
*/
|
|
|
|
struct StackVariableHint {
|
|
|
|
std::string element_type; // type of the thing stored
|
|
|
|
// todo - is boxed array on the stack supported?
|
|
|
|
enum class ContainerType {
|
|
|
|
NONE, // just store the plain thing.
|
|
|
|
ARRAY, // for refs, array of refs. For values, array of values.
|
|
|
|
INLINE_ARRAY // for refs, array of values, for values, invalid
|
|
|
|
} container_type = ContainerType::NONE;
|
|
|
|
int container_size = -1; // if container other than NONE, the number of elements.
|
|
|
|
int stack_offset = 0; // where it's located on the stack (relative to sp after prologue)
|
|
|
|
};
|
|
|
|
|
2020-08-22 23:30:17 -04:00
|
|
|
struct Config {
|
|
|
|
int game_version = -1;
|
|
|
|
std::vector<std::string> dgo_names;
|
2020-11-19 21:22:16 -05:00
|
|
|
std::vector<std::string> object_file_names;
|
2020-11-21 15:58:51 -05:00
|
|
|
std::vector<std::string> str_file_names;
|
2020-10-24 22:51:40 -04:00
|
|
|
std::unordered_set<std::string> bad_inspect_types;
|
2020-10-24 14:27:50 -04:00
|
|
|
std::string obj_file_name_map_file;
|
2020-08-22 23:30:17 -04:00
|
|
|
bool write_disassembly = false;
|
|
|
|
bool write_hexdump = false;
|
|
|
|
bool write_scripts = false;
|
|
|
|
bool write_hexdump_on_v3_only = false;
|
|
|
|
bool disassemble_objects_without_functions = false;
|
|
|
|
bool write_hex_near_instructions = false;
|
2020-11-16 19:57:45 -05:00
|
|
|
bool analyze_functions = false;
|
|
|
|
bool process_tpages = false;
|
2020-11-19 21:22:16 -05:00
|
|
|
bool process_game_text = false;
|
2020-11-24 20:48:38 -05:00
|
|
|
bool process_game_count = false;
|
|
|
|
bool dump_objs = false;
|
2020-11-27 16:38:36 -05:00
|
|
|
bool write_func_json = false;
|
2020-11-28 15:35:38 -05:00
|
|
|
bool function_type_prop = false;
|
2020-12-17 15:48:07 -05:00
|
|
|
bool analyze_expressions = false;
|
2021-03-05 18:48:01 -05:00
|
|
|
bool insert_lets = false;
|
2020-08-22 23:30:17 -04:00
|
|
|
std::unordered_set<std::string> asm_functions_by_name;
|
2020-11-28 15:35:38 -05:00
|
|
|
std::unordered_set<std::string> pair_functions_by_name;
|
2020-12-17 15:48:07 -05:00
|
|
|
std::unordered_set<std::string> no_type_analysis_functions_by_name;
|
2021-02-01 20:41:37 -05:00
|
|
|
std::unordered_set<std::string> allowed_objects;
|
2021-03-13 16:10:39 -05:00
|
|
|
std::unordered_map<std::string, std::unordered_map<int, std::vector<TypeCast>>>
|
|
|
|
type_casts_by_function_by_atomic_op_idx;
|
2020-12-26 11:09:59 -05:00
|
|
|
std::unordered_map<std::string, std::unordered_map<int, std::string>>
|
|
|
|
anon_function_types_by_obj_by_id;
|
2021-02-09 20:59:14 -05:00
|
|
|
std::unordered_map<std::string, std::vector<std::string>> function_arg_names;
|
2021-03-13 16:10:39 -05:00
|
|
|
std::unordered_map<std::string, std::unordered_map<std::string, LocalVarOverride>>
|
|
|
|
function_var_overrides;
|
2021-02-20 11:42:46 -05:00
|
|
|
std::unordered_map<std::string, std::unordered_map<std::string, LabelType>> label_types;
|
2021-03-27 15:18:59 -04:00
|
|
|
std::unordered_map<std::string, std::vector<StackVariableHint>> stack_var_hints_by_function;
|
2021-01-09 20:01:48 -05:00
|
|
|
bool run_ir2 = false;
|
2021-04-26 21:40:08 -04:00
|
|
|
|
|
|
|
std::unordered_set<std::string> hint_inline_assembly_functions;
|
2020-08-22 23:30:17 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
Config& get_config();
|
|
|
|
void set_config(const std::string& path_to_config_file);
|
2021-03-27 15:18:59 -04:00
|
|
|
|
2021-01-06 20:04:15 -05:00
|
|
|
} // namespace decompiler
|