summaryrefslogtreecommitdiff
path: root/src/wasm-interpreter.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/wasm-interpreter.h')
-rw-r--r--src/wasm-interpreter.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/wasm-interpreter.h b/src/wasm-interpreter.h
index 5d4e7d7b4..f699ba6f8 100644
--- a/src/wasm-interpreter.h
+++ b/src/wasm-interpreter.h
@@ -554,12 +554,23 @@ public:
}
}
+ // call an exported function
Literal callExport(Name name, LiteralList& arguments) {
Export *export_ = wasm.checkExport(name);
if (!export_) externalInterface->trap("callExport not found");
return callFunction(export_->value, arguments);
}
+ // get an exported global
+ Literal getExport(Name name) {
+ Export *export_ = wasm.checkExport(name);
+ if (!export_) externalInterface->trap("getExport external not found");
+ Name internalName = export_->value;
+ auto iter = globals.find(internalName);
+ if (iter == globals.end()) externalInterface->trap("getExport internal not found");
+ return iter->second;
+ }
+
std::string printFunctionStack() {
std::string ret = "/== (binaryen interpreter stack trace)\n";
for (int i = int(functionStack.size()) - 1; i >= 0; i--) {