<br><br><div class="gmail_quote">On Sat, May 23, 2009 at 3:46 PM, Sebastian Redl <span dir="ltr"><<a href="mailto:sebastian.redl@getdesigned.at">sebastian.redl@getdesigned.at</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im">Douglas Gregor wrote:<br>
><br>
> On May 19, 2009, at 7:18 PM, moataz ragab wrote:<br>
><br>
</div><div class="im">>> Whether it might be useful or not to clone a declaration, it might be<br>
>> useful if you want to create a new variable declaration similar to<br>
>> another declaration and only change the name.<br>
><br>
><br>
> Hmmm, interesting. It seems to me like we really want to give the<br>
> expression's Clone method some information that tells it what to do<br>
> with declarations. For your loop-unrolling rewriter, we want to<br>
> replace some variable declarations with other, similar variables<br>
> (e.g., when the original variable was declared in the loop) or reuse<br>
> the same variable declaration (if the variable is declared outside the<br>
> loop). </div></blockquote><div><br>   For the loop unrolling rewriter, I was thinking about skipping the declarations in loop body and replace them with an assignmen if they were initializing the variable. I planned to stop the cloning at this level and make the expression point to the same declaration.<br>
It doesn't come to my mind a case where I would need to declare another variable. Please correct me if I am wrong?<br>But this is not a generic approach to cloning.<br><br>I had another application, where I want to do loop splitting on parallel processors and that will need to split the arrays to keep them local to each processor memory. I haven't really gone through the implementation but was thinking of just cloning the declaration, change the name and size of the array.<br>
<br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="im">For my purposes, where I need to build a canonical expression,<br>

> we replace types with their canonical types and replace some<br>
> declarations (e.g., for non-type template parameters) with their<br>
> "canonical" declarations. This tells me that we need to think about<br>
> some kind of policy argument for Clone() that permits these changes.<br>
</div>A callback to handle all sub-objects, instead of just cloning<br>
recursively? It would be very tricky to do as a "policy" that is<br>
anything less than a fully generic callback, given that cloning is deep.<br>
The callback has to handle everything in that part of the AST somehow.<br>
You can't stop at a single level.  <br></blockquote><div>   What do you think about passing a visitor to Clone()?<br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
<font color="#888888"><br>
Sebastian<br>
</font></blockquote></div><br>