Class ScopedInstructionExecutor
java.lang.Object
org.ek9lang.compiler.phase7.support.ScopedInstructionExecutor
CONCERN: Temporary scope lifecycle management.
RESPONSIBILITY: Execute instructions within auto-cleanup scope.
REUSABILITY: ALL generators (33+ usages across codebase).
Encapsulates the repetitive pattern: 1. Generate scope ID 2. Push scope onto stack (enterScope) 3. Add SCOPE_ENTER instruction 4. Execute instructions 5. Add SCOPE_EXIT instruction 6. Pop scope from stack (exitScope)
This ensures consistent scope lifecycle management across all generators, eliminating bugs from manual scope handling and reducing code duplication.
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
ScopedInstructionExecutor
-
-
Method Details
-
execute
Execute instructions within temporary scope.The scope is automatically created, pushed onto the stack, and cleaned up after the instructions execute. This ensures proper memory management through scope-based reference counting.
- Parameters:
instructionGenerator- Supplier that generates the instructions to executedebugInfo- Debug information for scope instructions- Returns:
- Complete instruction list with SCOPE_ENTER, instructions, SCOPE_EXIT
-