Class IsSetGenerator

java.lang.Object
org.ek9lang.compiler.phase7.synthesis.AbstractSyntheticGenerator
org.ek9lang.compiler.phase7.synthesis.IsSetGenerator

final class IsSetGenerator extends AbstractSyntheticGenerator
Generates synthetic IR for the _isSet (?) operator.

The generated code follows this pattern:

Boolean _isSet():
  // Check super first (if not Any and has ? operator)
  if super._isSet() -> return true  // Valid via parent

  // For each field in own properties:
  //   result = this.field._isSet()
  //   if result._true() -> return true  // Found set field

  return false  // No fields set = truly empty object

Key semantic requirements:

  • Returns true if ANY field is set (short-circuit on first set)
  • Returns true if super._isSet() returns true
  • Returns false only when ALL fields are unset (truly empty)
  • No parameter checking needed (no "other" parameter)

This "ANY field set" semantic enables:

  • Partial objects with optional fields to be valid
  • Builder patterns where objects become valid incrementally
  • Reduced boilerplate (no need to override ? for optional fields)
  • Constructor Details

  • Method Details

    • generate

      List<IRInstr> generate(MethodSymbol methodSymbol, AggregateSymbol aggregateSymbol)
      Generate the _isSet operator IR for the given aggregate.
      Parameters:
      methodSymbol - The _isSet method symbol
      aggregateSymbol - The aggregate containing the method
      Returns:
      List of IR instructions implementing the method