Is there an “official” way to run the CodeInfo objects that one gets from code_typed?
I’d like to be able to do some transformations on code based the types of intermediate results, and then run the transformed code. (I could work with the surface-syntax Expr and write my own machinery to figure out the types, but I’d rather avoid having to do that.) My plan was to get the lowered, typed IR from code_typed, transform that, and evaluate the transformed code. For the last step, I would need some kind of feval(f::Core.CodeInfo, args...).
I’ve seen this done in Cassette.jl using some advanced voodoo, but I was thinking there was maybe an easier way. (If not, I’ll probably end up using Cassette - It seems like a brilliant project.)
I did look at Sugar, but I couldn’t find any documentation. Does get_func_expr convert the IR back into an Expr? Does this work in general, or only for a subset of Julia?
it’s just a subset for silly reasons… Btw, it should be relatively straight forward to replace the
unsupported expressions in the linear ir returned by code_typed…
…but I get an error message because postwalk (called by replace_slots, line 258) is undefined. I’ve switched to branch sd/07 on Sugar and Matcha. Am I missing something?