Class NestingDepthCounter
java.lang.Object
org.ek9lang.compiler.phase5.NestingDepthCounter
Tracks nesting depth within functions/methods/operators.
Increments on entering control structures (if, while, for, switch, try, etc.),
decrements on exit. Records maximum depth reached per function scope.
This is used to enforce nesting depth limits, preventing deeply nested code
that becomes hard to read and maintain.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) voidIncrement depth when entering a control structure.(package private) voidDecrement depth when exiting a control structure.(package private) booleanisEmpty()Check if there are any scopes on the stack.(package private) intpopScope()Pop scope and return max depth reached.(package private) voidPush new scope when entering function/method/operator.
-
Constructor Details
-
NestingDepthCounter
NestingDepthCounter()
-
-
Method Details
-
pushScope
void pushScope()Push new scope when entering function/method/operator. -
popScope
int popScope()Pop scope and return max depth reached. Called when exiting function/method/operator.- Returns:
- the maximum nesting depth reached in this scope
-
enterNesting
void enterNesting()Increment depth when entering a control structure. Updates max depth if this is the deepest we've been. -
exitNesting
void exitNesting()Decrement depth when exiting a control structure. -
isEmpty
boolean isEmpty()Check if there are any scopes on the stack.- Returns:
- true if stack has no contents
-