[Vm-dev] SqueakJS named primitives in the interpreter module
David T. Lewis
lewis at mail.msen.com
Thu Jan 19 14:08:29 UTC 2017
Thank you Bert,
On Thu, Jan 19, 2017 at 02:19:25PM +0100, Bert Freudenberg wrote:
> On Thu, Jan 19, 2017 at 3:55 AM, David T. Lewis <lewis at mail.msen.com> wrote:
> > For named primitives, we can load and run a primitive function from a
> > specific
> > module, as in the case of <primitive: 'primitiveFileSize' module:
> > 'FilePlugin'>.
> > We can also load a primitive with module name unspecified, as in the case
> > of
> > <primitive: 'primitiveScreenDepth'>. In that case we load and run the
> > function
> > from the main interpreter module.
> > I want to implement the anonymous named primitive #primitiveUtcWithOffset
> > in
> > of
> > some other anonymous named primitive to use as a pattern.
> > At first glance, I do not see any anonymous named primitives implemented
> > in vm.js,
> Indeed, SqueakJS does not implement any of the currently used module-less
> named primitives.
> It does, however, implement some obsolete ones, e.g. '
> m23PrimitiveTransformPoint' which was later moved to Matrix2x3Plugin.
> The lookup is quite trivial: If you specify an empty module name, it just
> looks up the method in the VM's primitive handler class itself, instead of
> a named module. E.g. in SqueakJS you could call the beep primitive either
> by index or by name, <primitive: 140> works as well as <primitive:
Ah, I see. That's exactly what I needed to know.
> > so I want to ask - does the basic functionality of looking up and
> > executing e.g.
> > #primitiveScreenDepth from the <primitive: 'primitiveScreenDepth'> pragma
> > work?
> in the 'Squeak.Primitives' class. I'd suggest putting it in the 'time'
> section https://github.com/bertfreudenberg/SqueakJS/blob/
> Note that quite a few indexed primitives do not exist as a full method.
> E.g. prim 135 is currently implemented as
> case 135: return this.popNandPushIfOK(1, this.millisecondClockValue());
> basically to reduce tedious boiler-plate code. Just in case you're
> wondering why some of the primitives appear to be missing ;)
Indeed, I can see that you have simplified many of these primitives quite a bit.
> - Bert -
> PS: makeStArray: might prove useful
You have correctly anticipated my next newbie question ;-)
More information about the Vm-dev