Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix issue with branching to swapped stfld -> callvirt
Given the (abridged) psuedo-IL ```asm ldfld PlayerData ... ldfld bool ... brtrue.s :opt ldfld string .. br.s :set opt: ldfld string ... set: stfld PlayerData::someField ``` We were patching it to the following: ```asm ldfld PlayerData ... ldfld bool ... brtrue.s :opt ldfld string ... br.s :set opt: ldfld string ... ldstr "someField" set: callvirt instance void PlayerData::SetStringSwappedArgs(string, string) ``` and the way we did this patching is by swapping an `stfld` to a `callvirt` and then inserting the `ldstr` for the field name (which is the second arg for our SetStringSwappedArgs) before this `callvirt` we inserted. However, given this situation, we skip over the ldstr of the field name when coming from the `false` branch path as it branches directly to `set` as it had previously branched directly to an `stfld` and branching is instruction location based. The fix for this is relatively simple, just swap the `stfld` with the `ldstr` instead, and then insert our `callvirt` afterwards, which gives the following: ```asm ldfld PlayerData ... ldfld bool ... brtrue.s :opt ldfld string ... br.s :set opt: ldfld string ... set: ldstr "someField" callvirt instance void PlayerData::SetStringSwappedArgs(string, string) ```
- Loading branch information