Class StrictAbsent
Every compiled absence TEST - the IS_NULL at the head of ? (and so of guards, ?: and the
comparison coalescing operators) and of ?? - answers a null quietly today: ? says false, ??
takes its right-hand side. In a well-typed program that null is unreachable (the front end proves every read is
preceded by a write), so meeting one means the proof has a hole. When the COMPILING JVM has
-Dek9.absent.strict=true (AbsentValue.STRICT_PROPERTY - the property is read the way
IRAnalysis reads ek9.arcBalance.strict), the null branch of each such test begins with a
Panic (PanicThrowInstrs) whose message is AbsentValue.message(String, String). Off (the default) this
emits nothing, so the IR - and every @IR/@BYTECODE golden - is unchanged.
🔑 :=?'s own IS_NULL is NOT a strict site, deliberately: on the never-written slot of
x as T? the null IS the case :=? exists for (it writes), and the front end credits it as the write
(controls g25/a10 in docs/language-design/absence-evidence/controls). Callers say which kind of test they
are building; nothing else may decide it.
The runtime half - the null tolerances in ek9-lang - reads the same property on the JVM that RUNS the
program (see AbsentValue). Back ends: the Panic is ordinary IR, so the LLVM back end gets it with no work.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordWhat observed an absent value, and where: the operator, and the source location named in the Panic message. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidemitIfEnabled(IRGenerationContext stackContext, List<IRInstr> instructions, StrictAbsent.Observer observer, DebugInfo debugInfo) In strict-absent mode, append the Panic toinstructions- the start of the branch a compiled absence test takes on a null.static booleanIs strict-absent mode on for this compilation?static Stringmessage(StrictAbsent.Observer observer) THE strict-absent Panic message for a compiled absence test.
-
Method Details
-
isEnabled
public static boolean isEnabled()Is strict-absent mode on for this compilation? -
message
THE strict-absent Panic message for a compiled absence test. -
emitIfEnabled
public static void emitIfEnabled(IRGenerationContext stackContext, List<IRInstr> instructions, StrictAbsent.Observer observer, DebugInfo debugInfo) In strict-absent mode, append the Panic toinstructions- the start of the branch a compiled absence test takes on a null. Otherwise append nothing.- Parameters:
stackContext- for temp names and the current scopeinstructions- the null branch being builtobserver- what observed the null, and wheredebugInfo- the debug information carried by the emitted instructions
-