Hi, I'm trying to use RoelTyper in Pharo. A question I ask myself is: 'Is it normal that roelTyper doesn't always return some assignements' ?
For example, when I evaluate: TypeCollector typeInstvar: #array ofClass: OrderedCollection . the assignements returned is an empty collection. I would expect that even roelTyper doesn't retrieve the exact type, it would always return a collection of 'candidate' types.
Am I using it in a wrong way? _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
Hello Cyrille,
First of all, thanks for trying to use RoelTyper! It is always interesting to have feedback ! There are two things. Firstly, you found a bug in RoelTyper :) RoelTyper should find some assignments for #array in OrderedCollection (in OrderedCollection>>grow for example). I must fix that. Secondly, RoelTyper found the right type for #array: Array! When you execute: TypeCollector typeInstvar: #array ofClass: OrderedCollection. it returns an ExtractedType (containing Assignments (normally :)) and Messages sends). To merge information and find the possible types for this extractedType you must send the message #types on it. (TypeCollector typeInstvar: #array ofClass: OrderedCollection) types. giving: Array Fréd ---- Frédéric Pluquet Université Libre de Bruxelles (ULB) Assistant http://www.ulb.ac.be/di/fpluquet 2009/12/10 Cyrille Delaunay <[hidden email]>
_______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
Oups... I answered too quickly ! It is not a bug :) !
As explain in this article, we link the variables (temporary variables, instance variables and returned values of methods) during the extraction of types. The links permit to associate some varaibles between them. For example in OrderedCollection>>grow "Become larger. Typically, a subclass has to override this if the subclass adds instance variables." | newArray | newArray := Array new: self size + self growSize. newArray replaceFrom: 1 to: array size with: array startingAt: 1. array := newArray RoelTyper links the temporary variable #newArray to the instance variable #array (because #newArray is assigned to #array). When you ask the extractedType by: TypeCollector typeInstvar: #array ofClass: OrderedCollection. the extractedType for #array contains the types assignements found for #array. And in the code, there are no one (no direct assignment of an object created by a message defined in the "instance creation" protocol of the class on which the message is sent (see the table of heuristics at the beginning of the page 4th of the paper)). But other linked extractedTypes has types assignements (as #newArray in OrderedCollection>>grow). So to retrieve this information in the extractedType of #array you must flatten the links (read the section 7 of the paper if you want more information), so: (TypeCollector typeInstvar: #array ofClass: OrderedCollection) flattenLinks. We don't flatten the links automatically because once flattened, the links are deleted from linked extractedTypes. We think it is important to keep this information available by default. The links are automatically flattened when you ask to calculate the possible types: (TypeCollector typeInstvar: #array ofClass: OrderedCollection) types. Fréd ---- Frédéric Pluquet Université Libre de Bruxelles (ULB) Assistant http://www.ulb.ac.be/di/fpluquet 2009/12/10 fpluquet <[hidden email]> Hello Cyrille, _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
Ok, thank you very much :)
2009/12/10 Frederic Pluquet <[hidden email]> Oups... I answered too quickly ! It is not a bug :) ! _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
Free forum by Nabble | Edit this page |