Class TextBodyMethodGenerator

java.lang.Object
org.ek9lang.compiler.phase7.generator.TextBodyMethodGenerator

public final class TextBodyMethodGenerator extends Object
Generates IR for text body methods with implicit String return.

Text body methods are unique in EK9 - they have an implicit String return type where the stringLit IS the return value. Unlike regular methods which declare <- rtn as String: value, text body methods have:

  greeting()
    -> name as String
    `Hello ${name}!`

The stringLit can be either:

  • Quoted string "Hello" - simple constant
  • Backtick string `Hello ${name}!` - potentially with interpolation
  • Constructor Details

  • Method Details

    • process

      public void process(OperationInstr operation, EK9Parser.TextBodyDeclarationContext ctx)
      Process a text body method and populate the OperationInstr with IR instructions.
      Parameters:
      operation - The operation instruction to populate
      ctx - The textBodyDeclaration parse context