Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
interp.cpp
Go to the documentation of this file.
1#include <sysio/vm/backend.hpp>
2#include <sysio/vm/error_codes.hpp>
3#include <sysio/vm/watchdog.hpp>
4
5#include <iostream>
6
7using namespace sysio;
8using namespace sysio::vm;
9
13int main(int argc, char** argv) {
14 // Thread specific `allocator` used for wasm linear memory.
16
17 if (argc < 2) {
18 std::cerr << "Error, no wasm file provided\n";
19 return -1;
20 }
21
22 std::string filename = argv[1];
23
24 watchdog wd{std::chrono::seconds(3)};
25
26 try {
27 // Read the wasm into memory.
28 auto code = read_wasm( filename );
29
30 // Instaniate a new backend using the wasm provided.
32
33 // Execute any exported functions provided by the wasm.
35
36 } catch ( const sysio::vm::exception& ex ) {
37 std::cerr << "sys-vm interpreter error\n";
38 std::cerr << ex.what() << " : " << ex.detail() << "\n";
39 }
40 return 0;
41}
wasm_allocator wa
Definition main.cpp:10
void execute_all(Watchdog &&wd, host_t &host)
Definition backend.hpp:219
Triggers a callback after a given time elapses.
Definition watchdog.hpp:13
backend_t bkend(hello_wasm, ehm, &wa)
watchdog wd
char ** argv
std::vector< uint8_t > read_wasm(const std::string &fname)
Definition utils.hpp:30
virtual const char * what() const =0
virtual const char * detail() const =0