From c0c40ceaf1c5e2c4fc966b36ec04592e6c67979f Mon Sep 17 00:00:00 2001 From: JF Bastien Date: Tue, 2 Feb 2016 05:51:04 -0800 Subject: Shell: fix --entry parameter numbers When running the shell with --entry it was assumed that the signature had zero parameters. This isn't true for main, so look at the function's parameter list and construct a zero-initialized arguments vector of the right types. This fixes a few failures, some of which were hiding other failures. --- src/binaryen-shell.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src/binaryen-shell.cpp') diff --git a/src/binaryen-shell.cpp b/src/binaryen-shell.cpp index 96f76fa95..08634c41a 100644 --- a/src/binaryen-shell.cpp +++ b/src/binaryen-shell.cpp @@ -183,10 +183,18 @@ static void run_asserts(size_t* i, bool* checked, AllocatingModule* wasm, auto interface = new ShellExternalInterface(); auto instance = new ModuleInstance(*wasm, interface); if (entry.is() > 0) { - ModuleInstance::LiteralList arguments; - try { - instance->callExport(entry, arguments); - } catch (ExitException& x) { + Function* function = wasm->functionsMap[entry]; + if (!function) { + std::cerr << "Unknown entry " << entry << std::endl; + } else { + ModuleInstance::LiteralList arguments; + for (NameType param : function->params) { + arguments.push_back(Literal(param.type)); + } + try { + instance->callExport(entry, arguments); + } catch (ExitException& x) { + } } } while (*i < root->size()) { -- cgit v1.2.3