ODP: Non default declaration search mechanism

Kucharski, Lukasz (NSN - PL/Wroclaw) lukasz.kucharski at nsn.com
Sun Jan 22 02:25:40 UTC 2012


Hi Milian,

Yes, I'm doing it openly, currently sources are available here: http://gitorious.org/kdevttcnsupport.
I will consider to move this project to KDE git.


When building enumeration types with unnamed context, I was able to get two instances of enumerator declaration, it was possible to distinguish enumeration type but next step seems to be problem. No matter which declaration is passed to newUse method effect is always the same, most probably due to same qualifiedIdentifier.

So how to overcome this issue?

BTW: ttcn3 do not support function overloading.

Lukasz


-----Wiadomość oryginalna-----
Od: ext Milian Wolff [mailto:mail at milianw.de]
Wysłano: N 2012-01-22 03:03
Do: kdevelop-devel at barney.cs.uni-potsdam.de
DW: Kucharski, Lukasz (NSN - PL/Wroclaw)
Temat: Re: Non default declaration search mechanism
 
On Sunday 22 January 2012 02:36:47 Kucharski, Lukasz wrote:
> Hi all,
> 
> I am currently working on a ttcn3 plug-in for kdevelop and I've encountered
> a problem that I don't how to solve in elegant and efficient way.

Hey there!

Cool to see more people working on KDev plugins. Are you doing this openly? If 
not, please do so! Put your code up on git.kde.org, should make it easier for 
you and all others to use it.

> Following C/C++ represents my problem:
> 
> enum AAA
> {
>     one,
>     two
> };
> 
> enum BBB
> {
>     one,
>     two
> };
> 
> const AAA c_val1 = one;
> const BBB c_val2 = one;
> 
> Of course this won't compile however equivalent ttcn3 code is valid.
> 
> Having 'one' enumerator in two different enumeration types requires named
> context to allow use definition to valid enumerator.
> 
> Enumeration types without named context allows to find all 'one'
> declarations but use chain is build always to first declaration, I mean
> declaration from AAA type. Enumeration types with named context
> [setPropagateDeclarations(true)] do not allow to find enumerator
> declarations with default search mechanism. I were able to successfully
> overload findLocalDeclarationsInternal and findDeclarationsInternal methods
> to achieve required functionality however it's very slow.

Personally, I would do it even differently. That is, (maybe) use 
propagateDeclarations, but definitely don't overload the findDeclarations* 
methods - that's pure suicide (as proven by looking at the actual 
implementation / the c++ overload).

Couldn't you maybe achieve the above by manually checking the following 
conditions in your usebuilder and handle them appropriatly?

- if inside assignment expression
- if target-type is of type enum
-> look for declaration in enum-declaration's internalContext

This might work for this case, but I'm not sure about your language's other 
features. Does it allow function-overloading?

foo(AAA) {...}
foo(BBB) {...}

foo(one); <-- which one is called?

> Is there anybody there that knows declaration search mechanism well enough
> to point me a right direction?

Personally I found it much simpler (in most of my C++ work and in all of my 
PHP work) to just use the plain old findDeclaration* functions just within the 
proper context.

Bye

-- 
Milian Wolff
mail at milianw.de
http://milianw.de





More information about the KDevelop-devel mailing list