[Vm-dev] Interpreter>>isContextHeader: optimization

Igor Stasenko siguctua at gmail.com
Mon Feb 23 04:08:19 UTC 2009

2009/2/23 Igor Stasenko <siguctua at gmail.com>:
> 2009/2/22 Eliot Miranda <eliot.miranda at gmail.com>:


another idea how to make a cleaner slang code , was to introduce a
special 'C' shared variable.
So, then instead of writing something like:

self ioRelinquishProcessorForMicroseconds: xxx.

or even worse:

self cCode:' ((sqInt (*) (sqInt, sqInt*, sqInt*, sqInt*, sqInt*))querySurfaceFn)
		(handle, &sourceWidth, &sourceHeight, &sourceDepth, &sourceMSB)'

you merely write:

C ioRelinquishProcessorForMicroseconds: xxx.
C querySurfaceFn: handle with: sourceWidth cReference with:
sourceHeight cReference ....

First , it lets a code generator know, that given message send is raw
C function call (by taking a first keyword as a function name).
Second, it can be simulated appropriately by a simulator, since you
can assign an object to 'C' pool var which having best-match
implementations for all such calls. And of course it helps greatly in
finding errors or mistypes!

Then patterns like 'self foo' be exclusively treated by code generator
as method which belongs to an instance of class where  method which
containing such code residing, without any exceptions.

So, if you write
'self signalSemaphore: xx' in Interpreter's method
a code generator should lookup for #signalSemaphore: in Interpreter class.
And if you write 'self header'   in Oop class -- it will lookup
#header method in Oop class, but nowhere else!

Best regards,
Igor Stasenko AKA sig.

More information about the Vm-dev mailing list