Class LiteralInstruction

java.lang.Object
org.ek9lang.compiler.ir.IRInstruction
org.ek9lang.compiler.ir.LiteralInstruction
All Implemented Interfaces:
INode

public final class LiteralInstruction extends IRInstruction
IR instruction for loading literal/constant values. Handles string literals, numeric literals, boolean literals, etc. Uses symbol-driven approach to get correct type information.
  • Method Details

    • stringLiteral

      public static LiteralInstruction stringLiteral(String result, String literalValue, String literalType, DebugInfo debugInfo)
      Create instruction to load a string literal.
      Parameters:
      result - Variable to store the literal value
      literalValue - The actual string value (including quotes)
      literalType - The resolved type name (could be decorated for generic contexts)
      debugInfo - Debug information for source mapping (can be null)
      Returns:
      LiteralInstruction for loading string literal
    • numericLiteral

      public static LiteralInstruction numericLiteral(String result, String literalValue, String literalType, DebugInfo debugInfo)
      Create instruction to load a numeric literal.
      Parameters:
      result - Variable to store the literal value
      literalValue - The numeric value as string
      literalType - The resolved type name (Integer, Float, etc.)
      debugInfo - Debug information for source mapping (can be null)
      Returns:
      LiteralInstruction for loading numeric literal
    • booleanLiteral

      public static LiteralInstruction booleanLiteral(String result, String literalValue, String literalType, DebugInfo debugInfo)
      Create instruction to load a boolean literal.
      Parameters:
      result - Variable to store the literal value
      literalValue - The boolean value as string ("true" or "false")
      literalType - The resolved type name (typically "Boolean")
      debugInfo - Debug information for source mapping (can be null)
      Returns:
      LiteralInstruction for loading boolean literal
    • literal

      public static LiteralInstruction literal(String result, String literalValue, String literalType, DebugInfo debugInfo)
      Create instruction to load any literal value.
      Parameters:
      result - Variable to store the literal value
      literalValue - The literal value as string
      literalType - The resolved type name (could be decorated)
      debugInfo - Debug information for source mapping (can be null)
      Returns:
      LiteralInstruction for loading the literal
    • stringLiteral

      public static LiteralInstruction stringLiteral(String result, String literalValue, String literalType)
    • numericLiteral

      public static LiteralInstruction numericLiteral(String result, String literalValue, String literalType)
    • booleanLiteral

      public static LiteralInstruction booleanLiteral(String result, String literalValue, String literalType)
    • literal

      public static LiteralInstruction literal(String result, String literalValue, String literalType)
    • getLiteralValue

      public String getLiteralValue()
      Get the literal value.
    • getLiteralType

      public String getLiteralType()
      Get the literal type (could be decorated for generic contexts).
    • toString

      public String toString()
      Overrides:
      toString in class IRInstruction