MCPcopy Create free account
hub / github.com/WasmVM/WasmVM / reg_func

Function reg_func

host/sysenv/sysenv.cpp:102–123  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

100// ---- reg_func helper --------------------------------------------------------
101
102void 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

Callers 2

sys_fs_instanciateFunction · 0.85
sys_proc_instanciateFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected