|
From: Baptiste L. <gai...@fr...> - 2002-11-20 09:00:24
|
----- Original Message -----
From: "Sven Reichard" <rei...@ma...>
To: "CppTool Mailing List" <Cpp...@li...>
Sent: Tuesday, November 19, 2002 4:56 PM
Subject: Re: [Cpptool-develop] update
> On Tue, 19 Nov 2002, Baptiste Lepilleur wrote:
> > Don't hesiate to express your doubt, I've never eaten anyone ;-)
> ok :)
> >
> > > are starting to look good :)
> > Indeed. The next step will be dealing with scope I guess. I'll try
> > finalizing the vc6addin before though. There is no better test than
> > real-life usage ;-).
>
> Fine with me. I'm currently quite busy with my thesis, so my input will be
> minimal for the next week or so. However, I'll think about a simple QT
> interface.
>
> About the scope: I assume you refer to another variable with the same name
> being defined in a subscope. This could be dealt with by
> - detecting such a variable;
> - renaming that "inner variable" to some silly name;
> - renaming the outer variable;
> - restoring the original name for the inner variable.
Actually, I'd rather deal with it in a cleaner way. We will need to
correctly resolve scope in the future to apply some refactorings. Having a
working solution at function body level will make it easier to find a
solution working at class level, and later at any level...
The step I have in my head at the current time are more along:
- assign a scope to each 'scope creator' statement (not well defined, but
something like for, if, while, declaration, ...) and create a scope
'hierarchy' (will probably become a graph when extended to deal with global
variable, anonymous namespace and class)
- assign a scope to each declared variable (usually from the
variable-decl-statement to the end of the parent node, with the exception of
the variable initialization on declaration)
- resolve the scope of each variable occurrences (local-scope-identifier and
variable-identifier node). Scope is 'not local' if the variable is unknown
(might be a parameter, class member, or global).
- apply the renaming only on variable with the same scope as the renamed
temporary.
I'll try to add a CodeAnalysisForRefactoring page to the wiki today.
Baptiste.
> (However, even if we don't deal with this case, it won't break the
> program.)
> The only thing we need to be careful about is the outer variable appearing
> in the initializer of the inner variable. I still have to check carefully
> if that is correct code. I mean something like this:
> {
> double x = 3.14;
> {
> int x = std::floor(x);
> }
> }
>
> In this case, the argument to floor is really the outer variable.
>
> Cheers,
> Sven.
>
> --
> Sven Reichard
> Dept. of Math. Sci.
> University of Delaware
> rei...@ma...
>
>
>
> -------------------------------------------------------
> This sf.net email is sponsored by: To learn the basics of securing
> your web site with SSL, click here to get a FREE TRIAL of a Thawte
> Server Certificate: http://www.gothawte.com/rd524.html
> _______________________________________________
> Cpptool-develop mailing list
> Cpp...@li...
> https://lists.sourceforge.net/lists/listinfo/cpptool-develop
>
|