Implementation

The virtual machine was implemented in 3900 lines of C++, with about 500 additional lines of tests in BMD assembly code. C++ was the language known best by Dane and I collectively, and the game engine and the virtual machine needed to be fairly well-integrated. Although using C++ had many quirks, one surprising non-issue was that of memory management. By extensive use of the boost::shared_ptr<T> wrapper and STL container classes, memory issues never became a major problem in the code.

One peculiar aspect of my code is the extensive use of macros. Normally I frown on C macros, but C++ lacks the full blown code-generation capabilities that, say Lisp has, and they were required to avoid code duplication that would probably double the size of the code as it currently stands. In any case, I tried to limit my use of the macros

If you want to start viewing the code, the best places start are value.cpp/hpp, instr.cpp/hpp, and vm.cpp/hpp.



Subsections

Mason Smith 2008-06-11