mirror of
https://github.com/open-goal/jak-project
synced 2026-08-22 07:04:29 -04:00
[Decompiler] Fixes for dma-disasm (#377)
* small tweaks * fix up some more dma stuff
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user