[Decompiler] Fixes for dma-disasm (#377)

* small tweaks

* fix up some more dma stuff
This commit is contained in:
water111
2021-04-23 20:29:15 -04:00
committed by GitHub
parent 0b8a878533
commit fa122356ec
57 changed files with 467 additions and 433 deletions
+21
View File
@@ -478,6 +478,7 @@ Form* cast_to_bitfield_enum(const EnumType* type_info,
FormPool& pool,
const Env& env,
Form* in) {
assert(type_info->is_bitfield());
auto integer = get_goal_integer_constant(strip_int_or_uint_cast(in), env);
if (integer) {
auto elts =
@@ -495,4 +496,24 @@ Form* cast_to_bitfield_enum(const EnumType* type_info,
}
}
Form* cast_to_int_enum(const EnumType* type_info,
const TypeSpec& typespec,
FormPool& pool,
const Env& env,
Form* in) {
assert(!type_info->is_bitfield());
auto integer = get_goal_integer_constant(strip_int_or_uint_cast(in), env);
if (integer) {
auto entry =
decompile_int_enum_from_int(TypeSpec(type_info->get_name()), env.dts->ts, *integer);
auto oper = GenericOperator::make_function(
pool.alloc_single_element_form<ConstantTokenElement>(nullptr, type_info->get_name()));
return pool.alloc_single_element_form<GenericElement>(
nullptr, oper, pool.alloc_single_element_form<ConstantTokenElement>(nullptr, entry));
} else {
// all failed, just return whatever.
return pool.alloc_single_element_form<CastElement>(nullptr, typespec, in);
}
}
} // namespace decompiler