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
{{ message }}
Repository navigation
Commit 6a52249
Browse filesBrowse the repository at this point in the historyBrowse files
-[Knowing what is a variable](#knowing-what-is-a-variable)
27
+
-[Accessing the SSA versions of a variable](#accessing-the-ssa-versions-of-a-variable)
28
+
-[Getting the accesses of a variable](#getting-the-accesses-of-a-variable)
29
+
-[Knowing what uses a variable](#knowing-what-uses-a-variable)
30
+
-[Getting the internal accesses of a variable](#getting-the-internal-accesses-of-a-variable)
31
+
-[Getting the calls on a variable](#getting-the-calls-on-a-variable)
32
+
-[Getting the assigned expressions](#getting-the-assigned-expressions)
24
33
-[Examples of analysis](#examples-of-analysis)
25
34
26
35
## Local resolution
@@ -407,6 +416,77 @@ A node can also be accessed internally, via an attribute access such as `x.y` or
407
416
408
417
TODO: Document more
409
418
419
+
## API
420
+
421
+
This section references the API available to analyse a FASTPython model. For now, FAST-Python was mostly used to analyse variables, so the API is centered on variables analysis.
422
+
423
+
The requirement column indicates what needs to be done on the model before using the selector:
424
+
- Vanilla: nothing, it works on the freshly imported model
425
+
- LR: the local resolution needs to be done
426
+
- SSA: the SSA resolution needs to be done (which includes the local resolution)
|`isResolvedVariable`|`FASTPyEntity`| LR | Returns `true` if the node resolves to a local variable declaration (not an unresolved name, function, method or import) |
435
+
|`usedVariables`|`FASTPyEntity`| LR | Returns all the entities of the node and its subtree resolving to local variable declarations (includes the node itself if it is one) |
436
+
|`allResolvedVariables`|`FASTPyModel`| LR | Returns every entity of the model resolving to a variable declaration |
|`ssaVersion`|`FASTPyEntity` representing a variable | SSA | Returns the current SSA version of the variable. It is a `FASTVariableVersionSSA` or a `FASTVariablePhiVersionSSA` if the value can come from multiple assignments |
443
+
|`allSSAVersions`|`FASTPyEntity` representing a variable | SSA | Returns all the SSA versions the variable can get, including the Phi versions |
444
+
|`allSSABasicVersions`|`FASTPyEntity` representing a variable | SSA | Same as `#allSSAVersions` but without the Phi versions |
|`allAccesses`| Any access of a variable | LR | Returns all the read and write accesses to the variable |
451
+
|`allReadAccesses`| Any access of a variable | LR | Returns all the read accesses to the variable |
452
+
|`allWriteAccesses`| Any access of a variable | LR | Returns all the write accesses to the variable |
453
+
|`variableDeclarator`| A write access of a variable | LR | Returns the node assigning the variable (assignment, augmented assignment, for loop or for in clause) |
454
+
|`versionAccesses`| Any access of a variable | SSA | Returns the read and write accesses for the current SSA version of the receiver |
455
+
|`versionReadAccesses`| Any access of a variable | SSA | Returns the read accesses for the current SSA version of the receiver |
456
+
|`versionWriteAccesses`| Any access of a variable | SSA | Returns the write accesses for the current SSA version of the receiver |
|`allNodesUsingMe`| Any access of a variable | LR | Returns all the nodes using the variable: the ancestors of each of its accesses, up to the statement containing it, without going further than the statement blocks |
463
+
|`statementsUsingMe`| Any access of a variable | LR | Same as `#allNodesUsingMe` but only the statements, without the intermediate nodes |
464
+
|`allNodesUsingMyVersion`| Any access of a variable | SSA | Same as `#allNodesUsingMe` but only with the accesses reachable from the current SSA version |
465
+
|`statementsUsingMyVersion`| Any access of a variable | SSA | Same as `#statementsUsingMe` but only with the accesses reachable from the current SSA version |
|`callsOnVariable`| Any access of a variable | LR | Returns the `FASTPyCall` nodes having the variable as receiver: the callee is the read of the variable itself (invocation or instantiation `x()`) or an internal access on it (`x.append(1)`, `x[3]()`) |
479
+
|`callsOnVariableVersion`| Any access of a variable | SSA | Same as `#callsOnVariable` but only with the reads reachable from the current SSA version |
|`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 |
486
+
|`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 |
487
+
|`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 |
488
+
|`transitiveAssignedExpressionsMap`| Any access of a variable | SSA | Same as `#assignedExpressionsMap` but each value is the transitive assigned expressions of the corresponding assignment |
489
+
410
490
## Examples of analysis
411
491
412
492
In this section I'll show how to answer some questions I was asked to answer with FAST-Python.
0 commit comments