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 very clearly 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.
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 stlandard.
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.
-
ClassDescriptionActs as a base for the main construct definitions.Acts as base for most generators as they all require the context and in most cases need to generate debug information.Both AND/OR are very similar in processing, the only real differences are:
What operation to call and the op code to generate.Pulls out the common code for variable and variable-only declarations.Creates IR instructions for assignment expressions.Process assignment statement: variable = expression Uses RELEASE-then-RETAIN pattern for memory-safe assignments.Creates BasicBlock IR from EK9 instruction block contexts.Creates IR instructions for block statements.Creates the appropriate IR Construct for a class declaration.Creates the appropriate IR Construct for a component declaration.Creates IR instructions for expressions.Creates the appropriate IR Construct for a standalone function.Guarded assignment generator using unified SWITCH_CHAIN_BLOCK approach.Generates IR instructions for guarded assignment operations (:=? - ASSIGN_UNSET).Data class to hold parameters for guarded assignment generation.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.Deals with generating the correct IR Instructions for processing any form of literal.Creates IR instructions for object access expressions.Deals with the generation of the IR for OperationDetails.Creates the appropriate IR Construct for an Aggregate of type 'program'.Generates IR instructions for question operator (?) using unified SWITCH_CHAIN_BLOCK.Creates the appropriate IR Construct for a record declaration.Generates IR instructions for Boolean AND operations using LOGICAL_AND_BLOCK pattern.Generates IR instructions for Boolean OR operations using LOGICAL_OR_BLOCK pattern.Creates IR instructions for statements.Unified generator for all EK9 control flow constructs using SWITCH_CHAIN_BLOCK.Creates the appropriate IR Construct for a trait declaration.Creates IR instructions for variable declarations.Creates IR instructions for variable only declarations.