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 using AND (flattened-aggregate) semantics.

An aggregate is "set" if and only if EVERY field is set - as if the whole inheritance chain were flattened onto one object and every field checked. This is the boolean twin of the copy-left $ operator: obj is set <=> ?obj is true <=> all fields set.

The generated code follows this pattern:

Boolean _isSet():
  // Check super first (if not Any and has ? operator):
  if NOT super._isSet() -> return false   // an inherited field is unset -> we are unset

  // For each own field:
  //   if NOT this.field._isSet() -> return false   // a single unset field -> we are unset

  // Fell through: super (if any) set AND every own field set -> return true

Key semantic requirements:

  • Returns true only if ALL fields are set (short-circuit to false on the first unset field)
  • Returns false if super._isSet() returns false (honours the super's false)
  • Returns true if class has NO fields (stateless object is vacuously set)
  • A partially-initialised object - any own OR inherited field unset - is UNSET
  • STOPS at Any: Any._isSet() is always false; the superHasOperator("?") gate excludes it so it is never folded into the AND (which would force every derived object unset)
  • No parameter checking needed (no "other" parameter)
  • 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