List Info

Thread: Using duchain in QMake support




Using duchain in QMake support
user name
2008-03-08 03:19:08
Hi,

I've started to think what I want to do during hackathon and
one thing
that really needs love is the QMake support. 

By now I've got some basic idea how duchain works and what
it might
enable to do in a quite easy way. So I'm thinking that
instead of
further writing the code that exists to walk the AST and
collect
variable names and values just building a duchain for the
QMake files
and then using that to dynamically lookup variable values
and similar
things.

Another thing is that duchain hopefully makes it easier to
provide full
project support - adding/removing and renaming/moving files
- as thats
basically "just" refactoring.

To make sure I don't expect too much from duchain, I'd like
to get some
answers for the following questions:

- Is "Foo = Barn...nFoo = A B C" only a
definition or also a use of 
  the Variable Foo? i.e. Foo is re-defined to a different
value.

- Can I find the last occurence of a variable assignment
within a
  certain context?

- qmake supports config scopes, i.e. "win32 { ... }
unix { ...}"
  can I map that with the environment stuff? How do I later
on access
  all the different config-parts (so I can enable a switch
in the ui
  "show files from all platform-configs")

- I guess the include-file stuff in C++ still works properly
when having
  a #include in the middle of the file right? (In qmake its
not uncommon
  to do a include(somefile.pri) in the middle of a file,
especially with
  the config scopes)

- Does expression evaluation in C++ support function calls?
I guess not,
  but I probably need this for QMake. Is it feasible to
calculate this
  during duchain building, or should I just note a use of
the function
  and later on calculate it "on the fly"?

I guess thats enough for now 

Andreas

-- 
You possess a mind not merely twisted, but actually
sprained.

_______________________________________________
KDevelop-devel mailing list
KDevelop-develkdevelop.org
https://barney.cs.uni-potsdam.de/mailman/listinf
o/kdevelop-devel

Re: Using duchain in QMake support
country flaguser name
Germany
2008-03-08 05:42:49
On Saturday 08 March 2008 10:19:08 Andreas Pakulat wrote:
> - Is "Foo = Barn...nFoo = A B C" only a
definition or also a use of
>   the Variable Foo? i.e. Foo is re-defined to a
different value.
That depends on how you interpret it. After all it's you who
builds the 
uses/declarations specifically for the language, in the way
that you think it 
makes sense.

However I'd say that the first assignment is a declaration,
because "Foo" 
isn't declared yet, and the second assignment contains a use
of the 
declaration of "Foo".

> - Can I find the last occurence of a variable
assignment within a
>   certain context?
Sure, as long as you record each assignment as a use.
However a use doesn't 
contain additional information like the actual expression
that is being 
assigned.

> - qmake supports config scopes, i.e. "win32 { ...
} unix { ...}"
>   can I map that with the environment stuff? How do I
later on access
>   all the different config-parts (so I can enable a
switch in the ui
>   "show files from all platform-configs")
I don't think you will need such complicated stuff like the
C++ environment 
management, but I also don't know how this exactly works
within QMake, so I 
cannot answer it clearly.

> - I guess the include-file stuff in C++ still works
properly when having
>   a #include in the middle of the file right? (In qmake
its not uncommon
>   to do a include(somefile.pri) in the middle of a
file, especially with
>   the config scopes)
Yep in C++ that works. In general, it should be nothing more
than a simple 
import.

> - Does expression evaluation in C++ support function
calls? I guess not,
>   but I probably need this for QMake. Is it feasible to
calculate this
>   during duchain building, or should I just note a use
of the function
>   and later on calculate it "on the fly"?

In C++, usually only the return-types of functions are
evaluated, because 
that's all that can be represented statically. Static
expressions like "const 
int a = otherInt + 5" or
"SomeClass<otherConstInt + 5>" are also
evaluated 
wherever needed, either while building the duchain, or
later.

Probably it'll be fine for you to evaluate the functions
while building the 
duchain.

Greetings, David

_______________________________________________
KDevelop-devel mailing list
KDevelop-develkdevelop.org
https://barney.cs.uni-potsdam.de/mailman/listinf
o/kdevelop-devel

Re: Using duchain in QMake support
user name
2008-03-08 12:23:58
On 08.03.08 12:42:49, David Nolden wrote:
> On Saturday 08 March 2008 10:19:08 Andreas Pakulat
wrote:
> > - Can I find the last occurence of a variable
assignment within a
> >   certain context?
> Sure, as long as you record each assignment as a use.
However a use doesn't 
> contain additional information like the actual
expression that is being 
> assigned.

Hmm, thats not soo good. Well, I guess I can find the AST
for a given
range and use the expression from that...

> > - qmake supports config scopes, i.e. "win32 {
... } unix { ...}"
> >   can I map that with the environment stuff? How
do I later on access
> >   all the different config-parts (so I can enable
a switch in the ui
> >   "show files from all
platform-configs")
> I don't think you will need such complicated stuff like
the C++ environment 
> management, but I also don't know how this exactly
works within QMake, so I 
> cannot answer it clearly.

Well, it works similar to 

#if defined(Q_OS_WIN)
<some code>
#elif defines(Q_OS_UNIX)
...
#endif

and the qmake support obviously needs to know which code
belongs to
which config option (or combination of them). Specifically
the user can
define its own config options, so its not solely about the
platform.

> > - Does expression evaluation in C++ support
function calls? I guess not,
> >   but I probably need this for QMake. Is it
feasible to calculate this
> >   during duchain building, or should I just note a
use of the function
> >   and later on calculate it "on the
fly"?
> 
> In C++, usually only the return-types of functions are
evaluated, because 
> that's all that can be represented statically. Static
expressions like "const 
> int a = otherInt + 5" or
"SomeClass<otherConstInt + 5>" are also
evaluated 
> wherever needed, either while building the duchain, or
later.
> 
> Probably it'll be fine for you to evaluate the
functions while building the 
> duchain.

Yeah, in QMake im in kind of a "lucky" position as
its relatively
limited and most of the functions are also defined in the
QMake language
(for example loops and such).

Andreas

-- 
You are capable of planning your future.

_______________________________________________
KDevelop-devel mailing list
KDevelop-develkdevelop.org
https://barney.cs.uni-potsdam.de/mailman/listinf
o/kdevelop-devel

[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )