Class CloseableArgumentKeeping

java.lang.Object
org.ek9lang.compiler.phase5.CloseableArgumentKeeping

final class CloseableArgumentKeeping extends Object
THE record of which constructor parameters a constructor KEEPS as a closeable property, and the deferred verdict on every construction that hands such a parameter a value that is not new (R4 of the fresh-store rule, E81062).

A constructor that stores its own parameter in a closeable property (held: res) takes ownership of the argument: the holder's operator close will close it. That is a transfer, and it is right only when the caller hands over a NEW value - Holder(Res("x")). Handing it a value that already has an owner - a try resource, a parameter, another object's property - gives that one resource two owners, and both close it (try -> res <- Res() / holder <- Holder(res) closed res twice).

Collected while every source is walked (Walk 1, in parallel), decided once all have been (check()): a constructor in one file is called in another, and a constructor that passes its own parameter on to super(...), this(...) or another keeping constructor keeps it too, which is a fixpoint over all of them. A member of a parameterised type is judged by the generic's own constructor (GenericTemplateMember).

  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    (package private) void
    After every source has been walked: close the kept set over the forwards, then report every construction that hands a kept parameter a value that is not new.
    (package private) void
    forwards(MethodSymbol constructor, int fromIndex, MethodSymbol target, int toIndex)
    The constructor passes its own parameter at fromIndex to target at toIndex: if the target keeps it, so does this constructor.
    (package private) void
    keeps(MethodSymbol constructor, int index)
    The constructor stores its parameter at index in a closeable property of the object it constructs.
    (package private) void
    notFresh(MethodSymbol target, int index, ErrorListener errorListener, IToken location, String argument)
    A construction is given a closeable value that is not new at index: an error when the constructor keeps that parameter.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • CloseableArgumentKeeping

      CloseableArgumentKeeping()
  • Method Details

    • keeps

      void keeps(MethodSymbol constructor, int index)
      The constructor stores its parameter at index in a closeable property of the object it constructs.
    • forwards

      void forwards(MethodSymbol constructor, int fromIndex, MethodSymbol target, int toIndex)
      The constructor passes its own parameter at fromIndex to target at toIndex: if the target keeps it, so does this constructor.
    • notFresh

      void notFresh(MethodSymbol target, int index, ErrorListener errorListener, IToken location, String argument)
      A construction is given a closeable value that is not new at index: an error when the constructor keeps that parameter.
    • check

      void check()
      After every source has been walked: close the kept set over the forwards, then report every construction that hands a kept parameter a value that is not new.