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

Mariano Martinez Peck marianopeck at gmail.com
Wed May 11 12:25:10 CEST 2011

If we see CompiledMethodTrailer >> sourceCode
    "Answer the source code of compiled method.
    Note: it does not attempts to read from source files using
    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:


    | 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 ?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gforge.inria.fr/pipermail/pharo-project/attachments/20110511/b2ae37c5/attachment.htm>

More information about the Pharo-project mailing list