Package org.ek9lang.compiler.phase7
All the symbols and plugins should now have been resolved. This means that it is now worthwhile creating the Intermediate Representation so that the code can be fully analysed/optimised and prepared for code generation.
The key aspect of generating the IR, it to start to move away from EK9 semantics and structures and, move very firmly and clearly to sets of instructions that are much closer to what we will need in final code generation. However, the IR we generate here is more of an MIR (medium level).
I decided to do this so that there is more opportunity to use optimisation both in the EK9 MIR phase 12, but also to enable back-ends to have more of an overall 'context' to apply further optimisations.
You will notice the there is some use of abbreviations in the class naming, this is because words like Statement (Stmt), Definition (Dfn), Instruction (Instr) and Declaration (Decl) are quite long and in combination would become excessive. Plus these abbreviations used are fairly standard.
IRGenerator
is the main entry point for this phase.
This does not use the ANTLR visitor or listener patterns. Instead, the 'generators' follow the 'flow' of the AST in a very specific way. This is to be able to generate the appropriate IR for that code.
This phase and the generation of the IR is quite 'fiddly' and by its nature a single simple expression or
statement in ek9, will actually result in quite a bit of code being executed to generate quite a lot of MIR.
For example:
birdA <- bird1 <? bird2
While a very simple single line statement in ek9 will generate a significant amount of IR. There are implicit '_isSet' calls being made, checks for 'null', memory management of temporary variables (to deal with possible exceptions). The above example just uses variable 'bird1'. But imaging a function/method call, that could throw and exception. We'd need to manage memory (heap retain/release, or stack (with auto release).
-
ClassesClassDescriptionActs as a base for the main construct definitions.Common code of Aggregate Construct types.Creates the appropriate IR Construct for a class declaration.Creates the appropriate IR Construct for a component declaration.Creates the appropriate IR Construct for a standalone function.Deals with visiting all parts of the EK9 structure in a module (compilable source).MULTI THREADED All symbols resolve and so should be able to create an intermediate representation.Creates the appropriate IR Construct for an Aggregate of type 'program'.Creates the appropriate IR Construct for a record declaration.Creates the appropriate IR Construct for a trait declaration.