Is it possible to clone a node in an AST?

Hi!

First, thank you so much again for your answer. I know that I can use the Rewriter class in order to do that kind of transformations (I’m using it for other operations, indeed), but probably I didn’t explained myself very well what I really want to do, so I’ll try to explain my problem from a different point of view:

I need to transform a given piece of code (for example, unroll a loop body rewriting adequate additional sentences just under the original -my tool does this thing right now using the Rewrite class-), but, according to the code optimization I want to implement, once this piece of code had been transformed, I need to do a second transformation with it, and for this I’d need to have an updated version of the AST in order to use the methods of the different classes that inherit from Stmt to access the multiple parts of any sentence.

Anyway, I’d like to know how clone nodes from an AST (o adding new ones) in order to do in a future more complex transformations than those I’m describing now.

Thanks,

Jorge.

2012/5/3 Robert Ankeney <rrankene@gmail.com>