mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-23 17:51:33 +00:00
Use delete_typed
to improve some ergonomics
This commit is contained in:
@ -475,24 +475,22 @@ impl<'a> Context<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut descriptor_section = None;
|
if let Some(custom) = self
|
||||||
for (id, section) in self.module.customs.iter_mut() {
|
.module
|
||||||
let custom = match section
|
.customs
|
||||||
.as_any_mut()
|
.delete_typed::<WasmBindgenDescriptorsSection>()
|
||||||
.downcast_mut::<WasmBindgenDescriptorsSection>()
|
|
||||||
{
|
{
|
||||||
Some(s) => s,
|
let WasmBindgenDescriptorsSection {
|
||||||
None => continue,
|
descriptors,
|
||||||
};
|
closure_imports,
|
||||||
descriptor_section = Some(id);
|
} = *custom;
|
||||||
|
|
||||||
// Store all the executed descriptors in our own field so we have
|
// Store all the executed descriptors in our own field so we have
|
||||||
// access to them while processing programs.
|
// access to them while processing programs.
|
||||||
self.descriptors.extend(custom.descriptors.drain());
|
self.descriptors.extend(descriptors);
|
||||||
|
|
||||||
// Register all the injected closure imports as that they're expected
|
// Register all the injected closure imports as that they're expected
|
||||||
// to manufacture a particular type of closure.
|
// to manufacture a particular type of closure.
|
||||||
for (id, descriptor) in custom.closure_imports.drain() {
|
for (id, descriptor) in closure_imports {
|
||||||
self.aux
|
self.aux
|
||||||
.import_map
|
.import_map
|
||||||
.insert(id, AuxImport::Closure(descriptor));
|
.insert(id, AuxImport::Closure(descriptor));
|
||||||
@ -506,9 +504,6 @@ impl<'a> Context<'a> {
|
|||||||
.insert(id, ImportBinding::Function(binding));
|
.insert(id, ImportBinding::Function(binding));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let Some(id) = descriptor_section {
|
|
||||||
self.module.customs.delete(id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn program(&mut self, program: decode::Program<'a>) -> Result<(), Error> {
|
fn program(&mut self, program: decode::Program<'a>) -> Result<(), Error> {
|
||||||
|
Reference in New Issue
Block a user