mirror of
https://github.com/gfx-rs/wgpu.git
synced 2025-12-08 21:26:17 +00:00
[naga] Create a helper for adjust_doc_comments
This commit is contained in:
parent
aa427de4ea
commit
611a2bbede
@ -6,8 +6,11 @@ mod types;
|
|||||||
|
|
||||||
use alloc::vec::Vec;
|
use alloc::vec::Vec;
|
||||||
|
|
||||||
use crate::arena::HandleSet;
|
use crate::{
|
||||||
use crate::{arena, compact::functions::FunctionTracer};
|
arena::{self, HandleSet},
|
||||||
|
compact::functions::FunctionTracer,
|
||||||
|
ir,
|
||||||
|
};
|
||||||
use handle_set_map::HandleMap;
|
use handle_set_map::HandleMap;
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
@ -272,41 +275,10 @@ pub fn compact(module: &mut crate::Module) {
|
|||||||
module_map.global_expressions.adjust(init);
|
module_map.global_expressions.adjust(init);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Adjust doc comments
|
// Adjust doc comments
|
||||||
if let Some(ref mut doc_comments) = module.doc_comments {
|
if let Some(ref mut doc_comments) = module.doc_comments {
|
||||||
let crate::DocComments {
|
module_map.adjust_doc_comments(doc_comments.as_mut());
|
||||||
module: _,
|
|
||||||
types: ref mut doc_comments_for_types,
|
|
||||||
struct_members: ref mut doc_comments_for_struct_members,
|
|
||||||
entry_points: _,
|
|
||||||
functions: _,
|
|
||||||
constants: ref mut doc_comments_for_constants,
|
|
||||||
global_variables: _,
|
|
||||||
} = **doc_comments;
|
|
||||||
log::trace!("adjusting doc comments for types");
|
|
||||||
for (mut ty, doc_comment) in core::mem::take(doc_comments_for_types) {
|
|
||||||
if !module_map.types.used(ty) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
module_map.types.adjust(&mut ty);
|
|
||||||
doc_comments_for_types.insert(ty, doc_comment);
|
|
||||||
}
|
|
||||||
log::trace!("adjusting doc comments for struct members");
|
|
||||||
for ((mut ty, index), doc_comment) in core::mem::take(doc_comments_for_struct_members) {
|
|
||||||
if !module_map.types.used(ty) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
module_map.types.adjust(&mut ty);
|
|
||||||
doc_comments_for_struct_members.insert((ty, index), doc_comment);
|
|
||||||
}
|
|
||||||
log::trace!("adjusting doc comments for constants");
|
|
||||||
for (mut constant, doc_comment) in core::mem::take(doc_comments_for_constants) {
|
|
||||||
if !module_map.constants.used(constant) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
module_map.constants.adjust(&mut constant);
|
|
||||||
doc_comments_for_constants.insert(constant, doc_comment);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Temporary storage to help us reuse allocations of existing
|
// Temporary storage to help us reuse allocations of existing
|
||||||
@ -516,6 +488,42 @@ impl ModuleMap {
|
|||||||
self.types.adjust(handle);
|
self.types.adjust(handle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn adjust_doc_comments(&self, doc_comments: &mut ir::DocComments) {
|
||||||
|
let crate::DocComments {
|
||||||
|
module: _,
|
||||||
|
types: ref mut doc_comments_for_types,
|
||||||
|
struct_members: ref mut doc_comments_for_struct_members,
|
||||||
|
entry_points: _,
|
||||||
|
functions: _,
|
||||||
|
constants: ref mut doc_comments_for_constants,
|
||||||
|
global_variables: _,
|
||||||
|
} = *doc_comments;
|
||||||
|
log::trace!("adjusting doc comments for types");
|
||||||
|
for (mut ty, doc_comment) in core::mem::take(doc_comments_for_types) {
|
||||||
|
if !self.types.used(ty) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
self.types.adjust(&mut ty);
|
||||||
|
doc_comments_for_types.insert(ty, doc_comment);
|
||||||
|
}
|
||||||
|
log::trace!("adjusting doc comments for struct members");
|
||||||
|
for ((mut ty, index), doc_comment) in core::mem::take(doc_comments_for_struct_members) {
|
||||||
|
if !self.types.used(ty) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
self.types.adjust(&mut ty);
|
||||||
|
doc_comments_for_struct_members.insert((ty, index), doc_comment);
|
||||||
|
}
|
||||||
|
log::trace!("adjusting doc comments for constants");
|
||||||
|
for (mut constant, doc_comment) in core::mem::take(doc_comments_for_constants) {
|
||||||
|
if !self.constants.used(constant) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
self.constants.adjust(&mut constant);
|
||||||
|
doc_comments_for_constants.insert(constant, doc_comment);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct FunctionMap {
|
struct FunctionMap {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user