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/wasm-interpreter.h | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'src/wasm-interpreter.h') diff --git a/src/wasm-interpreter.h b/src/wasm-interpreter.h index 086b9751e..381176390 100644 --- a/src/wasm-interpreter.h +++ b/src/wasm-interpreter.h @@ -123,14 +123,26 @@ private: Literal callFunction(IString name, LiteralList& arguments) { class FunctionScope { - public: + public: std::map locals; Function* function; - FunctionScope(Function* function, LiteralList& arguments) : function(function) { - assert(function->params.size() == arguments.size()); + FunctionScope(Function* function, LiteralList& arguments) + : function(function) { + if (function->params.size() != arguments.size()) { + std::cerr << "Function `" << function->name << "` expects " + << function->params.size() << " parameters, got " + << arguments.size() << " arguments." << std::endl; + abort(); + } for (size_t i = 0; i < arguments.size(); i++) { - assert(function->params[i].type == arguments[i].type); + if (function->params[i].type != arguments[i].type) { + std::cerr << "Function `" << function->name << "` expects type " + << printWasmType(function->params[i].type) + << " for parameter " << i << ", got " + << printWasmType(arguments[i].type) << "." << std::endl; + abort(); + } locals[function->params[i].name] = arguments[i]; } for (auto& local : function->locals) { -- cgit v1.2.3