[TECH] Pb with primtive definition
tim at sumeru.stanford.edu
Thu Jan 10 18:56:27 UTC 2002
Bergel Alexandre <bergel at iam.unibe.ch> is widely believed to have written:
> I have tried to set up a primtive as it was explain in Andrew C. Greenberg article ("Extending the Squeak Virtual Machine").
> So I define a method foo in a class TestPlugin derived from InterpreterPlugin.
> TestPlugin >> foo
> self export: true.
> pop: 1
> thenPush: (interpreterProxy booleanValueOf: true).
The problem here is a simple wrong-message; booleanValueOf: extracts a
_C_ value from a Smallalk Boolean. So, your code is putting on the stack
a 32bit word that has the bits of C's 'true' - #defined in sq.h as 1.
This is not an acceptable OOP to Squeak and so when you (for example)
have any garbage collection it will go boom.
If you try
self export: true.
you should be okay.
If you made your plugin a subclass of TestInterpreterPlugin you would be
able to use the extended capabilities and do something like
self primitive: 'foo'.
Tim Rowledge, tim at sumeru.stanford.edu, http://sumeru.stanford.edu/tim
Life would be much easier if I had the source code.
More information about the Squeak-dev