Class AcyclicTypes

java.lang.Object
org.ek9lang.compiler.phase9.AcyclicTypes
All Implemented Interfaces:
Predicate<IRConstruct>

public final class AcyclicTypes extends Object implements Predicate<IRConstruct>
THE static acyclicity of a generated aggregate for the cycle collector (EK9_NATIVE_CYCLE_COLLECTOR_DESIGN.md §4.2, §12.2 items 4-5, §14.2 S3). An object of a PROVEN ACYCLIC type can never lie on a reference cycle, so a counting back end's allocator stamps it (natively EK9_GC_ACYCLIC) and no release ever buffers it as a candidate.

The proof is local, because EK9 types are closed by default: a field declared as a closed, concrete type holds an object of EXACTLY that type, so the field's declared type is its runtime type. A type is proven acyclic when every field it holds - inherited ones included - is a childless closed core type, an enumeration, or a closed concrete user class or record that is itself proven acyclic, and no chain of such fields returns to a type already on it. Anything else may hold anything: a container (one C type for every element type), Any, a trait, an open or abstract type, a function (a dynamic function captures), a type parameter, a parameterisation, a constrained type (its base lives in an IR-only delegate field the symbols do not list), any other core type, a field-bearing extern base, a dynamic class's captures. So a wrong answer can only be "not proven" - the object is buffered and scanned, as every object was before this - never "proven" for a type that can be on a cycle. An acyclic object can still be reached FROM a cycle; the collector walks and frees it with the island like any other, the flag only stops it being a candidate.

A pure function of the symbols, stated in the IR as a construct fact (IRConstruct.isAcyclic, rendered [acyclic]) by IR_OPTIMISATION, so no back end re-derives it; nothing is written to the symbol model. One instance per compile: decisions are memoised by fully-qualified name, which is unique within one compile.

  • Field Details

    • CHILDLESS_CORE_TYPES

      public static final Set<String> CHILDLESS_CORE_TYPES
      Core types whose objects hold no child - their C vtable's enumerate_children is the noop - and that are closed, so a field of one holds exactly one. Held in step with the C by AcyclicTypesDriftTest.
  • Constructor Details

    • AcyclicTypes

      public AcyclicTypes()
  • Method Details

    • test

      public boolean test(IRConstruct construct)
      Is every object construct allocates proven never to lie on a reference cycle.
      Specified by:
      test in interface Predicate<IRConstruct>