-
Notifications
You must be signed in to change notification settings - Fork 34
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, and included file set.
-
Resolve include specifiers: Recursively resolve include specifiers in tu. Add the path of each included file to the included 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.
-
-
-
Map uses to locations: 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, do the following:
-
Resolve u to a list l of possible qualified names. For example, if u is
c.d
and it appears inside moduleB
which 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.d
appears 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 path p corresponding to q.
-
If p exists and is not in the input file set of a and is not already in the dependency file set of a, then
-
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 this algorithm on the list [ tu ] with the value of a computed so far. Let the result be the new a.
-
-
Otherwise add p to the missing dependency file set of a.
-
-
-
Eliminate included files as dependencies: For each file f in the included file set, if f appears in the dependency file file set, then delete it from the set. The dependency is already recorded in the file that includes f.