Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
interp.cpp File Reference
#include <sysio/vm/backend.hpp>
#include <sysio/vm/error_codes.hpp>
#include <sysio/vm/watchdog.hpp>
#include <iostream>
Include dependency graph for interp.cpp:

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Simple implementation of an interpreter using sys-vm.

Definition at line 13 of file interp.cpp.

13 {
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
Here is the call graph for this function: