diff options
author | Alon Zakai <alonzakai@gmail.com> | 2015-11-03 11:51:41 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2015-11-03 11:51:41 -0800 |
commit | 5b30873eb082df02a79e7daa2f3aa8b59dab358a (patch) | |
tree | bcc760e939af63502508709b182018d63b2085f4 /src/wasm-interpreter.h | |
parent | 8555bd445598fdcba593eef3fc4bd5e527b19068 (diff) | |
download | binaryen-5b30873eb082df02a79e7daa2f3aa8b59dab358a.tar.gz binaryen-5b30873eb082df02a79e7daa2f3aa8b59dab358a.tar.bz2 binaryen-5b30873eb082df02a79e7daa2f3aa8b59dab358a.zip |
comments
Diffstat (limited to 'src/wasm-interpreter.h')
-rw-r--r-- | src/wasm-interpreter.h | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/src/wasm-interpreter.h b/src/wasm-interpreter.h index 82e791389..95dce9e7a 100644 --- a/src/wasm-interpreter.h +++ b/src/wasm-interpreter.h @@ -1,6 +1,7 @@ - +// // Simple WebAssembly interpreter, designed to be embeddable in JavaScript, so it // can function as a polyfill. +// #include "wasm.h" @@ -16,6 +17,11 @@ class ModuleInstance { public: typedef std::vector<Literal> LiteralList; + // + // You need to implement one of these to create a concrete interpreter. The + // ExternalInterface provides embedding-specific functionality like calling + // an imported function or accessing memory. + // struct ExternalInterface { virtual Literal callImport(Import* import, LiteralList& arguments) = 0; virtual Literal load(Load* load, Literal ptr) = 0; @@ -28,15 +34,15 @@ public: } } - Literal callFunction(IString name) { - LiteralList empty; - return callFunction(name, empty); - } - #ifdef WASM_INTERPRETER_DEBUG int indent = 0; #endif + // + // Calls a function. This can be used both internally (calls from + // the interpreter to another method), or when you want to call into + // the module. + // Literal callFunction(IString name, LiteralList& arguments) { class FunctionScope { @@ -365,6 +371,12 @@ public: return ExpressionRunner(*this, scope).visit(function->body).value; } + // Convenience method, for the case where you have no arguments. + Literal callFunction(IString name) { + LiteralList empty; + return callFunction(name, empty); + } + std::map<IString, Function*> functions; private: |