Class CaptureEvaluationScope

java.lang.Object
org.ek9lang.compiler.phase3.CaptureEvaluationScope

final class CaptureEvaluationScope extends Object
THE phase-3 answer to "whose code is running here?" for a property field (a private property or a capture) - shared by the access check (E06180 in IdentifierReferenceOrError) and the "read it through a capture" wording of an unresolved name inside a dynamic body (IdentifierReferenceOrError, IdentifierOrError).

The running code is the nearest dynamic function or class on the scope stack, else the nearest method or function. A capture list is the one place that differs (Steve, 2026-10-08, CAPTURES a/b): it is visited with its dynamic construct already on the stack, yet each capture expression is evaluated where the construct is CREATED, so it is judged outside that construct - '(limit: pivot)' in a method of the type that holds 'pivot', and an inner dynamic class capturing its enclosing dynamic function's capture. A capture SHARES the object, as a method returning the property would.

Whether the running code HOLDS a field is identity, never a name: one of its captures (CapturedVariables) or one of its own properties (OwnProperty; a method's are its aggregate's). Only outerFieldNamed(ParseTree, String) matches by name - it words the error for a name that did not resolve, and an unresolved name has nothing else.

  • Constructor Details

    • CaptureEvaluationScope

      CaptureEvaluationScope(SymbolsAndScopes symbolsAndScopes)
  • Method Details

    • isAccessibleWhereEvaluated

      boolean isAccessibleWhereEvaluated(org.antlr.v4.runtime.tree.ParseTree node, ISymbol propertyField)
      True when the code that evaluates node holds the property field (a capture or an own property). Where there is no running code to judge against, it is accessible (as it always was).
    • outerFieldNamed

      Optional<CaptureEvaluationScope.OuterField> outerFieldNamed(org.antlr.v4.runtime.tree.ParseTree node, String name)
      Inside a dynamic function or class body (not its capture list): the property or capture called name of the code AROUND it - the nearest construct outward that has one. A dynamic construct is pulled out to module level, so those fields are never in its scope; reading one directly stays an error (CAPTURES c), and this is what lets the error name the fix.