Class OwnershipVerifier

java.lang.Object
org.ek9lang.compiler.phase9.OwnershipVerifier

public final class OwnershipVerifier extends Object
THE local rules of the ownership form (EK9_IR_OWNERSHIP_MODEL.md §11.2; stage-1 design §7) - the ones that need only the structured lists, not a per-path analysis:
  • V-C only an OWNED value is consumed, not twice in one straight list, and a value MOVED on a path (by DROP or a [consume] assignment) is not used after it on that path - its count now belongs to where it went, which may release it (Swift's use-after-move rule);
  • V-D a CAST forwards its operand's kind, and consumes an OWNED operand;
  • V-E the arms of a chain hand back values of one kind;
  • V-F DROP_AT_EXIT names a scope open in the current activation (the A11 rule);
  • V-G a slot's owner is open (or the CALLER or OBJECT) where the slot is first filled - its declaration, or its first [init] assignment when it is declared before its owner is entered (Contract 3: a try's resources and its region's first failure) - a slot is declared once per activation, and a slot is never itself dropped;
  • V-H a consumed argument is consumed by its call; an unmanaged result carries no count;
  • V-M the IR is in the ownership form ONLY: RETAIN, RELEASE, RELEASE_FIELD and SCOPE_REGISTER are OwnershipLowering's output, never phase 7's, and REFERENCE / TYPED_REFERENCE declares only a compiler temporary that holds no count of its own - every named variable is a SLOT_DECLARE with its owner (stage 3).

The rules see only what the ownership form states: a value's kind is ValueKind.madeBy(IRInstr) the instruction that made it (a CAST forwards its operand's), and a value no rule names is skipped. The per-path rules (V-A, V-B, V-I, V-J) wait for stage 4. Findings are structural.

  • Method Details

    • check

      public static List<String> check(IRConstruct construct)
      THE check of a construct in the ownership form (IR_ANALYSIS, and every IR fixture): each operation's problems as "operation: problem"; empty when every operation keeps every local rule. The lowered form is checked by RetainReleaseBalanceVerifier (V-L), never by this.
    • check

      static List<String> check(List<IRInstr> body)
      The problems in one operation body; empty when it keeps every local rule.