Skip to content

Commit f449da2

Browse files
committed
Python: Write explanatory examples.
1 parent 8e27904 commit f449da2

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

python/ql/src/experimental/dataflow/internal/DataFlowPrivate.qll

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,38 @@ private Node update(Node node) {
277277
* entries which are not unpacked are passed to the doubly starred parameter. This is achieved by
278278
* adding a dataflow step from the dictionary argument to `TKwOverflowNode(call, callable)` and a
279279
* step to clear content of that node at any unpacked keys.
280+
*
281+
* ## Examples:
282+
* Assume that we have the callable
283+
* ```python
284+
* def f(x, y, *t, *d):
285+
* pass
286+
* ```
287+
* Then the call
288+
* ```python
289+
* f(0, 1, 2, a=3)
290+
* ```
291+
* will be modelled as
292+
* ```python
293+
* f(0, 1, [*t], [**d])
294+
* ```
295+
* where `[` and `]` denotes synthesisezed nodes, so `[*t]` is the synthesized tuple argument
296+
* `TPosOverflowNode` and `[**d]` is the synthesized dictionary argument `TKwOverflowNode`.
297+
* There will be a store step from `2` to `[*t]` at pos `0` and one from `3` to `[**d]` at key
298+
* `a`.
299+
*
300+
* For the call
301+
* ```python
302+
* f(0, **{"y": 1, "a": 3})
303+
* ```
304+
* no tuple arguemnt is synthesized. It is modelled as
305+
* ```python
306+
* f(0, [y=1], [**d])
307+
* ```
308+
* where `[y=1]` is the synthesised unpacked argument `TKwUnpacked` (with `name` = `y`). There is
309+
* a read step from `**{"y": 1, "a": 3}` to `[y=1]` at key `y` to get the value passed to the parameter
310+
* `y`. There is a dataflow step from `**{"y": 1, "a": 3}` to `[**d]` to transfer the content and
311+
* a clearing of content at key `y` for node `[**d]`, since that value has been unpacked.
280312
*/
281313
module ArgumentPassing {
282314
/**

0 commit comments

Comments
 (0)