Hi!, I'm working on a compiler plugin in backend I...
# compiler
r
Hi!, I'm working on a compiler plugin in backend IR where I'm in need to move some statements from a user generated function to a plugin generated one. When I move the statements using
IrElement.deepCopyWithSymbol
I can properly clone the entire tree I need but this tree comes with proper offsets that I need to reset to
UNDEFINED_OFFSET
. I tried recursively walking the tree and mutating it but offsets are declared as a
val
and passed as arguments to most methods in
irFactory
. Is there a way to change the offsets of an existing IR Tree? Is there a way to clone a tree without the offsets? Thanks!
i
deepCopyWithSymbols
accepts
createCopier
as the last parameter. By default, it creates
DeepCopyIrTreeWithSymbols
, but in your case, you should implement your own copier, which will be similar to
DeepCopyIrTreeWithSymbols
, but resetting offsets.
r
Thanks @Ilmir Usmanov [JB], I worked around it by not transferring the statements and making a delegated call to the original function containing the statements, but I will use that next time I'm in need of this. :)