mirror of
https://github.com/fluencelabs/parity-wasm
synced 2025-05-29 07:31:54 +00:00
only function imports should be excluded from function_index
This commit is contained in:
parent
1b8ecf11a5
commit
bd0c0f70e7
@ -3,7 +3,8 @@ extern crate parity_wasm;
|
||||
use std::env::args;
|
||||
|
||||
use parity_wasm::{interpreter, ModuleInstanceInterface, RuntimeValue};
|
||||
use parity_wasm::elements::{Internal, Type, FunctionType, ValueType};
|
||||
use parity_wasm::elements::{Internal, External, Type, FunctionType, ValueType};
|
||||
|
||||
|
||||
fn main() {
|
||||
let args: Vec<_> = args().collect();
|
||||
@ -37,9 +38,14 @@ fn main() {
|
||||
_ => panic!("Founded export is not a function"),
|
||||
};
|
||||
let import_section_len: usize = match module.import_section() {
|
||||
Some(import) => import.entries().len(),
|
||||
Some(import) =>
|
||||
import.entries().iter().filter(|entry| match entry.external() {
|
||||
&External::Function(_) => true,
|
||||
_ => false,
|
||||
}).collect::<Vec<_>>().len(),
|
||||
None => 0,
|
||||
};
|
||||
println!("{:?}", import_section_len);
|
||||
|
||||
let function_index_in_section = function_index - import_section_len;
|
||||
let func_type_ref: usize = function_section.entries()[function_index_in_section].type_ref() as usize;
|
||||
|
Loading…
x
Reference in New Issue
Block a user