How does C++ support create class declarations?

David Nolden zwabel at googlemail.com
Mon Feb 18 19:57:52 UTC 2008


On Monday 18 February 2008 19:47:16 Andreas Pakulat wrote:
> I've got the following DUChain:
> kdevelop(14055)/kdevelop (python support) Python::DumpChain::dump: "" New
> Context  "" [ (0, 0)  ->  (23, 0) ]   top-context kdevelop(14055)/kdevelop
> (python support) Python::DumpChain::dump: "  " New Context  "Bar" [ (0, 0) 
> ->  (2, 1) ] kdevelop(14055)/kdevelop (python support)
> Python::DumpChain::dump: "    " Declaration:  "<notype> "  [ "Bar::" ]  
> 0x844ef20 (internal ctx 0x0 ) [ (0, 6)  ->  (0, 9) ] ,  defined,  0 use(s)
>
> i.e. there's a Context with localScopeIdentifier "Bar" and inside that
> the class declaration and following that would be the body statements.
>
> Or should the Declaration be in the top context and there should be a
> context just for the body with the localScopeIdentifier "Bar"?
>
> Andreas

I think it should be like this:

Context  "" [ (0, 0)  ->  (23, 0) ]   top-context 
 Context  "Bar" id 0x1 [ (0, 0)  ->  (2, 1) ] 
 Declaration "Bar" (internal ctx 0x1)

So the context "Bar" and declaration "Bar" are connected through 
the "Context::owner()" and "Declaration::internalContext()" relationship, and 
they both have the top-context as parent context.

So the second is true. Yes it is very different that for functions, there is 
only one context for the class-body, with the correct localScopeIdentifier. 
That's needed, so members of classes can be addressed. For functions, the 
function-body probably just doesn't have a localScopeIdentifier because it 
doesn't matter, you don't need to address variables declared in a function 
from outside.

Greetings, David




More information about the KDevelop-devel mailing list