From 5852b13a30d00a6b40683a1e3a8760dacd520ee0 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Sun, 22 Jul 2018 00:18:06 +0100 Subject: Mark arguments const in callExport (#1626) The arguments is read only and therefore could be const. The immediate benefit is callers do not need to define it as a local variable (see Literal callExport(Name name)). --- src/wasm-interpreter.h | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/wasm-interpreter.h b/src/wasm-interpreter.h index d1aab7ab6..a2c4aad43 100644 --- a/src/wasm-interpreter.h +++ b/src/wasm-interpreter.h @@ -649,15 +649,14 @@ public: } // call an exported function - Literal callExport(Name name, LiteralList& arguments) { + Literal callExport(Name name, const LiteralList& arguments) { Export *export_ = wasm.getExportOrNull(name); if (!export_) externalInterface->trap("callExport not found"); return callFunction(export_->value, arguments); } Literal callExport(Name name) { - LiteralList arguments; - return callExport(name, arguments); + return callExport(name, LiteralList()); } // get an exported global @@ -689,7 +688,7 @@ private: public: // Call a function, starting an invocation. - Literal callFunction(Name name, LiteralList& arguments) { + Literal callFunction(Name name, const LiteralList& arguments) { // if the last call ended in a jump up the stack, it might have left stuff for us to clean up here callDepth = 0; functionStack.clear(); @@ -697,14 +696,14 @@ public: } // Internal function call. Must be public so that callTable implementations can use it (refactor?) - Literal callFunctionInternal(Name name, LiteralList& arguments) { + Literal callFunctionInternal(Name name, const LiteralList& arguments) { class FunctionScope { public: std::vector locals; Function* function; - FunctionScope(Function* function, LiteralList& arguments) + FunctionScope(Function* function, const LiteralList& arguments) : function(function) { if (function->params.size() != arguments.size()) { std::cerr << "Function `" << function->name << "` expects " -- cgit v1.2.3