Initial hack on the new low-level compiler API.
None of the new code is in use yet. The current Haskell compiler (HscMain.hscMain) isn't as typed and as hack-free as we'd like. Here's a list of the things it does wrong: * In one shot mode, it returns the new interface as _|_, when recompilation isn't required. It's then up to the users of hscMain to keep their hands off the result. * (Maybe ModIface) is passed around when it's known that it's a Just. Hey, we got a type-system, let's use it. * In one shot mode, the backend is returning _|_ for the new interface. This is done to prevent space leaks since we know that the result of a one shot compilation is never used. Again, it's up to the users of hscMain to keep their hands off the result. * It is allowed to compile a hs-boot file to bytecode even though that doesn't make sense (it always returns Nothing::Maybe CompiledByteCode). * Logic and grunt work is completely mixed. The frontend and backend keeps checking what kind of input they're handling. This makes it very hard to get an idea of what the functions actually do. * Extra work is performed when using a null code generator. The new code refactors out the frontends (Haskell, Core), the backends (Haskell, boot) and the code generators (one-shot, make, nothing, interactive) and allows them to be combined in typesafe ways. A one-shot compilation doesn't return new interfaces at all so we don't need the _|_ space-leak hack. In 'make' mode (when not targeting bytecode) the result doesn't contain Nothing::Maybe CompiledByteCode. In interactive mode, the result is always a CompiledByteCode. The code gens are completely separate so compiling to Nothing doesn't perform any extra work. DriverPipeline needs a bit of work before it can use the new API.
Showing with 337 additions and 2 deletions