summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2018-07-22 00:18:06 +0100
committerAlon Zakai <alonzakai@gmail.com>2018-07-21 16:18:06 -0700
commit5852b13a30d00a6b40683a1e3a8760dacd520ee0 (patch)
tree199072158be56bfb32e171d275042ee78e527e99
parent7db96b6d0c93e3b92b396169506b5fd4f14a7dd3 (diff)
downloadbinaryen-5852b13a30d00a6b40683a1e3a8760dacd520ee0.tar.gz
binaryen-5852b13a30d00a6b40683a1e3a8760dacd520ee0.tar.bz2
binaryen-5852b13a30d00a6b40683a1e3a8760dacd520ee0.zip
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)).
-rw-r--r--src/wasm-interpreter.h11
1 files changed, 5 insertions, 6 deletions
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<Literal> 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 "