-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwvm.cc
33 lines (27 loc) · 1010 Bytes
/
wvm.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <string>
#include <tuple>
#include "parser.h"
#include "module.h"
#include "decoder.h"
#include "instance.h"
#include "executor.h"
#include "log.h"
int main(int argc, char *argv[])
{
std::string file_name = argv[1];
/** parser module */
std::shared_ptr<wvm::Parser<wvm::Module, wvm::Decoder>> parser_ptr = std::make_shared<wvm::Parser<wvm::Module, wvm::Decoder>>(file_name);
std::shared_ptr<wvm::Module> module_ptr = parser_ptr->parse();
/** instantiate module */
std::shared_ptr<wvm::Instance> instance_ptr = std::make_shared<wvm::Instance>(module_ptr);
std::shared_ptr<wvm::Runtime> runtime_ptr = instance_ptr->instantiate();
/** execute module */
std::shared_ptr<wvm::Executor> executor_ptr = std::make_shared<wvm::Executor>(runtime_ptr);
wvm::Executor::engine_result_t ret = executor_ptr->execute(std::optional<uint32_t>{});
/** print result */
if (ret.has_value())
{
LOG("ret: ", std::get<int>(ret.value()));
}
return 0;
}