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 |
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 |
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: ' |
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 >> >> > > |
Free forum by Nabble | Edit this page |