It appears I was trying to set up a completely independent class hierarchy / object graph with no dependencies on Squeak's classes. In other words, my own Class, Metaclass, Object and so forth, all in a Namespaced environment rather than in the SystemDictionary (known colloquially as the "Smalltalk" global object).
This is trickier than it seems. All of the above need to live "in" a Package object. As an object, it is therefore an instance of the Package class, which has Class, Object and so forth as superclasses. So these (Class, Object, etc) all need to be made first... but then these classes in turn need to be in a Package (called "Kernel"). Thus, we have a chicken-and-egg problem. We need an instance of Package, which is an instance of a class inside itself (and further, compiled by a compiler which is in another instance of Package).
My solution is to file out the core packages using my current tools: Kernel, SourceCode, Compiler, Namespaces, NamespaceTools, etc. Then I do this:
- File in (but do not compile) the Kernel package, using the existing compiler and a custom filing code.
- Make the new Metaclass singularity by hand.
- Compile the Kernel package using whatever compiler is available, using the new Metaclasses.
- File in and compile all other dependencies using the resulting Kernel. These will all be discarded once the second kernel is built.
- File in the Kernel source code again into a separate PackageSource, this time using the new Kernel (above) for the Object, Class etc classes.
- Now, do a whole lot of "special case" handling on the new second Kernel, using and sacrificing bits from the first, to make the new Kernel completely self-contained. This is quite a complex step so I'll spare the details.
1 comment:
Is what you're doing similar enough to https://github.com/yoshikiohshima/SqueakBootstrapper to make that latter useful to you?
Post a Comment