When to create Contexts (or: how does C++ do it)

Andreas Pakulat apaku at gmx.de
Wed Feb 13 21:42:22 UTC 2008

On 11.02.08 00:23:37, David Nolden wrote:
> On Sunday 10 February 2008 23:58:32 Andreas Pakulat wrote:
> > Hi,
> >
> > I'm looking at the visitFunctionDefinition/Declaration code in C++
> > contextbuilder and am wondering about something:
> >
> > What range does the created context cover? If I'm not completely wrong
> > there's only 1 context opened for a function definition, thats the one
> > for its content.
> >
> > If thats true: Why is there no context for the functions parameters?
> > Aren't that also declarations which would need a context? Or how is that
> > done?
> >
> > I'm mostly wondering because in the visitForStatement there's a separate
> > context for the init/end/step part, i.e. the actual looping conditions.
> > And of course the other one that covers the body of the for (importing
> > the first one)
> >
> > Andreas
> Here's how it works in C++:
> For function-declarations, there is always one context created for the 
> parameters. That context has type DUContext::Function. If the 
> function-declaration has a body, another context is created for the body. 
> Such code-context always have type DUContext::Other. The body context then 
> imports the function-cotext, so the parameters are visible from within it.

As far as I can see the code-context doesn't carry the identifier of the
function (as opposed to the function declaration). Isn't that a bit
problematic? I mean how does DUChain know that this context belongs to
the function? Is the context associated to the definition object that
gets created for a function definition? (I haven't yet dived into
creating declarations and definitions, just trying to get some contexts
created first)


Alimony and bribes will engage a large share of your wealth.

More information about the KDevelop-devel mailing list