[Vm-dev] SqueakJS named primitives in the interpreter module

David T. Lewis lewis at mail.msen.com
Thu Jan 19 02:55:10 UTC 2017

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
SqueakJS, but I am a total JavaScript noob so I am looking for an example 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,
so I want to ask - does the basic functionality of looking up and executing e.g.
#primitiveScreenDepth from the <primitive: 'primitiveScreenDepth'> pragma work?

For reference, here are the named primitives in the anonymous module as
referenced from methods in Squeak trunk.

     ( Pragma allSubInstances
         select: [:e | ( e keyword = #primitive: 
                 and: [ e numArgs = 1 ] )
                     and: [ e arguments first isInteger not ] ] )
             collect: [ :e | e arguments first asSymbol ].


More information about the Vm-dev mailing list