Class ConstrainedConstruction

java.lang.Object
org.ek9lang.compiler.phase7.ConstrainedConstruction

final class ConstrainedConstruction extends Object
THE construction bodies of a constrained type (DFN-3): the constructor that takes a value (a copy of a base or constrained value, or a conversion), the fallible factory of, and ? - each deciding whether the value it holds is usable for the constraint (_viable).
  • Constructor Details

  • Method Details

    • processParameterizedConstructor

      void processParameterizedConstructor(OperationInstr operation, List<ISymbol> params)
      Generate constructor that takes a base-type argument and stores it in the delegate field.
    • processFallibleFactory

      void processFallibleFactory(OperationInstr operation)
      Generate the fallible factory of(arg as Base) -> Constrained?. Returns a SET constrained value when arg is set and satisfies the constraint, otherwise an UNSET constrained value. It NEVER Panics (unlike the bare constructor, which Panics on a set out-of-range value) — the safe path for validating untrusted input. The set path calls the bare constructor with the already-validated value, which cannot Panic.
    • processIsSetOperator

      void processIsSetOperator(OperationInstr operation)
      Generate ? as this._viable AND this._delegate._isSet() rather than delegating it.

      Pure delegation asked the delegate a question it cannot answer. The delegate knows WHAT value is held; it does not know whether this constrained value was REJECTED, because a rejected value has no distinguishable base representation when the base's default is itself set. Both halves are needed: the flag catches a rejection (and a default that breaches the window), the delegate catches an ordinarily unset value flowing through.