Building GeomLab

GeomLab consists of two layers: a Java layer that implements FunCode, a virtual machine for functional programming, and a second layer, including most of the compiler for the GeomLab language, that runs on the FunCode machine. The Java layer is divided into several Java packages:

The GeomLab compiler is written (all apart from the scanner) in its own input language, so the build process for GeomLab requires a bootstrap copy of the FunCode translation of the compiler. The complete build process goes as follows:

  1. Compile the Java source, using a command such as
    javac funbase/*.java funjit/*.java geomlab/*.java plugins/*.java
  2. Use the bootstrap code to compile the compiler:
    java geomlab.RunScript -b boot.txt compiler.txt >stage1.boot
  3. Use the compiler to compile itself:
    java geomlab.RunScript -b stage1.boot compiler.txt >stage2.boot
  4. Use the compiler to compile itself again:
    java geomlab.RunScript -b stage2.boot compiler.txt >stage3.boot
    The files stage2.boot and stage3.boot should be identical.
  5. Make a session image containing the compiler and the prelude:
    java geomlab.RunScript -b stage2.boot prelude.txt -e '_dump("geomlab.gls")'

Now it should be possible to run the GeomLab application with java geomlab.GeomLab. By default, this initially loads the session image geomlab.gls prepared above. Strictly speaking, it is not necessary to go through stages (2), (3) and (4) of the build process shown here: the bootstrap file boot.txt can be used directly in place of stage2.boot in stage (5). However, if there have been changes to the compiler, the whole process is necessary in order to get the system into a stable state.

There are two object code formats used in the process above: the file boot.txt is in a special, textual format that is capable of storing only a limited number of kinds of value, but the final image geomlab.gls is in a binary format that uses Java serialization and can store all kinds of value. The textual format is used to get round problems with serialization when the underlying Java classes are subject to change.