Class ConstrainedConstruction
java.lang.Object
org.ek9lang.compiler.phase7.ConstrainedConstruction
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 Summary
ConstructorsConstructorDescriptionConstrainedConstruction(IRGenerationContext stackContext, ConstrainedTypeInstrs instrs, ConstraintLowering lowering, BooleanCondition booleanCondition) -
Method Summary
Modifier and TypeMethodDescription(package private) voidprocessFallibleFactory(OperationInstr operation) Generate the fallible factoryof(arg as Base) -> Constrained?.(package private) voidprocessIsSetOperator(OperationInstr operation) Generate?asthis._viable AND this._delegate._isSet()rather than delegating it.(package private) voidprocessParameterizedConstructor(OperationInstr operation, List<ISymbol> params) Generate constructor that takes a base-type argument and stores it in the delegate field.
-
Constructor Details
-
ConstrainedConstruction
ConstrainedConstruction(IRGenerationContext stackContext, ConstrainedTypeInstrs instrs, ConstraintLowering lowering, BooleanCondition booleanCondition)
-
-
Method Details
-
processParameterizedConstructor
Generate constructor that takes a base-type argument and stores it in the delegate field. -
processFallibleFactory
Generate the fallible factoryof(arg as Base) -> Constrained?. Returns a SET constrained value whenargis 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
Generate?asthis._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.
-