Class IRConstruct
- All Implemented Interfaces:
INode
In the case of functions there is a single 'call' method, this has all the parameters that would be supplied when other constructs use the function.
So this is more like a Function in Java - that is really just an object. The reason for this is that in EK9 it is possible for functions to 'capture' variables as properties (dynamic functions). But this whole mechanism makes sense even for normal fixed named functions. It also means it is very easy to pass functions around as data.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaccept(INodeVisitor visitor) voidadd(OperationInstr operation) voidvoidaddImplementedTrait(ISymbol traitSymbol) THE single IR-tree traversal for this construct: every instruction in every operation body, flattened depth-first through every nested instruction list the back-end executes.Get the coverage module ID for this construct.intCount the total number of coverage probes in this construct.The construct's DISPLAY name (module::Holder of String), present only where it differs fromgetFullyQualifiedName()- a monomorphised generic, whose identity is a digest.Returns the normalized source file name for JVM debug information.The display name of the abstract base or trait whose hierarchy-wide<=>this construct is sealed under, present ONLY then (D52 residual, Contract 22): the sort groups every type sharing it together and orders the groups by this name.Returns signature-qualified name including parameter types and return type.Returns the source file name where this construct was defined.The single nominal super type this construct extends, resolved from the symbol's declared super (function super-chain, Scenario-2 wrapper base, or aggregate super).The locale variants of a text's abstract base - present only on such a base.booleanCheck if this construct has coverage instrumentation.booleanTrue when an implemented trait (its own, a super's or a trait's trait) declares value semantics - an==or<=>taking one argument, or a#?.booleanTrue when no object of this type can lie on a reference cycle (EK9_NATIVE_CYCLE_COLLECTOR_DESIGN.md §14.2, S3): a counting back end never makes one a cycle candidate.booleanTrue when no object of this type can be reached from anything shared between threads (EK9_NATIVE_CYCLE_COLLECTOR_ DESIGN.md §13.11, T12 - phase5 ConfinedTypeMarker), so every object of it belongs to the thread that made it: a counting back end may collect such objects on that thread while other threads run.booleanisForSymbol(ISymbol toCheck) booleanAssess if this construct is a function or a general aggregate symbol type.booleanbooleanTrue when an object of this type can be reached from what is published for the life of the program - an application's registrations, a handler given to runtime threads (EK9_NATIVE_CYCLE_COLLECTOR_DESIGN.md §13.11, S2 - phase5 RegisteredTypeMarker): a store into one of its fields after construction is the store barrier (PUBLISH store).voidsetAcyclic(boolean acyclic) voidsetConfined(boolean confined) voidsetProgramEntryPoint(ProgramEntryPointInstr programEntryPoint) voidsetRegistered(boolean registered) voidsetServiceRouteDetails(ServiceRouteDetails serviceRouteDetails) voidsetTextVariantTable(TextVariantTable textVariantTable) toString()
-
Constructor Details
-
IRConstruct
-
-
Method Details
-
getSamenessOwner
The display name of the abstract base or trait whose hierarchy-wide<=>this construct is sealed under, present ONLY then (D52 residual, Contract 22): the sort groups every type sharing it together and orders the groups by this name. A type that is its own sameness owner has none - run time names it from its own class. IR data fixed from the symbols (SortOwnerAbove); each back end stores it as data on the type.- Returns:
- the sameness owner's display name, or empty when the construct is its own owner
-
isForSymbol
-
getFullyQualifiedName
-
getDisplayName
The construct's DISPLAY name (module::Holder of String), present only where it differs fromgetFullyQualifiedName()- a monomorphised generic, whose identity is a digest. Each back end stores it as data on the type (JVM: a static constant; native: besidevtable->type_name) for the run-time helpertypeNameOf. Never an identity (Contract 21,ConstructDisplayName).- Returns:
- the display name, or empty when the identity already reads correctly
-
getSourceFileName
Returns the source file name where this construct was defined. This is used for JVM debug information (SourceFile attribute) to enable debuggers to map bytecode back to the original .ek9 source file.- Returns:
- Source file name, typically a relative path like "introduction/HelloWorld.ek9"
-
getNormalizedSourceFileName
Returns the normalized source file name for JVM debug information. Strips the "./" prefix if present, as jdb and other debuggers interpret "./" literally and fail to find source files like "./workarea.ek9".This normalized form is required for: - JVM SourceFile attribute in .class files - JSR-45 SMAP (Source Map) generation - Debugger source file resolution (jdb, IDE debuggers)
- Returns:
- Normalized source file name without "./" prefix (e.g., "workarea.ek9" instead of "./workarea.ek9")
-
getSignatureQualifiedName
Returns signature-qualified name including parameter types and return type. For functions and methods, this includes the complete signature to enable method overloading resolution and target code generation.Format: "module::construct(org.ek9.lang::ParamType1,org.ek9.lang::ParamType2)->org.ek9.lang::ReturnType"
- Returns:
- Signature-qualified name for overload resolution.
-
isFunction
public boolean isFunction()Assess if this construct is a function or a general aggregate symbol type.- Returns:
- true if the construct is just a function - otherwise false and it is an aggregate.
-
isProgram
public boolean isProgram() -
addField
-
getTraceableFields
-
addImplementedTrait
-
getImplementedTraits
-
inheritsValueSemanticsFromTrait
public boolean inheritsValueSemanticsFromTrait()True when an implemented trait (its own, a super's or a trait's trait) declares value semantics - an==or<=>taking one argument, or a#?. A concrete implementer that inherits its sameness from a trait body declares none itself, yet still needs Javaequals/hashCodeso hash containers (Set, Dict keys) honour it: a JVM interface cannot default those two. Carried here, from the traits the construct already records, so a back end never searches the symbol table for it (B18 prerequisite P1; Contract 6).- Returns:
- whether sameness reaches this construct from a trait
-
getSuperType
The single nominal super type this construct extends, resolved from the symbol's declared super (function super-chain, Scenario-2 wrapper base, or aggregate super). Empty means it extendsObject(no usable super, or the super isAnyfor a function). Backends read this instead of re-deriving the super, keeping code generation mechanical and consistent.- Returns:
- the resolved super type symbol, or empty
-
add
-
getSymbol
-
getFields
-
getOperations
-
isAcyclic
public boolean isAcyclic()True when no object of this type can lie on a reference cycle (EK9_NATIVE_CYCLE_COLLECTOR_DESIGN.md §14.2, S3): a counting back end never makes one a cycle candidate. Known from IR_OPTIMISATION on (false before it); rendered[acyclic]. -
setAcyclic
public void setAcyclic(boolean acyclic) -
isConfined
public boolean isConfined()True when no object of this type can be reached from anything shared between threads (EK9_NATIVE_CYCLE_COLLECTOR_ DESIGN.md §13.11, T12 - phase5 ConfinedTypeMarker), so every object of it belongs to the thread that made it: a counting back end may collect such objects on that thread while other threads run. Known from IR_OPTIMISATION on (false before it); rendered[confined]. -
setConfined
public void setConfined(boolean confined) -
isRegistered
public boolean isRegistered()True when an object of this type can be reached from what is published for the life of the program - an application's registrations, a handler given to runtime threads (EK9_NATIVE_CYCLE_COLLECTOR_DESIGN.md §13.11, S2 - phase5 RegisteredTypeMarker): a store into one of its fields after construction is the store barrier (PUBLISH store). Known from IR_OPTIMISATION on (false before it); rendered[registered]. -
setRegistered
public void setRegistered(boolean registered) -
setProgramEntryPoint
-
getProgramEntryPoint
-
setServiceRouteDetails
-
getServiceRouteDetails
-
setTextVariantTable
-
getTextVariantTable
The locale variants of a text's abstract base - present only on such a base. SeeTextVariantTable. -
hasCoverageProbes
public boolean hasCoverageProbes()Check if this construct has coverage instrumentation.Returns true if any operation in this construct contains a COVERAGE_PROBE instruction. When true, bytecode generation should add a $ek9_coverage field to hold the module's shared probe array.
- Returns:
- true if coverage probes are present in this construct
-
getCoverageModuleId
Get the coverage module ID for this construct.Extracts the moduleId from the COVERAGE_REGISTER instruction which has the authoritative module ID computed from the module name.
- Returns:
- Optional containing the module ID, or empty if no coverage registration
-
getCoverageProbeCount
public int getCoverageProbeCount()Count the total number of coverage probes in this construct.- Returns:
- The number of COVERAGE_PROBE instructions in all operations
-
allBodyInstructions
THE single IR-tree traversal for this construct: every instruction in every operation body, flattened depth-first through every nested instruction list the back-end executes. The coverage has/find/count queries above are one-liners over it - do NOT re-derive another walker; use this orExecutedInstructionsOf(one operation) /ExecutedInstructionsIn(a list).Consolidated three previously-divergent walkers. Completed 2026-09-24: it had omitted a chain's condition-case
conditionEvaluationandguardUpdates(where a while-loop'shasNext()and a guard's_isSet()live) and a for-range loop's initialisation and direction/condition/setup/increment lists - all executed by the back-end, so an IR reader using the old walk silently missed calls. A chain'sevaluation_variable_setupandreturn_variable_setupare deliberately NOT walked: they are rendered in the textual IR but no back-end reads them, so they are not executed code. -
accept
-
toString
-