-
Notifications
You must be signed in to change notification settings - Fork 51
Computing Dependencies
This algorithm computes dependencies for a list of translation units.
-
An analysis data structure a. The input file set of a must record the set of files presented for analysis.
-
A list tul of FPP translation units.
-
An analysis data structure a with updated location specifier map, dependency file set, direct dependency file set, and included file set.
Run the dependency algorithm on tul.
To run the dependency algorithm on a translation unit list tul, do the following:
-
Resolve include specifiers: Recursively resolve include specifiers in tul. Add the path of each included file to the included file set in a. If the level of a is zero, then add the path of each included file to the direct dependency file set in a.
-
Build the location specifier map: Traverse each translation unit tu in tul, updating the scope name list as modules are entered and exited. For each location specifier s encountered, do the following:
-
Let k be the symbol kind specified in s. For example, in the specifier
locate constant c at "c.fpp", the symbol kind isconstant. -
Compute the qualified name q associated with s. For example, if the location specifier
locate constant c at "c.fpp"appears inside module M, then q is M.c. -
Check the location specifier map for a mapping from (k, q) to some location specifier s'.
-
If there is no such mapping, then add the mapping from (k, q) to s.
-
Otherwise
-
Compute the absolute path p associated with s. For example, if the location specifier
locate constant c at "c.fpp"appears in the file/home/foo/bar/baz.fpp, then p is/home/foo/bar/c.fpp. -
Compute the absolute path p' associated with s'.
-
If p does not equal p', then throw an error.
-
Check that s and s' are either both dictionary specifiers or both not dictionary specifiers. If not, then throw an error.
-
-
-
Construct the implied use map: Run the algorithm for constructing the implied use map.
-
Add dependencies: Traverse each translation unit tu in tul, updating the scope name list as modules are entered and exited.
-
For each use of a symbol u encountered in tu, including all the implied uses, do the following:
-
Resolve u to a list l of possible qualified names. For example, if u is
c.dand it appears inside moduleBwhich appears inside moduleA, then l isA.B.c.d,A.c.d,c.d. Construct l with the innermost name first. For example,A.B.c.dappears beforeA.c.d. -
For each qualified name q in l, in order starting with the head of l, check the location specifier map of a for a location specifier s corresponding to q.
-
If s exists, then add the dependencies for s.
-
-
For each topology definition T encountered in tu, if this is the first topology seen in dependency checking, then
-
For each location specifier s in the location specifier map, if s specifies
dictionary, then add the dependencies for s. -
Mark in a that we have seen a topology.
-
-
For each location specifier s encountered in tu, if we have seen a topology and s specifies
dictionary, then add the dependencies for s.
-
-
Eliminate included files as dependencies: For each file f in the included file set, if f appears in the dependency file set, then delete it from the set. The dependency is already recorded in the file that includes f.
To add a dependency for a location specifier s, do the following:
-
Compute the absolute path p associated with s.
-
If p is in the input file set of a or is already in the dependency file set of a, then do nothing.
-
Otherwise
-
If the level of a is zero, then add p to the direct dependency file set of a.
-
Add p to the dependency file set of a.
-
If the file f at p exists, then
-
Parse f, generating a translation unit tu.
-
Run the dependency algorithm on the list [ tu ] with the value of a computed so far, but with an empty scope name list. Restore the current level and scope name list and let the result be the new a.
-
-
Otherwise add p to the missing dependency file set of a.
-