#include <fstream>
#include <iostream>
#include <sstream>
using namespace wasmtime;
std::string readFile(const char *name) {
std::ifstream watFile;
watFile.open(name);
std::stringstream strStream;
strStream << watFile.rdbuf();
return strStream.str();
}
int main() {
auto module = Module::compile(engine, readFile("examples/gcd.wat")).unwrap();
auto instance = Instance::create(store, module, {}).unwrap();
auto gcd = std::get<Func>(*instance.get(store, "gcd"));
auto results = gcd.call(store, {6, 27}).unwrap();
std::cout << "gcd(6, 27) = " << results[0].i32() << "\n";
}
Global compilation state in Wasmtime.
Definition: wasmtime.hh:645
Owner of all WebAssembly objects.
Definition: wasmtime.hh:1820