mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-03-31 01:11:06 +00:00
Remove nodejs-checking logic from math exports
Instead create a temporary vector which is used to later invoke the generic `export` function
This commit is contained in:
parent
62e9f580d0
commit
de3a7e3242
@ -314,6 +314,15 @@ impl<'a> Context<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn rewrite_imports(&mut self, module_name: &str) {
|
fn rewrite_imports(&mut self, module_name: &str) {
|
||||||
|
for (name, contents) in self._rewrite_imports(module_name) {
|
||||||
|
self.export(&name, &contents);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn _rewrite_imports(&mut self, module_name: &str)
|
||||||
|
-> Vec<(String, String)>
|
||||||
|
{
|
||||||
|
let mut math_imports = Vec::new();
|
||||||
let imports = self.module.sections_mut()
|
let imports = self.module.sections_mut()
|
||||||
.iter_mut()
|
.iter_mut()
|
||||||
.filter_map(|s| {
|
.filter_map(|s| {
|
||||||
@ -336,19 +345,12 @@ impl<'a> Context<'a> {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut globals = &mut self.globals;
|
|
||||||
let renamed_import = format!("__wbindgen_{}", import.field());
|
let renamed_import = format!("__wbindgen_{}", import.field());
|
||||||
let node = self.config.nodejs;
|
|
||||||
let mut bind_math = |expr: &str| {
|
let mut bind_math = |expr: &str| {
|
||||||
if node {
|
math_imports.push((
|
||||||
globals.push_str(&format!("
|
renamed_import.clone(),
|
||||||
exports.{} = function{};
|
format!("function{}", expr),
|
||||||
", renamed_import, expr));
|
));
|
||||||
} else {
|
|
||||||
globals.push_str(&format!("
|
|
||||||
export function {}{}
|
|
||||||
", renamed_import, expr));
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// FIXME(#32): try to not use function shims
|
// FIXME(#32): try to not use function shims
|
||||||
@ -395,6 +397,8 @@ impl<'a> Context<'a> {
|
|||||||
import.module_mut().push_str(module_name);
|
import.module_mut().push_str(module_name);
|
||||||
*import.field_mut() = renamed_import.clone();
|
*import.field_mut() = renamed_import.clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
math_imports
|
||||||
}
|
}
|
||||||
|
|
||||||
fn unexport_unused_internal_exports(&mut self) {
|
fn unexport_unused_internal_exports(&mut self) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user