Nasty VM stuff
jim benson
jb at speed.net
Mon Apr 13 23:43:44 UTC 1998
I have looked thru most of the VM code. I would like to write some
useful primitives. But, I have run into a couple of roadblocks which I
am sure there are some simple and elegant answers to.
Within a primitive:
How do I look up a name in the global space "SystemDictionary"?
How do I hash a symbol?
How do I send it a message (including parameters)?
Will Mr. garbage collector collect my arguments if I pop them off the
stack during execution of a primitive?
For example, let us say that I would like to create a new rectangle
within my primitive. I believe that I have to lookup the class based on
the hashed symbol 'Rect'. In Squeak:
bo := Rectangle new.
bo square: 20.
First I need to get the class 'Rectangle'.
Smalltalk at: #Rect.
Are there some clever incantations, spells or maybe even code I go throw
to get this info?
And once I have this class, or an arbitrary object, how do I pass a
message to it? I assume that I need to hash the name of the message (
something along the lines of HashAsSymbol('new')). What is the Squeak
approved way of doing this?
Finally, how do I send this symbol as a message to one of my new found
friends?
Humbled by this experience,
Jim
More information about the Squeak-dev
mailing list
|