It appears IMCC's way of emitting instructions as it collects compilation was a mistake (mine) and isn't going to work for metadata that needs to be initialized first.
Basically all metadata has to be collected before any code can be emitted. I was thinking of generating an _init routine that creates the classes, so we have several possibilities.
Short term: Require all class definitions and other metadata to be
declared first in the PIR stream. Upon first non-metadata object (sub, pccsub)
we flush the _init sub.
Long term: We should parse the whole PIR file before doing any sort of code emission. This means collecting all the compilation units, running the allocator and optimizer on each and then emit all metadata first before emitting the rest of the units. This allows metadata to be throughout the PIR stream.
This isn't really so big a deal since high level languages should be able to emit PIR code with all metadata first anyway.
Comments?
-Melvin