[Rose-public] VariableDeclaration name

Tim rose.mailinglist at gmail.com
Wed Sep 18 09:26:34 PDT 2013


Hello Phil,

perfect! It works!

I'm still confused why I have to create a SgName instance:

         SgVariableDeclaration* vd = isSgVariableDeclaration(n);

         SgName name;
         SgInitializedName* in = vd->get_decl_item(name);
         std::cout << in->get_name().getString() << std::endl;

Can you tell me the underlying concept?


Cheers!

Tim

On 09/17/2013 06:28 PM, Phil Miller wrote:
> I believe you want SgInitializedName::get_name(). 
> SgVariableDeclaration represents a statement that may declare several 
> variables, each of which has its own SgInitializedName AST node.
>
>
> On Tue, Sep 17, 2013 at 6:16 PM, Tim <rose.mailinglist at gmail.com 
> <mailto:rose.mailinglist at gmail.com>> wrote:
>
>     Hello,
>
>     I'm using the virtual disc image with the corresponding rose
>     version of 2012.
>     At the moment, I try to write a hello world transformer which
>     inserts new variables into a list
>     of variable declarations. For instance:
>
>     int main(int argc, char* argv[])
>     {
>       int first, insert_after_me, last;
>       return 1;
>     }
>
>     How can I get the name of the current VariableDeclaration?
>     The function get_mangled_name() delivers a long string that
>     contains the var name, however,
>     I don't like to parse this string.
>     Is there any other solution/function like this:
>
>     if(isSgVariableDeclaration(n)){
>
>       SgVariableDeclaration* vd = isSgVariableDeclaration(n);
>
>       if(vd->???.compare("insert_after_me") == 0) {
>
>         ...
>       }
>     }
>
>     I'm happy about every evidence :-)
>
>     Cheers!
>
>     Tim
>     _______________________________________________
>     rose-public mailing list
>     rose-public at nersc.gov <mailto:rose-public at nersc.gov>
>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nersc.gov/pipermail/rose-public/attachments/20130918/ff9d3681/attachment.html>


More information about the rose-public mailing list