Class IRConstruct

java.lang.Object
org.ek9lang.compiler.ir.instructions.IRConstruct
All Implemented Interfaces:
INode

public final class IRConstruct extends Object implements INode
In EK9 every construct becomes one of these nodes. So that means class, trait, component, program, function - everything.

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 Details

    • IRConstruct

      public IRConstruct(ISymbol symbol, String sourceFileName)
  • Method Details

    • isForSymbol

      public boolean isForSymbol(ISymbol toCheck)
    • getFullyQualifiedName

      public String getFullyQualifiedName()
    • getSourceFileName

      public String 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

      public String 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

      public String 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

      public void addField(Field field, Ek9Types ek9Types)
    • getTraceableFields

      public List<Field> getTraceableFields()
    • addImplementedTrait

      public void addImplementedTrait(ISymbol traitSymbol)
    • getImplementedTraits

      public List<ISymbol> getImplementedTraits()
    • add

      public void add(OperationInstr operation)
    • getSymbol

      public ISymbol getSymbol()
    • getFields

      public List<Field> getFields()
    • getOperations

      public List<OperationInstr> getOperations()
    • setProgramEntryPoint

      public void setProgramEntryPoint(ProgramEntryPointInstr programEntryPoint)
    • getProgramEntryPoint

      public Optional<ProgramEntryPointInstr> getProgramEntryPoint()
    • 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

      public Optional<Long> 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
    • accept

      public void accept(INodeVisitor visitor)
      Specified by:
      accept in interface INode
    • toString

      public String toString()
      Overrides:
      toString in class Object