Struct naga::front::wgsl::index::DependencySolver

source ·
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.

Implementations§

source§

impl<'a> DependencySolver<'a, '_>

source

fn solve(self) -> Result<Vec<Handle<GlobalDecl<'a>>>, Error<'a>>

Produce the sorted list of declaration handles, and check for cycles.

source

fn dfs(&mut self, id: Handle<GlobalDecl<'a>>) -> Result<(), Error<'a>>

Ensure that all declarations used by id have been added to the ordering, and then append id itself.

Auto Trait Implementations§

§

impl<'source, 'temp> Freeze for DependencySolver<'source, 'temp>

§

impl<'source, 'temp> RefUnwindSafe for DependencySolver<'source, 'temp>

§

impl<'source, 'temp> Send for DependencySolver<'source, 'temp>

§

impl<'source, 'temp> Sync for DependencySolver<'source, 'temp>

§

impl<'source, 'temp> Unpin for DependencySolver<'source, 'temp>

§

impl<'source, 'temp> UnwindSafe for DependencySolver<'source, 'temp>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.