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

  // No fields to check: return true (object is complete)
  // Has fields but none set: return false (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 true if class has NO fields (no state to be "unset")
  • Returns false only when has fields but ALL are unset (truly empty)
  • No parameter checking needed (no "other" parameter)

This semantic enables:

  • Stateless objects (no fields) to be considered valid/set
  • 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