import_function

This commit is contained in:
Svyatoslav Nikolsky
2017-05-03 09:09:41 +03:00
parent a39112a940
commit 8f2409d4ab
6 changed files with 54 additions and 3 deletions

View File

@ -178,7 +178,8 @@ impl ModuleInstance {
match self.imports.parse_function_index(index) {
ItemIndex::IndexSpace(_) => unreachable!("parse_function_index resolves IndexSpace option"),
ItemIndex::Internal(index) => self.call_internal_function(outer, index, None),
ItemIndex::External(index) => self.module.import_section()
ItemIndex::External(index) =>
self.module.import_section()
.ok_or(Error::Function(format!("trying to access external function with index {} in module without import section", index)))
.and_then(|s| s.entries().get(index as usize)
.ok_or(Error::Function(format!("trying to access external function with index {} in module with {}-entries import section", index, s.entries().len()))))