[squeak-dev] Request for feedback: mirrors

Igor Stasenko siguctua at gmail.com
Thu May 24 00:13:43 UTC 2012


ok, i checked your implementation and now i see where you doing lookup

receiver: anObject perform: aSelector arguments: anArray
	| cm |
	cm := self compiledMethodAt: aSelector ifAbsent:
		[^ anObject doesNotUnderstand: (Message selector: aSelector
arguments: anArray)].
	^ self receiver: anObject withArguments: anArray executeMethod: cm

But you can avoid it, consider a following:

ObjectVmMirror>>fixedAt: anInteger
	^ Reflection
		receiver: object
		perform: #fixedAt:
		arguments: {anInteger}

you can rewrite it as:

ObjectVmMirror>>fixedAt: anInteger
	^ self execute: GetFixedSlotMethod
		arguments: {anInteger}

where GetFixedSlotMethod is a class variable holding an appropriate
CompiledMethod instance,
which you can initialize just once at class initialization (and
reinitialize if it changes).

and #execute:arguments: is method which using prim 188 for executing
given method
with object as receiver.

-- 
Best regards,
Igor Stasenko.


More information about the Squeak-dev mailing list