From: Baptiste L. <gai...@fr...> - 2002-12-22 13:29:32
|
----- Original Message ----- From: "Andre Baresel" <and...@gm...> To: "Baptiste Lepilleur" <gai...@fr...> Sent: Sunday, December 22, 2002 1:42 PM Subject: Re: [Cpptool-develop] Next things .. > >The current implementation of IntroduceExplainingVariable would > >simply do the following things: > >- ask the user for the type and name of the extracted expression > >- add a variable declaration before the statement in which the expression > >appears (may need to add a compound statement) > >- replace the extracted expression with a reference to the new locale > >variable. > > > So I will try to figure out more about the refactoring code ... getting > into this. You may want to try for the InlineTemp refactoring instead of IntroduceExplainingVariable. It's fairly close to RenameTemp and is mainly a search and replace. Deciding where the declaration should be added for IntroduceExplainingVariable is not a simple matter. The code model I'm creating will hopefully help with that. [...] > I was starting to think about a "code rewriter" solution but well, it > seams to me quite complex and > stoped thinking about this for the moment. I could write down some of my > ideas (which will be > incomplete since I need to get more into the code of the whole thing). I was blocked on this topic for a long time, but I had an idea yesterday (still ill defined) which I'm trying to implement. Basically, when you will do: CompoundStatementPtr compound= ...; compound->appendStatement( new WhileStatement( ... ) CompoundStatement will memorize that a new statement was added and rewrite the code as required. [...] > >Parsing for method or function declarations should probably be done while > >dealing with variable and attribute declaration. > > > okido, I'm with you. I skimmed a bit of the C++ standard concerning declaration (by the way, the outtermost level of a source file is only about declaration), and I can say that it's not going to be simple. Beyond parsing, one important thing that we will need to achieve is defining a code model for type representation, so that we will know if a local variable is an instance of a given class, a pointer... Baptiste. |