The monkey's notes are reprinted. Please indicate the source.
I. Definition
1. Define nodes.Node nε g (P) is the definition node of variable vε v. It is recorded as def (v, n ), if and only when the value of variable V is defined at the statement segment of the corresponding node N.
2. Use nodes.Node n' g (P) is the use node of the variable vε v. It is recorded as use (v, n ), if and only when the value of variable V is used by the statement segment of the corresponding node n.
3. P-use and C-use.Use node use (v, n) is a predicate used (recorded as p-use). if and only when statement N is a predicate statement; otherwise, use (v. n) is used for computing (recorded as C-use ).
4. Define-use path.Definition of variable V-the path used (recorded as Du-path) is the path in paths (P), so that for a certain V in V, the definition and use of node def (V, m) and use (v, n), so that m and n are the initial and final nodes of the path.
5. Define the clear path.The clear path defined for variable V is a paths (p) with the initial and final nodes def (v, m) and use (v, n) so that no other node in the path is defined by V. Ii. Examples. 1. Program snippets
2. flowchart 3. Simplified flowchart 4. definition/use test table
Variable |
Define a node |
Use nodes |
Lockprice |
7 |
24 |
Stockprice |
8 |
25 |
Barrelprice |
9 |
26 |
Totallocks |
10, 16 |
16, 21, 24 |
Totalstocks |
11,17 |
17,22, 25 |
Totalbarrels |
12, 18 |
18, 23, 26 |
Locks |
13,19 |
14,16 |
Stocks |
15 |
17 |
Barrrels |
15 |
18 |
Locksales |
24 |
27 |
Stocksales |
25 |
27 |
Barrelsales |
26 |
27 |
Sales |
27 |
28,29, 33,34, 37,38 |
Commission |
31,32, 33,36, 37,38 |
32, 33, 37, 41 |
5. Define/use path
- Stocks definition-path used
-
- Def (stocks, 15)
- Use (stocks, 17)
- <15, 16, 17> is a definition of stocks-use path. Stock has no other defined nodes, so this path defines the clear path.
- Locks definition-use path
-
- Ldef (locks, 13), Def (locks, 19 );
- Luse (locks, 14) Use (locks16 ).
- P1 = <13,14>
- P2 = <13, 14, 15, 16>
- P3 = <19,20, 14>
- P4 = <19,20, 14,15, 16>
- Definition of total locks-path used
-
- Def (totallocks, 10), Def (totallocks, 16)
- Use (totallocks, 16), use (totallocks21), use (totallocks24 ).
- Six definitions are expected-use path.
- P5 = <, 16> define
P6 = <10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21>
P7 = <, 24>
P7 =
P8 '= <16, 16>
P8 = <16, 17, 18, 19, 14, 20, 21>
P9 = <,>
- Definition of sales-path used
-
- P10 = <27,28>
P11 = <27,28, 29>
P12 = <27,28, 29,30, 31,32, 33>
P13 = <27,28, 29,34>
P14 = <27,28, 29,34, 35,36, 37>
P15 = <27,28, 29,34, 38>
- Definition of Commission-path used