Package org.ek9lang.compiler.phase5


package org.ek9lang.compiler.phase5
I - PRE Intermediate Representation generation checks.

At this point, before the compiler builds the intermediate representation it completes some more checks.

PreIntermediateRepresentationChecks is the main entry point for this phase. Most of the processing is delegated to PreIRListener.

This now follows the same pattern as most of the other Listeners, using SymbolsAndScopes for handling scope traversals and locating recorded symbols and scopes.

There is a 'complexity' calculator built into this phase, it is quite tolerant of high complexity. It does emit compiler errors if a single method/function has complexity at level 50 or higher or if an aggregate has a total complexity of 500 or higher. The rules for calculating complexity are based on a modified McCabe region algorithm. It is quite simple in its approach, as code elements are encountered a level of complexity is incremented.

There are additional checks around simple evaluation of whether variables have been initialised or not. In some cases properties on aggregates may need to be defined in uninitialised for i.e.

   prop1 as String?
 

In such cases the EK9 compiler will mandate that the EK9 developer create all necessary coded constructors, it will not mandate that 'prop1' is then initialised - it will leave that to the Ek9 developer to 'take the risk' and understand what may or may not go wrong in their code.

Ideally, all properties and variables are always declared in initialised form (even if the value is 'un-set'). But this cannot always be mandated, so the EK9 compiler has some tolerance for these uninitialised variables.