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

rabbit rabbit at callistohouse.org
Sat Jan 14 15:24:10 UTC 2023




Just sharing my new method for coping methods to my new class, implimentations of redirectMessage: sending.

    ELib class>>#copyMethodsToClass: refClass fromClass: sourceClass upToClass: terminalClass

	"Collect classes to contribute message protocol."
	 | classes |
	classes := sourceClass allSubclasses select: [ :clazz | (terminalClass ~~ clazz) and: [ (terminalClass inheritsFrom: clazz) not]  ].

	"contribute message protocols."
	classes do: [:thisClazz | 
		thisClazz methodDictionary keysAndValuesDo: [:selector :method | | compiledMethod | 
			compiledMethod := Compiler 
				compile: ((thisClazz methodHeaderFor: selector), '
					  ^self redirectMessage: (Message 
							selector: ', selector asSymbol printString, '
							arguments: ', '{', 
								(((method tempNames first: method numArgs) printElementsOn: '' writeStream) contents),
								'}).')
				environment: refClass 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 ::


------- Original Message -------
On Thursday, January 12th, 2023 at 2:14 PM, Tobias Pape <Das.Linux at gmx.de> wrote:


> > On 11. Jan 2023, at 19:18, rabbit rabbit at callistohouse.org wrote:
> > 
> > Hi y’all,
> > 
> > Is there a way I could acquire the list of argument names of a CompiledMethod?
> 
> 
> If you have the class, use #methodHeaderFor:
> 
> Collection methodHeaderFor: #detect:ifNone: => 'detect: aBlock ifNone: exceptionBlock'
> 
> 
> 
> Best regards
> -Tobias


More information about the Squeak-dev mailing list