decomp drawable, main (#3434)

This commit is contained in:
water111
2024-03-24 12:27:04 -04:00
committed by GitHub
parent ffe01a352d
commit 9b4b54978a
80 changed files with 12118 additions and 200 deletions
+20 -7
View File
@@ -2078,9 +2078,10 @@ std::vector<BitFieldConstantDef> decompile_bitfield_from_int(const TypeSpec& typ
return *try_decompile_bitfield_from_int(type, ts, value, true, {});
}
std::vector<std::string> decompile_bitfield_enum_from_int(const TypeSpec& type,
const TypeSystem& ts,
u64 value) {
std::optional<std::vector<std::string>> try_decompile_bitfield_enum_from_int(const TypeSpec& type,
const TypeSystem& ts,
u64 value,
bool require_success) {
u64 reconstructed = 0;
std::vector<std::string> result;
auto type_info = ts.try_enum_lookup(type.base_type());
@@ -2116,10 +2117,14 @@ std::vector<std::string> decompile_bitfield_enum_from_int(const TypeSpec& type,
}
if (reconstructed != value) {
throw std::runtime_error(fmt::format(
"Failed to decompile bitfield enum {}. Original value is 0x{:x} but we could only "
"make 0x{:x} using the available fields.",
type.print(), value, reconstructed));
if (require_success) {
throw std::runtime_error(fmt::format(
"Failed to decompile bitfield enum {}. Original value is 0x{:x} but we could only "
"make 0x{:x} using the available fields.",
type.print(), value, reconstructed));
} else {
return std::nullopt;
}
}
if (bit_count == (int)result.size()) {
@@ -2137,6 +2142,14 @@ std::vector<std::string> decompile_bitfield_enum_from_int(const TypeSpec& type,
return result;
}
std::vector<std::string> decompile_bitfield_enum_from_int(const TypeSpec& type,
const TypeSystem& ts,
u64 value) {
auto ret = try_decompile_bitfield_enum_from_int(type, ts, value, true);
ASSERT(ret.has_value());
return *ret;
}
std::string decompile_int_enum_from_int(const TypeSpec& type, const TypeSystem& ts, u64 value) {
auto type_info = ts.try_enum_lookup(type.base_type());
ASSERT(type_info);