[virtmach] Your VM

Anton Ertl anton@mips.complang.tuwien.ac.at
Wed, 30 May 2001 17:45:37 +0200 (MET DST)


Francois-Rene Rideau wrote:
> 
> On Tue, May 29, 2001 at 10:37:38AM +0100, Thaddaeus Frogley wrote:
> >> large switch case statement, 
> > An unmaintainable nightmare.
> Only if you program it manually.
> If you metaprogram a wee bit, you can get it
> to be generated automatically from modular declarations.
> Actually, from the same modular declarations,
> you can generate several versions with different threading techniques,
> and automatically select which is best for which architecture/compiler combo.
> 
> One way you can do that is with m4 macros (thisforth does it -- butt ugly);
> another way is with a LISP or Perl or Python or whatever script.

Or, instead of rolling your own with a general-purpose tool, you can
use a tool designed for the purpose:
http://www.complang.tuwien.ac.at/anton/vmgen/

Currently vmgen supports only threaded code using gcc's
labels-as-values, but the next release will support switch-based
interpreters as well (maybe even function-pointer-based interpreters).

- anton