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: resources/doc/analysis.md
+20-20Lines changed: 20 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,14 +5,14 @@ A general note: When we import an entity, we cannot know if it is a variable, a
5
5
> Note: Currently, analysis done with FASTPython are mostly done to analyse variables. So the documentation will be centered on analysis of variables and the algos are mostly tested on variables analysis and not functions, methods, ...ß
6
6
7
7
-[Doing analysis on FASTPython](#doing-analysis-on-fastpython)
8
-
-[Overview of the analysis pipeline](#overview-of-the-analysis-pipeline)
9
-
-[FAST utilities](#fast-utilities)
10
-
-[Nodes additional API](#nodes-additional-api)
11
-
-[FAST Python visitor](#fastpython-visitor)
12
-
-[Local resolution](#local-resolution)
13
-
- [Shadowing](#shadowing)
14
-
- [Querying local resolver information](#querying-local-resolver-information)
- [Static Single Assignment (SSA)](#static-single-assignment-ssa)
17
17
- [Building](#building)
18
18
- [Exploiting the SSA](#exploiting-the-ssa)
@@ -22,8 +22,8 @@ A general note: When we import an entity, we cannot know if it is a variable, a
22
22
- [Subscript content](#subscript-content)
23
23
- [Instance variables](#instance-variables)
24
24
- [Python 2 VS Python 3](#python-2-vs-python-3)
25
-
- [Global and Non local statement](#global-and-non-local-statement)
26
-
-[API](#api)
25
+
- [Global and Non local statement](#global-and-non-local-statement)
26
+
- [API](#api)
27
27
- [Variables analysis](#variables-analysis)
28
28
- [Knowing what is a variable](#knowing-what-is-a-variable)
29
29
- [Accessing the SSA versions of a variable](#accessing-the-ssa-versions-of-a-variable)
@@ -64,7 +64,7 @@ Some general properties got added such as:
64
64
-`FASTPyMethodDefinition>>isAbstract` to know if a method is abstract
65
65
-`FASTPyMethodDefinition>>selfName` to know the name of the self parameter (will be nil for static methods)
66
66
67
-
For nodes representing a write access to a variable (it is possible to find them easily once we resolved our project with the local resolver or the SSA), we can find the expressions used in their writing by using `#assignedExpressions` on the node doing the assignment, i.e. the `variableDeclarator` of the write access, not on the variable itself.
67
+
For nodes representing a write access to a variable (it is possible to find them easily once we resolved our project with the local resolver or the SSA), we can find the expressions used in their writing by using `#assignedExpressions` on the node doing the assignment, i.e. the `variableDeclaration` of the write access, not on the variable itself.
68
68
69
69
> Note: you can find some warnings on this in the section [Querying local resolver information](#querying-local-resolver-information). They are the same.
70
70
@@ -166,7 +166,7 @@ It is possible to ask a few things to the nodes once the resolution is done:
166
166
-`node allNodesUsingMe` if the node is a variable, returns all the nodes using the variable: for each access of the variable, all its ancestors up to the statement containing it, without going further than the statement blocks (Module, function, method, clauses, ...). For example, for `return x + 3`, it returns the return statement and the binary operation
167
167
-`node statementsUsingMe` if the node is a variable, returns the statements using the variable: same as `allNodesUsingMe` but only the statement of each access, without the intermediate nodes
168
168
-`node callsOnVariable` if the node is a variable, returns the calls made on the variable, i.e. the `FASTPyCall` nodes having the variable as receiver: the callee of the call is the read of the variable itself (such as the invocation or instantiation `x()`) or an internal access on the variable (such as `x.append(1)` or `x[3]()`)
169
-
-`node variableDeclarator` if the node that is a variable write access, it will return the node assigning the variable (can be an assignment, augmented assignment, for loop or for in clause)
169
+
-`node variableDeclaration` if the node that is a variable write access, it will return the node assigning the variable (can be an assignment, augmented assignment, for loop or for in clause)
170
170
171
171
On the model:
172
172
-`model allResolvedVariables` returns all nodes in the model that resolve to a variable declaration. This is a shortcut for querying the model-level view of all resolved variables
@@ -284,9 +284,9 @@ On top of this, it is possible to get information via the SSA directly with the
284
284
### Assigned expressions
285
285
286
286
It is also possible to query what is assigned in variables once the SSA is done:
287
-
-`node variableDeclarator` for a node that is a write access to a variable, it will return the node assigning the variable
287
+
-`node variableDeclaration` for a node that is a write access to a variable, it will return the node assigning the variable
288
288
-`node assignedExpressionsMap` for a variable, return a map of all expressions used to assigned the variable. The keys of the map are the write accesses that can impact the value of this variable. In some cases there will be only one. But if the variable is assigned in a conditional expression, it will get one entry by assignment that can impact the current variable value
289
-
-`node transitiveAssignedExpressions` for a node doing an assignment (the `variableDeclarator` of a write access), returns the expressions used in the assignment and, for each variable used in those expressions, the expressions assigned to that variable, recursively
289
+
-`node transitiveAssignedExpressions` for a node doing an assignment (the `variableDeclaration` of a write access), returns the expressions used in the assignment and, for each variable used in those expressions, the expressions assigned to that variable, recursively
290
290
-`node transitiveAssignedExpressionsMap` for a variable, same as `assignedExpressionsMap` but the values are the transitive assigned expressions of each write access
291
291
292
292
Be carful, `x = 3` is not the only way to assign a variable. Take those cases into account:
@@ -479,7 +479,7 @@ The requirement column indicates what needs to be done on the model before using
479
479
|`allAccesses`| Any access of a variable | LR | Returns all the read and write accesses to the variable |
480
480
|`allReadAccesses`| Any access of a variable | LR | Returns all the read accesses to the variable |
481
481
|`allWriteAccesses`| Any access of a variable | LR | Returns all the write accesses to the variable |
482
-
|`variableDeclarator`| A write access of a variable | LR | Returns the node assigning the variable (assignment, augmented assignment, for loop or for in clause) |
482
+
|`variableDeclaration`| A write access of a variable | LR | Returns the node assigning the variable (assignment, augmented assignment, for loop or for in clause) |
483
483
|`versionAccesses`| Any access of a variable | SSA | Returns the read and write accesses for the current SSA version of the receiver |
484
484
|`versionReadAccesses`| Any access of a variable | SSA | Returns the read accesses for the current SSA version of the receiver |
485
485
|`versionWriteAccesses`| Any access of a variable | SSA | Returns the write accesses for the current SSA version of the receiver |
@@ -511,9 +511,9 @@ The requirement column indicates what needs to be done on the model before using
|`assignedExpressions`| An assignment node (the `variableDeclarator` of a write access) | Vanilla | Returns the expressions used by this assignment. Returns an empty collection on any other node |
514
+
|`assignedExpressions`| An assignment node (the `variableDeclaration` of a write access) | Vanilla | Returns the expressions used by this assignment. Returns an empty collection on any other node |
515
515
|`assignedExpressionsMap`| Any access of a variable | SSA | Returns a map with, as key, each write access impacting the value of the variable, and as value, the expressions used by that assignment |
516
-
|`transitiveAssignedExpressions`| An assignment node (the `variableDeclarator` of a write access) | SSA | Same as `#assignedExpressions` but the variables used in the assigned expressions are followed: the expressions assigned to them are added, recursively |
516
+
|`transitiveAssignedExpressions`| An assignment node (the `variableDeclaration` of a write access) | SSA | Same as `#assignedExpressions` but the variables used in the assigned expressions are followed: the expressions assigned to them are added, recursively |
517
517
|`transitiveAssignedExpressionsMap`| Any access of a variable | SSA | Same as `#assignedExpressionsMap` but each value is the transitive assigned expressions of the corresponding assignment |
The assignments nodes can be an assignment, a for, an augmented assignment or a for in clause.
@@ -644,7 +644,7 @@ It returns a dictionary with the possible write accesses as key and the expressi
644
644
645
645
> Note: you can find some warnings on this in the section [Querying local resolver information](#querying-local-resolver-information). They are the same.
646
646
647
-
> Note 2: You can use `#assignedExpressions` on the `variableDeclarator` of a specific write access to have information only on this one.
647
+
> Note 2: You can use `#assignedExpressions` on the `variableDeclaration` of a specific write access to have information only on this one.
648
648
649
649
**What expressions are transitively used to do the assignment?**
650
650
@@ -665,7 +665,7 @@ model module statements last arguments first transitiveAssignedExpressionsMap
665
665
666
666
The read of `y` is part of the result since `y` is itself assigned `1`.
667
667
668
-
> Note: `#transitiveAssignedExpressions` is the equivalent of `#assignedExpressions`: call it on the `variableDeclarator` of a specific write access to have the transitive expressions of only this one.
668
+
> Note: `#transitiveAssignedExpressions` is the equivalent of `#assignedExpressions`: call it on the `variableDeclaration` of a specific write access to have the transitive expressions of only this one.
0 commit comments