Distinguishing between "instance of class" and "class" types in the duchain

Milian Wolff mail at milianw.de
Tue Apr 10 14:11:40 UTC 2012


On Monday 09 April 2012 23:37:03 Sven Brauch wrote:
> Hi there,
> 
> consider this code:
>   class my_class(): pass

ClassDeclaration -> StructureType

>   copy_of_my_class = my_class

AliasDeclaration -> StructureType

>   instance_of_my_class = my_class()

Declaration -> StructureType

> How could you find out which of instance_of_my_class or
> copy_of_my_class are the class itself or instances of the class now? I
> mean, both have the "raw" structuretype assigned, no?

See above? The type is not saying anything about the declaration kind.

> Am 9. April 2012 23:02 schrieb Milian Wolff <mail at milianw.de>:
> > On Monday 09 April 2012 22:32:02 Sven Brauch wrote:
> >> Hello there,
> >> 
> >> there's something I'm unsure about how to correctly represent it in
> >> the duchain: the difference between "class" and "instance of a class".
> >> My current solution is that a class declaration creates a structure
> >> type, and if I want to reference the class itself (not an instance of
> >> the class) I create an alias declaration which aliases the class
> >> declaration. That is not really optimal for several reasons tough:
> >> there's always the need to search for declarations if you work with
> >> types, e.g. if handling an assignment, you cannot simply assign B the
> >> type of A, but you have to check if A is a class or an instance of a
> >> class, then create an alias declaration or something else depending on
> >> that... etc; additionaly, it's not possible to store class types in
> >> unsure types that way (a declaration cannot have an unsure type which
> >> could either be a class or None, or similar).
> >> 
> >> Is there a good way to do this?
> >> Is there a good *idea* which I could implement in the duchain to solve
> >> this problem? It's really messy right now.
> > 
> > In PHP and C++ we just assign the "raw" structuretype to instances. To
> > figure out if you actually have a declaration, you can either cast to
> > ClassDeclaration or compare the declaration of the structuretype. Why does
> > that not work for you?
> > 
> > bye
> > 
> > --
> > Milian Wolff
> > mail at milianw.de
> > http://milianw.de
> > --
> > KDevelop-devel mailing list
> > KDevelop-devel at kdevelop.org
> > https://barney.cs.uni-potsdam.de/mailman/listinfo/kdevelop-devel
-- 
Milian Wolff
mail at milianw.de
http://milianw.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20120410/b0c39d12/attachment-0001.sig>


More information about the KDevelop-devel mailing list