primitive senders

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

primitive senders

Andrea Gammachi
Hi all.
Is there a way to find all the primitive senders i.e.: methods that contains <primitive: ***> or by specific primitive number: <primitive: 327> ?
cheers

Andrea

Reply | Threaded
Open this post in threaded view
|

Re: primitive senders

Boris Popov-4
Andrea Gammachi wrote:
> Hi all.
> Is there a way to find all the primitive senders i.e.: methods that
> contains <primitive: ***> or by specific primitive number: <primitive:
> 327> ?
> cheers

I didn't really bother turning this into VisualLauncher extension, but
that would be a good idea if you want to push it a bit,

| prim except matches |
prim := #(513).
except := #(nil 395).
matches := OrderedCollection new.
SystemUtils allBehaviorsDo: [:class |
         class enumerateMethods: [:cls :sel :meth |
                | num |
                num := meth primitiveNumber.
                ((prim isEmpty or: [prim includes: num]) and: [(except includes: num)
not])
                        ifTrue: [matches add: (MethodDefinition class: class selector: sel)]]].
^MethodCollector new
                openListBrowserOn: matches
                label: 'Primitive Methods'

So if you want to find methods with <primitive: ***>, leave prim list empty,

prim := #().

or if you want to find methods with specific primitive numbers, just
list them there,

prim := #(327).

Which, by the way, will find #primAbortIncrementalMark.

You'll notice 395 in the except list, which is all external interface
<C:> calls, but like I said, feel free to tweak this to your liking.

Hope this helps,

-Boris

Reply | Threaded
Open this post in threaded view
|

Re: primitive senders

Vassili Bykov
Method collector can select methods for you, so there's no need to
iterate them by hand:

| collector query |
collector := MethodCollector new.
query := collector methodsSelect:
        [:method | method primitiveNumber = 513].
collector
        openListBrowserOn: query select
        label: 'Primitive methods found'

Change the condition to

        [:method | method primitiveNumber notNil].

to find all primitive methods.


Boris Popov wrote:

> Andrea Gammachi wrote:
>> Hi all.
>> Is there a way to find all the primitive senders i.e.: methods that
>> contains <primitive: ***> or by specific primitive number: <primitive:
>> 327> ?
>> cheers
>
> I didn't really bother turning this into VisualLauncher extension, but
> that would be a good idea if you want to push it a bit,
>
> | prim except matches |
> prim := #(513).
> except := #(nil 395).
> matches := OrderedCollection new.
> SystemUtils allBehaviorsDo: [:class |
>      class enumerateMethods: [:cls :sel :meth |
>         | num |
>         num := meth primitiveNumber.
>         ((prim isEmpty or: [prim includes: num]) and: [(except includes:
> num) not])
>             ifTrue: [matches add: (MethodDefinition class: class
> selector: sel)]]].
> ^MethodCollector new
>         openListBrowserOn: matches
>         label: 'Primitive Methods'
>
> So if you want to find methods with <primitive: ***>, leave prim list
> empty,
>
> prim := #().
>
> or if you want to find methods with specific primitive numbers, just
> list them there,
>
> prim := #(327).
>
> Which, by the way, will find #primAbortIncrementalMark.
>
> You'll notice 395 in the except list, which is all external interface
> <C:> calls, but like I said, feel free to tweak this to your liking.
>
> Hope this helps,
>
> -Boris
>
>


--
Vassili Bykov <[hidden email]>

[:s | s, s printString] value: '[s: | s, s printString] value: '

Reply | Threaded
Open this post in threaded view
|

Re: primitive senders

Boris Popov-4
Vassili Bykov wrote:

> Method collector can select methods for you, so there's no need to
> iterate them by hand:
>
> | collector query |
> collector := MethodCollector new.
> query := collector methodsSelect:
>     [:method | method primitiveNumber = 513].
> collector
>     openListBrowserOn: query select
>     label: 'Primitive methods found'
>
> Change the condition to
>
>     [:method | method primitiveNumber notNil].
>
> to find all primitive methods.

Cool, now is it going to become a menu item in 7.5? ;)

Cheers!

-Boris
http://bpopov.wordpress.com

>
>
> Boris Popov wrote:
>> Andrea Gammachi wrote:
>>> Hi all.
>>> Is there a way to find all the primitive senders i.e.: methods that
>>> contains <primitive: ***> or by specific primitive number:
>>> <primitive: 327> ?
>>> cheers
>>
>> I didn't really bother turning this into VisualLauncher extension, but
>> that would be a good idea if you want to push it a bit,
>>
>> | prim except matches |
>> prim := #(513).
>> except := #(nil 395).
>> matches := OrderedCollection new.
>> SystemUtils allBehaviorsDo: [:class |
>>      class enumerateMethods: [:cls :sel :meth |
>>         | num |
>>         num := meth primitiveNumber.
>>         ((prim isEmpty or: [prim includes: num]) and: [(except
>> includes: num) not])
>>             ifTrue: [matches add: (MethodDefinition class: class
>> selector: sel)]]].
>> ^MethodCollector new
>>         openListBrowserOn: matches
>>         label: 'Primitive Methods'
>>
>> So if you want to find methods with <primitive: ***>, leave prim list
>> empty,
>>
>> prim := #().
>>
>> or if you want to find methods with specific primitive numbers, just
>> list them there,
>>
>> prim := #(327).
>>
>> Which, by the way, will find #primAbortIncrementalMark.
>>
>> You'll notice 395 in the except list, which is all external interface
>> <C:> calls, but like I said, feel free to tweak this to your liking.
>>
>> Hope this helps,
>>
>> -Boris
>>
>>
>
>