mirror of
https://github.com/open-goal/jak-project
synced 2026-07-07 22:22:21 -04:00
[Decompiler] Replace type hint system and improve variable types. (#320)
* get gkernel and gkernel-h at least somewhat working in the offline tests * strip comments from json * switch hints to casts. online tests passing, offline passing up to gkernel * variable retyping is added * fix up casts in lets * update
This commit is contained in:
@@ -611,6 +611,45 @@ void SSA::make_vars(const Function& function, const DecompilerTypeSystem& dts) {
|
||||
init_types = end_types;
|
||||
}
|
||||
}
|
||||
|
||||
// override the types of the variables for function arguments:
|
||||
assert(function.type.arg_count() > 0);
|
||||
for (int arg_idx = 0; arg_idx < int(function.type.arg_count()) - 1; arg_idx++) {
|
||||
auto arg_reg = Register::get_arg_reg(arg_idx);
|
||||
if (!program_read_vars[arg_reg].empty()) {
|
||||
program_read_vars[arg_reg].at(0).type = TP_Type::make_from_ts(function.type.get_arg(arg_idx));
|
||||
}
|
||||
|
||||
if (!program_write_vars[arg_reg].empty()) {
|
||||
program_write_vars[arg_reg].at(0).type =
|
||||
TP_Type::make_from_ts(function.type.get_arg(arg_idx));
|
||||
}
|
||||
}
|
||||
|
||||
// copy types from input argument coloring moves:
|
||||
for (auto& instr : blocks.at(0).ins) {
|
||||
if (instr.is_arg_coloring_move) {
|
||||
auto src_ssa = instr.src.at(0);
|
||||
for (int arg_idx = 0; arg_idx < int(function.type.arg_count()) - 1; arg_idx++) {
|
||||
if (Register::get_arg_reg(arg_idx) == src_ssa.reg()) {
|
||||
// copy the type from here.
|
||||
auto dst = instr.dst;
|
||||
assert(dst);
|
||||
auto dst_reg = instr.dst->reg();
|
||||
auto dst_varid = map.var_id(*dst);
|
||||
if ((int)program_read_vars[dst_reg].size() > dst_varid) {
|
||||
program_read_vars[dst_reg].at(dst_varid).type =
|
||||
TP_Type::make_from_ts(function.type.get_arg(arg_idx));
|
||||
}
|
||||
|
||||
if ((int)program_write_vars[dst_reg].size() > dst_varid) {
|
||||
program_write_vars[dst_reg].at(dst_varid).type =
|
||||
TP_Type::make_from_ts(function.type.get_arg(arg_idx));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void remap_color_move(
|
||||
|
||||
Reference in New Issue
Block a user