| 100 | // ---- reg_func helper -------------------------------------------------------- |
| 101 | |
| 102 | void reg_func( |
| 103 | ModuleInst& moduleinst, |
| 104 | Store& store, |
| 105 | const std::string& name, |
| 106 | std::initializer_list<ValueType> params, |
| 107 | std::initializer_list<ValueType> results, |
| 108 | hostfunc_t fn) |
| 109 | { |
| 110 | index_t addr = store.funcs.size(); |
| 111 | moduleinst.funcaddrs.emplace_back(addr); |
| 112 | |
| 113 | FuncInst& fi = store.funcs.emplace_back(moduleinst); |
| 114 | fi.module = moduleinst; |
| 115 | for(ValueType vt : params) fi.type.params.emplace_back(vt); |
| 116 | for(ValueType vt : results) fi.type.results.emplace_back(vt); |
| 117 | fi.body.emplace<hostfunc_t>(fn); |
| 118 | |
| 119 | ExportInst& ex = moduleinst.exports.emplace_back(); |
| 120 | ex.name = name; |
| 121 | ex.value.type = ExternVal::ExternType::Func; |
| 122 | ex.value.addr = addr; |
| 123 | } |
| 124 | |
| 125 | // ---- Top-level entry point -------------------------------------------------- |
| 126 |
no outgoing calls
no test coverage detected