// Copyright (c) 2024 Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/)

////////////////////////////////
//~ rjf: RADDBG Converter Helper Implementation Generators

@gen @c_file
{
  `internal RDI_RegCode regs_rdi_code_from_arch_reg_code(Architecture arch, REGS_RegCode code)`;
  `{`;
    `RDI_RegCode result = 0;`;
    `switch(arch)`;
    `{`;
      `default:{}break;`;
      `case Architecture_x64:`;
      `{`;
        `switch(code)`
          `{`;
          `default:{}break;`;
          @expand(REGS_RegTableX64 a) `case REGS_RegCodeX64_$(a.name):{result = RDI_RegCodeX64_$(a.name);}break;`;
          `}`;
        `}break;`;
      `case Architecture_x86:`;
      `{`;
        `switch(code)`
          `{`;
          `default:{}break;`;
          @expand(REGS_RegTableX86 a) `case REGS_RegCodeX86_$(a.name):{result = RDI_RegCodeX86_$(a.name);}break;`;
          `}`;
        `}break;`;
      `}`;
    `return result;`;
    `}`;
}

@gen @c_file
{
  `internal REGS_RegCode regs_reg_code_from_arch_rdi_code(Architecture arch, RDI_RegCode code)`;
  `{`;
    `REGS_RegCode result = 0;`;
    `switch(arch)`;
    `{`;
      `default:{}break;`;
      `case Architecture_x64:`;
      `{`;
        `switch(code)`
          `{`;
          `default:{}break;`;
          @expand(REGS_RegTableX64 a) `case RDI_RegCodeX64_$(a.name):{result = REGS_RegCodeX64_$(a.name);}break;`;
          `}`;
        `}break;`;
      `case Architecture_x86:`;
      `{`;
        `switch(code)`
          `{`;
          `default:{}break;`;
          @expand(REGS_RegTableX86 a) `case RDI_RegCodeX86_$(a.name):{result = REGS_RegCodeX86_$(a.name);}break;`;
          `}`;
        `}break;`;
      `}`;
    `return result;`;
    `}`;
}
