struct DependencySolver<'source, 'temp> {
globals: &'temp FastHashMap<&'source str, Handle<GlobalDecl<'source>>>,
module: &'temp TranslationUnit<'source>,
visited: Vec<bool>,
temp_visited: Vec<bool>,
path: Vec<ResolvedDependency<'source>>,
out: Vec<Handle<GlobalDecl<'source>>>,
}
Expand description
Local state for ordering a TranslationUnit
’s module-scope declarations.
Values of this type are used temporarily by Index::generate
to perform a depth-first sort on the declarations.
Technically, what we want is a topological sort, but a depth-first sort
has one key benefit - it’s much more efficient in storing
the path of each node for error generation.
Fields§
§globals: &'temp FastHashMap<&'source str, Handle<GlobalDecl<'source>>>
A map from module-scope definitions’ names to their handles.
module: &'temp TranslationUnit<'source>
The translation unit whose declarations we’re ordering.
visited: Vec<bool>
For each handle, whether we have pushed it onto out
yet.
temp_visited: Vec<bool>
For each handle, whether it is an predecessor in the current depth-first traversal. This is used to detect cycles in the reference graph.
path: Vec<ResolvedDependency<'source>>
The current path in our depth-first traversal. Used for generating error messages for non-trivial reference cycles.
out: Vec<Handle<GlobalDecl<'source>>>
The list of declaration handles, with declarations before uses.