An useful snip (maybe)

Markus Fritsche Fritsche.Markus at gmx.net
Fri Mar 18 18:33:03 UTC 2005


Lic. Edgar J. De Cleene wrote:
> On [DATE], "[NAME]" <[ADDRESS]> wrote:

Your attribution line is broken ;)

>>referencesAsSet
>>| set |
>>set := Set new.
>>self methodDict do: [ association |
>>association value literals do: [ :literal |
>>(literal isKindOf: LookupKey) ifTrue: [
>>set add: literal ]]].
>>self class methodDict do: [ association |
>>association value literals do: [ :literal |
>>(literal isKindOf: LookupKey) ifTrue: [
>>set add: literal ]]].
>>^ set

> I was ussing some code , but with Class instead LookupKey, cauld I learn the
> difference ?

Hmm... A small trip to CompiledMehods? Okay. Do
(SequenceableCollection class methodDict at: #streamContents:) inspect.
You should see the 'CompiledMethod Inspector' coming up. Open a Browser 
on the Method. When you select 'literal2' in the Inspector, you should 
see #WriteStream - that is the inspector representation of a 
ReadOnlyVariableBinding.
Every pointer (I learned this by examination, not by reading the papers) 
to an object in a CompiledMethod is represent by either a 
ReadOnlyVariableBinding or an Association. They are described at 
http://people.squeakfoundation.org/person/maf/diary.html?start=2

This way, you don't get the 'Smalltalk at: #Class'-lookups, but if 
someone decides to lookup a class this way, then he surely has dealt 
with the fact it could raise an error (or give back nil when used as
'Smalltalk at: #Class ifAbsent: []'.

Did I answer your questions?

Kind regards, Markus

-- 
http://reauktion.de/archer/




More information about the Squeak-dev mailing list