Class StatementCounter

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

class StatementCounter extends Object
Tracks statement counts within functions/methods/operators. Increments on each executable statement encountered during AST traversal. This is used to enforce NCSS (Non-Commenting Source Statement) limits, preventing overly long functions that become hard to read and maintain.
  • Constructor Details

    • StatementCounter

      StatementCounter()
  • Method Details

    • pushScope

      void pushScope()
      Push new scope when entering function/method/operator. Initializes statement count to zero.
    • popScope

      int popScope()
      Pop scope and return statement count. Called when exiting function/method/operator.
      Returns:
      the total statement count in this scope
    • incrementCount

      void incrementCount()
      Increment the statement count for the current scope. Called when encountering an executable statement.
    • isNotEmpty

      boolean isNotEmpty()
      Check if there are any scopes on the stack.
      Returns:
      true if stack has contents