After the exposed references have been found, the destination scope must
be updated to include definitions for the objects in the exposed
references. The base_symtab
class provides the
resolve_exposed_refs
method to accomplish this. This method
takes the lists of original objects in the replacements
structure
produced by the find_exposed_refs
method (see section Finding Exposed References) and adds corresponding entries to the lists of new objects.
New symbols are created and added to the symbol table to replace the
originals. Variable definitions are also created as needed.
Because some types use name equivalence, they cannot be copied without
creating different types. Thus, whenever possible, types are moved up
in the symbol table hierarchy so that they are visible in both the
source and destination scopes. If a type is successfully moved, the old
and new entries for the replacements
lists are the same. Some
types contain references to variables (e.g. as array bounds), and if
those variables are not already visible in the destination scope, the
types cannot be moved. When that happens, resolve_exposed_refs
resorts to making a new type where the variable references are updated
to use the cloned variables.