Class IrDirectiveText

java.lang.Object
org.ek9lang.compiler.directives.IrDirectiveText
All Implemented Interfaces:
Function<String,String>, UnaryOperator<String>

final class IrDirectiveText extends Object implements UnaryOperator<String>
THE normalisation applied to generated @IR / @IR_PARAMETERISED golden content before it is compared against - or emitted into - a directive body.

A directive body in a .ek9 file is backtick-delimited, so a literal backtick inside the generated IR would prematurely close the directive and break parsing of the whole source file. The one place this occurs today is the `expr` quoting inside a require failure's Panic message (e.g. Requirement failed: `count >= 0` at ...). Mirror the bytecode side (see BytecodeNormalizer, which does the identical substitution for the same reason): represent a backtick as the token BACKTICK in the golden, and apply the same substitution to generated IR before both the line comparison and the update-block emission so the two always agree.

Stateless: hold one.

  • Constructor Details

    • IrDirectiveText

      IrDirectiveText()
  • Method Details

    • apply

      public String apply(String generatedIr)
      Normalise generated IR text for use as (or comparison against) a backtick-delimited directive.
      Specified by:
      apply in interface Function<String,String>