[squeak-dev] Accessing argument literals through Compiled Methods.

rabbit rabbit at callistohouse.org
Thu Jan 12 18:37:16 UTC 2023


Better is:

methodSignature := ‘detect:ifNone:’ messageSignatureFromArguments: #(‘detectBlock’ ‘noneBlock’).

—
Have a good one; keep it, light.
Kindly, rabbit . .. … ‘…^,^ 🐇🐇🐇

Sent from Callisto House mobile - Ganymede
:: decentralized mobile homeless solutions ::

On Thu, Jan 12, 2023 at 13:34, rabbit <rabbit at callistohouse.org> wrote:

> Jeez, I’m totally confused, this morning.
>
> Ahh, yes. Here we are. Thanks, Elliot. I’m still unable to see methods added to the methodDict, even with the call to #addSelector: selector withMethod: compiledMethod method notifying: [nil].
>
> A comment in String>>#keywords sez ::
>
> "Has a final keyword, as in #nextPut::andCR"
>
> What is this? Is there some sort of trailing keyword allowed???
>
> •••
>
> Here’s an extension method I’m now using, called with:
>
> methodSignature := ‘detect:ifNone:’ messageSignatureFromArguments: { [:each | each isIt ]. [nil] }.
>
> String>>#messageSignatureFromArguments: arguments
> "Answer an array of the keywords, insterspersed with the argument names, that compose the receiver."
> | selectorStream |
> selectorStream := '' writeStream.
> (self numArgs = 0)
> ifTrue: [selectorStream nextPutAll: self]
> ifFalse: [self keywords with: arguments
> do: [:keyword :argument | selectorStream nextPutAll: keyword, ' ', argument, ' ']].
> ^ selectorStream contents
> The allows my method copy block to be:
>
> classes do: [:thisClazz |
> thisClazz methodDictionary keysAndValuesDo: [:selector :method | | arguments compiledMethod |
> arguments := method tempNames first: method numArgs.
> compiledMethod := Compiler
> compile: ((selector messageSignatureFromArguments: arguments),
> ' ^self redirectMessage: (Message selector: ', selector asSymbol printString,
> ' arguments: ', '{', ((arguments printElementsOn: '' writeStream) contents), '}).')
> environment: value class environment notifying: nil trailer: method trailer ifFail: [nil].
> refClass addSelector: selector withMethod: compiledMethod method notifying: nil]].
>
>> Have a good one; keep it, light.
> Kindly, rabbit . .. … ‘…^,^ 🐇🐇🐇
>
> Sent from Callisto House mobile - Ganymede
> :: decentralized mobile homeless solutions ::
>
> On Thu, Jan 12, 2023 at 11:23, Eliot Miranda <eliot.miranda at gmail.com> wrote:
>
>> Use selector keywords to get the keywords. This works for unary and binary selectors.
>>
>> _,,,^..^,,,_ (phone)
>>
>>> On Jan 11, 2023, at 12:21 PM, rabbit <rabbit at callistohouse.org> wrote:
>>
>>>  Yes to get the keywords and numArgs I.
>>>
>>> keywords := selector subStrings: $:.
>>>
>>>>>> Have a good one; keep it, light.
>>> Kindly, rabbit . .. … ‘…^,^ 🐇🐇🐇
>>>
>>> Sent from Callisto House mobile - Ganymede
>>> :: decentralized mobile homeless solutions ::
>>>
>>> On Wed, Jan 11, 2023 at 13:42, Ron Teitelbaum <ron at usmedrec.com> wrote:
>>>
>>>> Hi Rob,
>>>>
>>>> Do you mean
>>>>
>>>> aCompiledMethod selector?
>>>>
>>>> All the best,
>>>>
>>>> Ron Teitelbaum
>>>>
>>>> On Wed, Jan 11, 2023 at 1:18 PM rabbit <rabbit at callistohouse.org> wrote:
>>>>
>>>>> Hi y’all,
>>>>>
>>>>> Is there a way I could acquire the list of argument names of a CompiledMethod?
>>>>>
>>>>>>>>>> Have a good one; keep it, light.
>>>>> Kindly, rabbit . .. … ‘…^,^ 🐇🐇🐇
>>>>>
>>>>> Sent from Callisto House mobile - Ganymede
>>>>> :: decentralized mobile homeless solutions ::
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20230112/7ddbdb8c/attachment-0001.html>


More information about the Squeak-dev mailing list