[squeak-dev] Re: [Pharo-project] Why you need new Method trailers? :)

Adrian Lienhard adi at netstyle.ch
Mon Dec 21 12:20:13 UTC 2009


Hi Igor,

This looks complicated... Note, in Pharo this does not work because  
there is no sharing of compiled methods from traits anymore.

I attached a changeset that does the same as yours but for Pharo.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: PrintTraitsMethodOrigin.1.cs
Type: application/octet-stream
Size: 2282 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20091221/3a3b2171/PrintTraitsMethodOrigin.1.obj
-------------- next part --------------



The only thing that is needed are a few lines in sourceCodeAt:. The  
method #traitOrClassOfSelector: returns the origin of a method -- this  
should work just fine for aliased methods too.

HTH,
Adrian

On Dec 21, 2009, at 01:09 , Igor Stasenko wrote:

> I just created a small changeset
>
> http://bugs.squeak.org/view.php?id=7432
>
> which gives me a long awaited feature:
> to see in a browser, where the heck a given method comes from.
>
> If method comes from trait, a method's source tells me , from which  
> one exactly!
>
> Open a browser on Behavior clas and select an #addExclusionOf:to:  
> method.
> Usually you'll see:
>
> addExclusionOf: aSymbol to: aTrait
> 	self setTraitComposition: (
> 		self traitComposition copyWithExclusionOf: aSymbol to: aTrait)
>
> But with my changes you'll see:
>
> " From: TAccessingTraitCompositionBehavior "
> addExclusionOf: aSymbol to: aTrait
> 	self setTraitComposition: (
> 		self traitComposition copyWithExclusionOf: aSymbol to: aTrait)
>
> in code pane.
>
> Same applies to traits themselves for instance, browse
> TPureBehavior>>isAliasSelector:
>
> " From: TAccessingTraitCompositionBehavior "
> isAliasSelector: aSymbol
> 	"Return true if the selector aSymbol is an alias defined
> 	in my or in another composition somewhere deeper in
> 	the tree of traits compositions."
>
> 	^(self includesLocalSelector: aSymbol) not
> 		and: [self hasTraitComposition]
> 		and: [self traitComposition isAliasSelector: aSymbol]
>
>
> There is one problem , which requires better expertise than mine and i
> need a help from Traits experts: an aliased methods.
> I tried to find out, how to dig out the aliased method from
> composition, and get its source to display in code pane .. but no
> luck.
> Please give me an advice, how a  #getSourceCodeBySelector:
> method should be implemented for proper handling of aliases.
> Currently, all aliased methods sources shown using decompiler:
>
> Behavior>>methodDictAddSelectorSilently: t1 withMethod: t2
> 	self basicAddSelector: t1 withMethod: t2
>
> Aliased methods, obviously, will require an additional info in source
> header, like:
>
> " From: SomeTrait , originalSelector:  #blablba "
>
> -- 
> Best regards,
> Igor Stasenko AKA sig.
>
> _______________________________________________
> Pharo-project mailing list
> Pharo-project at lists.gforge.inria.fr
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project



More information about the Squeak-dev mailing list