The Do-It Yourself Guide to Squeak Primitives


11. Add Your C File to the VM Make/Project File

So, we're almost done. Depending on your platform, you'll have to add your new C file to the VM makefile or import it into the VM build project with the appropriate C development tool (e.g., CodeWarrior). Depending on the complexity of your C code, you might also have to add additional libraries to the linker command (or import them to the interactive development tool's library list).

12. Recompile the VM

Now either say "make" or use the appropriate compiler/linker tool to rebuild the VM. Make sure it recompiles the (new) interp.c file as well as your primitive C code, and that you link with any additional libraries required by your C code.

13. Test It

If all of the above steps worked, you should now have a new virtual machine that includes your C primitive! You can start it with a virtual image that contains the Smalltalk side of your primitive and test it out. If this is your first foray into adding primitives, I strongly suggest that you start with a really trivial primitive (e.g., one that squares its argument or some such nonsense) to run through the process from start to finish. If you're so experienced that you don't need to, then why are you reading this note? (If you're an experienced Smalltalk programmer with lots of free time, please contact me immediately!)