mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-03-31 01:11:06 +00:00
Merge pull request #1064 from alexcrichton/wasm2es6js-imports
wasm2es6js: Fix handling of exported imports
This commit is contained in:
commit
fbad34a4cb
@ -58,7 +58,27 @@ pub fn typescript(module: &Module) -> String {
|
|||||||
.unwrap_or(0);
|
.unwrap_or(0);
|
||||||
for entry in i.entries() {
|
for entry in i.entries() {
|
||||||
let idx = match *entry.internal() {
|
let idx = match *entry.internal() {
|
||||||
Internal::Function(i) => i - imported_functions,
|
Internal::Function(i) if i < imported_functions => {
|
||||||
|
*module.import_section()
|
||||||
|
.unwrap()
|
||||||
|
.entries()
|
||||||
|
.iter()
|
||||||
|
.filter_map(|f| {
|
||||||
|
match f.external() {
|
||||||
|
External::Function(i) => Some(i),
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.nth(i as usize)
|
||||||
|
.unwrap()
|
||||||
|
}
|
||||||
|
Internal::Function(i) => {
|
||||||
|
let idx = i - imported_functions;
|
||||||
|
let functions = module
|
||||||
|
.function_section()
|
||||||
|
.expect("failed to find function section");
|
||||||
|
functions.entries()[idx as usize].type_ref()
|
||||||
|
}
|
||||||
Internal::Memory(_) => {
|
Internal::Memory(_) => {
|
||||||
exports.push_str(&format!(
|
exports.push_str(&format!(
|
||||||
"export const {}: WebAssembly.Memory;\n",
|
"export const {}: WebAssembly.Memory;\n",
|
||||||
@ -76,11 +96,6 @@ pub fn typescript(module: &Module) -> String {
|
|||||||
Internal::Global(_) => continue,
|
Internal::Global(_) => continue,
|
||||||
};
|
};
|
||||||
|
|
||||||
let functions = module
|
|
||||||
.function_section()
|
|
||||||
.expect("failed to find function section");
|
|
||||||
let idx = functions.entries()[idx as usize].type_ref();
|
|
||||||
|
|
||||||
let types = module
|
let types = module
|
||||||
.type_section()
|
.type_section()
|
||||||
.expect("failed to find type section");
|
.expect("failed to find type section");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user