-
Notifications
You must be signed in to change notification settings - Fork 10
[Hooks] Basic support for on.exit including domination
#2160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request implements basic support for the on.exit hook mechanism in flowR's dataflow analysis. The on.exit function in R allows registering cleanup code that executes when a function exits, regardless of how the exit occurs (normal return, explicit return, or error). The implementation includes:
- Core hook infrastructure with domination analysis to handle exit point overwriting
- Built-in processor for
on.exitthat wraps expressions into function definitions - Hook compaction logic to remove redundant and dominated hooks
- Comprehensive test coverage for various
on.exitscenarios - Documentation updates marking hooks as "partially supported"
Key Changes
- New
hooks.tsmodule definingKnownHooksenum and hook management functions - Extended
DataflowCfgInformationto track registered hooks within subtrees - Built-in processor for
on.exitthat handles theaddandafterparameters - Hook execution integrated into function definition processing with exit point domination
- Updated call graph generation to include hook calls
Reviewed changes
Copilot reviewed 55 out of 58 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| src/dataflow/hooks.ts | New file defining hook types, compaction logic, and utilities for managing registered hooks |
| src/dataflow/info.ts | Added hooks field to DataflowCfgInformation, new overwriteExitPoints function for exit point domination |
| src/dataflow/internal/process/functions/call/built-in/built-in-register-hook.ts | New built-in processor that transforms on.exit calls into hook registrations |
| src/dataflow/internal/process/functions/call/built-in/built-in-function-definition.ts | Processes exit hooks, calls them, and handles exit point domination |
| src/dataflow/environments/default-builtin-config.ts | Registers on.exit as a hook registration function (moved from unknown side effects) |
| src/dataflow/graph/call-graph.ts | Updated to include hook calls in call graph |
| test/functionality/dataflow/processing-of-elements/functions/dataflow-function-on-exit.test.ts | New comprehensive test suite covering various on.exit scenarios |
| test/functionality/dataflow/call-graph/call-graph-hooks.test.ts | New tests for hook behavior in call graphs |
| test/functionality/_helper/shell.ts | Added mustNotHaveVertices and mustNotHaveEdges test configuration options |
| src/dataflow/internal/process/functions/call/known-call-handling.ts | Changed from reverse() to toReversed() for immutability |
| src/util/collections/defaultmap.ts | Updated return types from IterableIterator to MapIterator for type accuracy |
| src/util/range.ts | Added invalidRange() helper function |
| wiki/*.md | Generated documentation updates reflecting timing changes and R version updates |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
test/functionality/dataflow/call-graph/call-graph-hooks.test.ts
Outdated
Show resolved
Hide resolved
test/functionality/dataflow/processing-of-elements/functions/dataflow-function-on-exit.test.ts
Outdated
Show resolved
Hide resolved
test/functionality/dataflow/processing-of-elements/functions/dataflow-function-on-exit.test.ts
Outdated
Show resolved
Hide resolved
test/functionality/dataflow/processing-of-elements/functions/dataflow-function-on-exit.test.ts
Outdated
Show resolved
Hide resolved
test/functionality/dataflow/processing-of-elements/functions/dataflow-function-on-exit.test.ts
Outdated
Show resolved
Hide resolved
|
This pull request is included in v2.8.0 (see Release v2.8.0 (Call-Graphs, Roxygen 2 Support, Many Plugins, Registrations, Exceptions and Hooks)). |
No description provided.