Does #class deserve to be a very-special shortcutbytecodeanymore?

ducasse ducasse at iam.unibe.ch
Sun Jan 6 16:49:22 UTC 2002


on 1/6/02 4:18 PM, Stephen Pair at spair at advantive.com wrote:

> 
>> You mean 
>> 
>> Mirror>>on: anObject
>> 
>> reflected := anObject
>> 
>> Mirror>>instVarAt: anInteger
>> 
>> ^ reflected instVarAt: anInteger
>> 
>> 
>> With this solution I do not have to compile them into a
>> method but the behavior is still on Object. This can be only
>> good to play with the idea.
>> 
>> I do not really see how the primitive can work with the following
>> 
>> Mirror>>instVarAt: index of: anObject
>> 
>> <primitive: 73>
>> "Access beyond fixed variables."
>> ^ anObject basicAt: index - anObject class instSize
>> 
>> But the code of the primitive is referring to the receiver so
>> how this can work?
> 
> Actually, it should be:
> 
> Mirror>>instVarOf: anObject at: index
> 
> <primitive: 73>
> "Access beyond fixed variables."
> ^ anObject basicAt: index - anObject class instSize
> 
> The receiver needs to be the first parameter.  It's a dirty little hack
> that works only because the primitive doesn't care that an extra thing
> has been pushed onto the stack...note that the extra thing (the
> receiver) will stay on the stack.  All the primitive cares about are the
> top two things on the stack.  A similar pattern can be used for the
> other primitives.
> 
> - Stephen
> 
> 
> 
> 
Thanks I see why I could not figure out why ;)





More information about the Squeak-dev mailing list