[Pharo-project] [MethodTrailer] #getSourceCodeBySelector: and #getSourceCodeByIdentifier: are not implemented

Marcus Denker marcus.denker at inria.fr
Thu May 12 10:30:57 EDT 2011



I vote for removing any dead code. Less code, less bugs. Less code, easier to understand.

On May 12, 2011, at 3:45 PM, Mariano Martinez Peck wrote:

> If we see CompiledMethodTrailer >> sourceCode
>     "Answer the source code of compiled method.
>     Note: it does not attempts to read from source files using sourcePointer,
>     nor reconstruct the source code using temp names"
>     
>     (kind == #EmbeddedSourceQCompress or: [ kind == #EmbeddedSourceZip ]) ifTrue: [
>         ^ data ].
>     
>     kind == #SourceBySelector ifTrue: [
>         ^ method methodClass getSourceCodeBySelector: method selector ].
>     
>     kind == #SourceByStringIdentifier ifTrue: [
>         ^ method methodClass getSourceCodeByIdentifier: data ].
> 
>     ^ nil
> 
> 
> But neither #getSourceCodeBySelector: nor #getSourceCodeByIdentifier:  are implemented. In fact, it is easy to modify their test and make them red. Change #testSourceBySelectorEncoding or #testSourceByIdentifierEncoding and add a send to #sourceCode. Example:
> 
> testSourceBySelectorEncoding
> 
>     | trailer |
>     
>     trailer := CompiledMethodTrailer new.
>     
>     trailer setSourceBySelector.
>     
>     self assert: (trailer kind == #SourceBySelector ).
>     self assert: (trailer size = 1).
>     trailer sourceCode. 
> 
> 
> 
> So...I don't know why they are not implemented, but if this was work "unfinished", we should at least make that clear and not to appear that it is supported but at the end it is not. So, if that's the case, I suggest to put nice comments explaining that and in addition implement:
> 
> Behavior >> getSourceCodeBySelector: 
> ^ self notYetImplemented
> 
> 
> Behavior >> getSourceCodeByIdentifier: 
> ^ self notYetImplemented
> 
> 
> What do you think ?
> 
> -- 
> Mariano
> http://marianopeck.wordpress.com
> 

--
Marcus Denker  -- http://www.marcusdenker.de
INRIA Lille -- Nord Europe. Team RMoD.





More information about the Pharo-dev mailing list