Making a .st file from the source of a method

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Making a .st file from the source of a method

Sean P. DeNigris
I have a class that I use to set up my images. A subclass has a method:

        (Smalltalk at: #UpdateStreamer) new updateFromServer.
        "Do other stuff..."

I want to save the statements of the method above in a .st file to pass as an argument to the vm. That's all working, but in order to retrieve the two statements above, I do:

        | scriptMethod sourceString sourceStringWithBracketsStripped |
        scriptMethod := PharoTrunkImage compiledMethodAt: #setupScript.
        sourceString := scriptMethod methodNode body asString.
        sourceStringWithBracketsStripped := sourceString copyFrom: 3 to: sourceString size - 2.
        ^ sourceStringWithBracketsStripped.

That works, but I don't like it. What's the best way to do this (or is this it)?