Class LatticeOrder

java.lang.Object
org.ek9lang.compiler.phase5.flow.LatticeOrder

final class LatticeOrder extends Object
THE order of the value-tracking lattice: does one abstract value admit every run-time state another admits?

Each AbstractValue stands for a set of run-time states of a variable: TOP admits every state, BOTTOM none (the point cannot be reached), a constant exactly that value, a range every integer in it, an excluded constant every set value but that one, SET every set value, UNSET only the unset state, a collection state the set (or unset) collections with that emptiness, a lock identity the locks named, and a symbolic term only itself. covers(upper, lower) is true when the set upper stands for contains the one lower stands for.

It is what makes the join SOUND rather than merely commutative: LatticeJoin.of(AbstractValue, AbstractValue) must answer an upper bound of its two arguments - covers(join(a, b), a) and covers(join(a, b), b) - or a value the other branch can deliver is claimed impossible after the branches meet (D42: SET joined with a constant once answered the constant, and a correct program got "condition is always true"). LatticeJoinTest pins that property over every pair of kinds. Narrowing is the opposite direction (it may only move DOWN this order), and is never done by a join.

Deliberately conservative: where the representation cannot tell (a symbolic term against anything but itself), the answer is false, so the property test can only reject a join, never excuse an unsound one.

  • Method Details

    • covers

      static boolean covers(AbstractValue upper, AbstractValue lower)
      THE order: true if upper admits every run-time state that lower admits.