Class CloseableResourceToBeChecked
java.lang.Object
org.ek9lang.compiler.common.CloseableResourceToBeChecked
Checks if a symbol should be tracked as a closeable resource.
A closeable resource is a local variable whose type has a close() operator.
This predicate is used to identify variables that need to be tracked for resource leak detection. The rules are:
This predicate is used to identify variables that need to be tracked for resource leak detection. The rules are:
- Must be a VariableSymbol (not a type or function)
- Must not be a property field (fields are managed by the containing aggregate)
- Must not be an incoming parameter (caller's responsibility)
- Must not be a returning parameter (callee transfers ownership)
- Type must have a close() operator with no parameters and no return
- Type must NOT be Stdin, Stdout, or Stderr (these are global, never really closed)
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanisLocalVariable(ISymbol symbol) THE 'is this a local variable' for resource management: a variable that is not a property, not an incoming parameter and not the returning parameter.booleanTHE 'is this a type whose values the compiler must see closed' predicate: an aggregate with acloseoperator that is not one of the global standard streams and not a bare type parameter.boolean
-
Constructor Details
-
CloseableResourceToBeChecked
-
-
Method Details
-
isLocalVariable
THE 'is this a local variable' for resource management: a variable that is not a property, not an incoming parameter and not the returning parameter. Asked by the phase-5 check that a closeable local is a try resource (E81056). -
test
-
isManagedCloseableType
THE 'is this a type whose values the compiler must see closed' predicate: an aggregate with acloseoperator that is not one of the global standard streams and not a bare type parameter. The phase-5 named-local rule (E81056) asks it of a variable's type; the phase-5 store rule (E81059) asks it of both a stored value's type and the declared type of the slot it is stored into; phase 7 asks it of an unnamed temporary's type to decide whether the statement that created it must close it. All ask HERE so the ownership rules cannot disagree about what is closeable.
-