Properly fix mis-associated function with vtable entry #239
Labels
Area-OutputGeneration
Issues concerning the process of generating output from Biohazrd
TechDebt
Workaround
The trampolines api work revealed a subtle bug in our logic for associating VTable entries with their corresponding functions.
Right now we resolve using
TranslatedVTableEntry.MethodReference
. This works most of the time but in situations where the function gets duplicated (such as withLiftBaseMethodsTransformation
in Mochi.DirectX) it ends up selecting the wrong function.This wasn't noticed before because the logic in
EmitFunctionContext
would select thethis
pointer type based on the containing record regardless of where theTranslatedFunction
actually came from. However with the new trampoline API the type of thethis
pointer is effectively determined duringCreateTrampolinesTransformation
.For now I've added a hacky workaround which prefers to associate with a function which is on the same record as the vtable, but we either need to:
__HACK__CouldResolveTo
APIs.TryResolve
which can be scoped to a specific declarationLiftBaseMethodsTransformation
(by duplicating the methods and re-associating the vtable entries.The text was updated successfully, but these errors were encountered: