Given a function, I would like to swap all calls to the function f()
with calls to the function g()
in the body of the given function. The operation does not need to modify the original function. Generating a new function from the original is also fine.
To clarify, I need to generate a new method with the same body as the original method, but with all calls to f()
swapped with calls to g()
.
I read the related post (Swap method implementation at runtime in .NET?), but it provides no useful information on how to accomplish this.
It would be best if this were done during compile-time, but runtime swapping is also fine.
I am trying to make a recursive function memoizer. I have read the related post (C# Memoization of functions with arbitrary number of arguments), but this provides only memoization of a single call, which is rather simple, while I want the memoization to be implemented on all recursive calls to the function.
Also, I would prefer not using third-party libraries.
Aucun commentaire:
Enregistrer un commentaire