Class SmapGenerator

java.lang.Object
org.ek9lang.compiler.backend.jvm.SmapGenerator

public final class SmapGenerator extends Object
Generates JSR-45 SMAP (Source Map) for debugging non-Java languages on the JVM.

SMAP format enables debuggers to map JVM bytecode back to original .ek9 source files. This is critical for proper debugging support - without SMAP, debuggers expect .java files.

SMAP Structure:

SMAP
GeneratedFileName
LanguageName
*S LanguageName
*F
+ FileID FileName
  FilePath
*L
InputStartLine#FileID,InputLineCount:OutputStartLine,OutputLineIncrement
*E
See Also:
  • Constructor Details

    • SmapGenerator

      public SmapGenerator(String generatedFileName)
      Create SMAP generator for a specific generated class.
      Parameters:
      generatedFileName - The name of the generated .class file (without .class extension)
  • Method Details

    • addMapping

      public void addMapping(DebugInfo debugInfo, int outputLineNumber)
      Add debug information from an IR instruction to the SMAP.
      Parameters:
      debugInfo - Debug information from IR
      outputLineNumber - JVM bytecode line number
    • collectFromIRConstruct

      public void collectFromIRConstruct(IRConstruct construct)
      Collect all debug information from IR construct operations.
      Parameters:
      construct - IR construct containing operations with debug info
    • generate

      public String generate()
      Generate complete SMAP string in JSR-45 format.
      Returns:
      SMAP string for SourceDebugExtension attribute