Skip to content
This repository was archived by the owner on Nov 23, 2024. It is now read-only.

feat: rework of build call graph #225

Closed
lukarade opened this issue Feb 29, 2024 · 0 comments · Fixed by #238
Closed

feat: rework of build call graph #225

lukarade opened this issue Feb 29, 2024 · 0 comments · Fixed by #238
Assignees
Labels
enhancement 💡 New feature or request purity Inferring the purity of functions

Comments

@lukarade
Copy link
Contributor

Is your feature request related to a problem?

After reviewing the new resolve_references approach, we found that build_call_graph can be optimized too.

Desired solution

The dataclass CallGraphNode can be simplified, and the build process can be optimized using the new Reasonsclass.

Possible alternatives (optional)

No response

Screenshots (optional)

No response

Additional Context (optional)

No response

@lukarade lukarade added enhancement 💡 New feature or request purity Inferring the purity of functions labels Feb 29, 2024
@lukarade lukarade self-assigned this Feb 29, 2024
@lukarade lukarade linked a pull request Mar 3, 2024 that will close this issue
lars-reimann pushed a commit that referenced this issue Mar 8, 2024
…#238)

Closes #171 #225 #237 

### Summary of Changes

After reviewing the new `resolve_references` approach, we found that
`build_call_graph` and thus `infer_purity` could also be optimised.
`built_call_graph` now uses the new `CallGraphBuilder` class and an
improved recursive approach to build a call graph from a
`Reasons`object:
First the data for classes is pre-processed, so that the `__init__` are
linked to their respective class.
Then, a function iterates over all `Reasons` objects and adds either a
`CallGraphNode` - for self defined functions and builtins, a
`CombinedCallGraphNode` - for a node that represents a cycle of
functions or an `ImportedCallGraphNode` - for imported functions to the
call graph. When a node is edited, all calls of that node are added as
children to that node.

`infer_purity` now uses the new `PurityAnalyzer` class to analyze the
call graph for impurity.
As before, all reasons for impurity are detected by first analyzing the
children of a `CallGraphNode` and propagating their results, before
analyzing the node itself. Imported nodes are treated separately.
Combined nodes are decombined to their original functions, and the
results of the combined node is transferred.

---------

Co-authored-by: megalinter-bot <[email protected]>
@github-project-automation github-project-automation bot moved this from Backlog to ✔️ Done in Library Analysis Mar 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement 💡 New feature or request purity Inferring the purity of functions
Projects
Status: ✔️ Done
1 participant