You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+34Lines changed: 34 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -349,7 +349,41 @@ class MyCustomVisitor(AbstractVisitor):
349
349
...
350
350
```
351
351
352
+
### Composed Visitor
353
+
354
+
Usually, in order to complete the action you want to perform on a graph, you require to chain the visitor one after the other. In order to do so, a utility exist in freexgraph called VisitorComposer.
355
+
356
+
A visitor composer is split between three part :
357
+
* before : a list of visitor pattern to apply one after the other. Each of those visitations will trigger a traversal of the graph. All those visitors are launched in order before the action
358
+
* action : a list of visitor pattern to apply in one traversal. It is useful in order to not traverse the graph too many times if not required
359
+
* after : a list of visitor pattern to apply one after the other. Each of those visitations will trigger a traversal of the graph. All those visitors are launched in order after the action
360
+
361
+
The action visitor list from the visitor composer is what is special. It makes it possible to do multiple actions in one traversal of the graph.
# * VisitorA is applied on execution_graph.root (full traversal)
373
+
# * VisitorB is applied on execution_graph.root (full traversal)
374
+
#
375
+
# In one traversal
376
+
# * VisitorC action is applied on each node
377
+
# * VisitorD action is applied on each node
378
+
# * VisitorE action is applied on each node
379
+
#
380
+
# * VisitorF is applied on execution_graph.root (full traversal)
381
+
# * VisitorG is applied on execution_graph.root (full traversal)
382
+
visitor_composed.visit(execution_graph.root)
383
+
```
384
+
352
385
### Reverse visit
386
+
353
387
It is possible to revert the order of visitation of any visitor by setting its attribute `is_reversed` of the visitor (works with any type of visitor inheriting from AbstractVisitor).
0 commit comments