Pavel Krivanek http://www.comtalk.eu/Squeak/98
On Sun, Jun 29, 2008 at 4:09 AM, Yoshiki Ohshima yoshiki@vpri.org wrote:
Write a compiler in another language. That can generates the bits that are same as CompiledMethods. For a class definition, it creates (yes) the network of pointers.
The compiler sticks the class definitions, method dictionaries, subclass structure, and compiled methods into a big "int*" array. The goal is to make that something just run, so for example, the stuff managed by ClassDescription (instanceVariable names and organization) don't have to be compiled. Stuff like the source pointer is not needed at this stage.
The compiler doesn't have to be in another language. What is important is that the compiler builds a Squeak image from a text file. The compiler can be written in Smalltalk as long as it uses only the class definitions in the test file, not in the compiler's image.
In face, it would be possible to reuse the existing compiler to build up a standard structure of classes in the image, but to put them all in their own namespace. Thus, an Object class defined in the test file would not be the same as the Object class used in the compiler. Thus, a system that bootstraps images from text files could first read the text file and produce a set of classes in the image, and then write out an image that contains only those classes.
Pavel Krivanek's KernelImage does the second part, but not the first. It creates a parallel class hierarchy by copying part of the existing classes, then it writes out an image that contains only those classes.
So, I think you could make a bootstrapping compiler by hacking the existing compiler to read in a regular .st file into a separate namespace. Then you'd use KernelImage to write out the image. The system would have to make sure that instances of String, CompilerMethod, etc., pointed to the new classes and not the old, but KernelImage has to do something like this already.
Given KernelImage, I don't think that the compiler is all that hard to write. The hard part would be making the text file of all the classes. If I were doing this, I'd hack KernelImage to create the text file for me, so I could at least create something similar to KernelImage.
-Ralph Johnson