/src/WasmEdge/include/runtime/instance/component/component.h
Line | Count | Source |
1 | | // SPDX-License-Identifier: Apache-2.0 |
2 | | // SPDX-FileCopyrightText: 2019-2024 Second State INC |
3 | | |
4 | | //===-- wasmedge/runtime/instance/component.h - Component Instance definition // |
5 | | // |
6 | | // Part of the WasmEdge Project. |
7 | | // |
8 | | //===----------------------------------------------------------------------===// |
9 | | /// |
10 | | /// \file |
11 | | /// This file contains the component instance definition. |
12 | | /// |
13 | | //===----------------------------------------------------------------------===// |
14 | | #pragma once |
15 | | |
16 | | #include "ast/component/component.h" |
17 | | #include "ast/module.h" |
18 | | #include "ast/type.h" |
19 | | #include "common/errcode.h" |
20 | | #include "common/types.h" |
21 | | #include "runtime/instance/component/function.h" |
22 | | #include "runtime/instance/component/hostfunc.h" |
23 | | #include "runtime/instance/module.h" |
24 | | |
25 | | #include <atomic> |
26 | | #include <functional> |
27 | | #include <map> |
28 | | #include <memory> |
29 | | #include <string> |
30 | | #include <type_traits> |
31 | | #include <vector> |
32 | | |
33 | | namespace WasmEdge { |
34 | | namespace Runtime { |
35 | | namespace Instance { |
36 | | |
37 | | class ComponentInstance; |
38 | | |
39 | | class ComponentImportManager { |
40 | | // The import manager is used for supplying the imports to local instantiate |
41 | | // child components and core modules. |
42 | | public: |
43 | | // Export component func with name into this import manager. |
44 | | void exportFunction(std::string_view Name, |
45 | 0 | Component::FunctionInstance *Inst) noexcept { |
46 | 0 | NamedFunc.emplace(Name, Inst); |
47 | 0 | } |
48 | | |
49 | | // Export component instance with name into this import manager. |
50 | | void exportComponentInstance(std::string_view Name, |
51 | 0 | const ComponentInstance *Inst) noexcept { |
52 | 0 | NamedCompInst.emplace(Name, Inst); |
53 | 0 | } |
54 | | |
55 | | // Export core function instance with name into this import manager. |
56 | | void exportCoreFunctionInstance(std::string_view Name, |
57 | 0 | FunctionInstance *Inst) noexcept { |
58 | 0 | NamedCoreFunc.emplace(Name, Inst); |
59 | 0 | } |
60 | | |
61 | | // Export core table instance with name into this import manager. |
62 | | void exportCoreTableInstance(std::string_view Name, |
63 | 0 | TableInstance *Inst) noexcept { |
64 | 0 | NamedCoreTable.emplace(Name, Inst); |
65 | 0 | } |
66 | | |
67 | | // Export core memory instance with name into this import manager. |
68 | | void exportCoreMemoryInstance(std::string_view Name, |
69 | 0 | MemoryInstance *Inst) noexcept { |
70 | 0 | NamedCoreMemory.emplace(Name, Inst); |
71 | 0 | } |
72 | | |
73 | | // Export core global instance with name into this import manager. |
74 | | void exportCoreGlobalInstance(std::string_view Name, |
75 | 0 | GlobalInstance *Inst) noexcept { |
76 | 0 | NamedCoreGlobal.emplace(Name, Inst); |
77 | 0 | } |
78 | | |
79 | | // Export core module instance with name into this import manager. |
80 | | void exportCoreModuleInstance(std::string_view Name, |
81 | 0 | const ModuleInstance *Inst) noexcept { |
82 | 0 | NamedCoreModInst.emplace(Name, Inst); |
83 | 0 | } |
84 | | |
85 | | // Find component func by name. |
86 | | Component::FunctionInstance * |
87 | 0 | findFunction(std::string_view Name) const noexcept { |
88 | 0 | return findExport(NamedFunc, Name); |
89 | 0 | } |
90 | | |
91 | | // Find component instance by name. |
92 | | const ComponentInstance * |
93 | 0 | findComponentInstance(std::string_view Name) const noexcept { |
94 | 0 | return findExport(NamedCompInst, Name); |
95 | 0 | } |
96 | | |
97 | | // Find core function instance by name. |
98 | | FunctionInstance * |
99 | 0 | findCoreFunctionInstance(std::string_view Name) const noexcept { |
100 | 0 | return findExport(NamedCoreFunc, Name); |
101 | 0 | } |
102 | | |
103 | | // Find core table instance by name. |
104 | 0 | TableInstance *findCoreTableInstance(std::string_view Name) const noexcept { |
105 | 0 | return findExport(NamedCoreTable, Name); |
106 | 0 | } |
107 | | |
108 | | // Find core memory instance by name. |
109 | 0 | MemoryInstance *findCoreMemoryInstance(std::string_view Name) const noexcept { |
110 | 0 | return findExport(NamedCoreMemory, Name); |
111 | 0 | } |
112 | | |
113 | | // Find core global instance by name. |
114 | 0 | GlobalInstance *findCoreGlobalInstance(std::string_view Name) const noexcept { |
115 | 0 | return findExport(NamedCoreGlobal, Name); |
116 | 0 | } |
117 | | |
118 | | // Find core module instance by name. |
119 | | const ModuleInstance * |
120 | 0 | findCoreModuleInstance(std::string_view Name) const noexcept { |
121 | 0 | return findExport(NamedCoreModInst, Name); |
122 | 0 | } |
123 | | |
124 | | // Reset the import manager. |
125 | 0 | void reset() noexcept { |
126 | 0 | NamedFunc.clear(); |
127 | 0 | NamedCompInst.clear(); |
128 | 0 | NamedCoreFunc.clear(); |
129 | 0 | NamedCoreTable.clear(); |
130 | 0 | NamedCoreMemory.clear(); |
131 | 0 | NamedCoreGlobal.clear(); |
132 | 0 | NamedCoreModInst.clear(); |
133 | 0 | } |
134 | | |
135 | | private: |
136 | | // Find export template. |
137 | | template <typename T> |
138 | | T *findExport(const std::map<std::string, T *, std::less<>> &Map, |
139 | 0 | std::string_view ExtName) const noexcept { |
140 | 0 | auto Iter = Map.find(ExtName); |
141 | 0 | if (likely(Iter != Map.cend())) { |
142 | 0 | return Iter->second; |
143 | 0 | } |
144 | 0 | return nullptr; |
145 | 0 | } Unexecuted instantiation: WasmEdge::Runtime::Instance::Component::FunctionInstance* WasmEdge::Runtime::Instance::ComponentImportManager::findExport<WasmEdge::Runtime::Instance::Component::FunctionInstance>(std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, WasmEdge::Runtime::Instance::Component::FunctionInstance*, std::__1::less<void>, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, WasmEdge::Runtime::Instance::Component::FunctionInstance*> > > const&, std::__1::basic_string_view<char, std::__1::char_traits<char> >) const Unexecuted instantiation: WasmEdge::Runtime::Instance::ComponentInstance const* WasmEdge::Runtime::Instance::ComponentImportManager::findExport<WasmEdge::Runtime::Instance::ComponentInstance const>(std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, WasmEdge::Runtime::Instance::ComponentInstance const*, std::__1::less<void>, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, WasmEdge::Runtime::Instance::ComponentInstance const*> > > const&, std::__1::basic_string_view<char, std::__1::char_traits<char> >) const Unexecuted instantiation: WasmEdge::Runtime::Instance::FunctionInstance* WasmEdge::Runtime::Instance::ComponentImportManager::findExport<WasmEdge::Runtime::Instance::FunctionInstance>(std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, WasmEdge::Runtime::Instance::FunctionInstance*, std::__1::less<void>, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, WasmEdge::Runtime::Instance::FunctionInstance*> > > const&, std::__1::basic_string_view<char, std::__1::char_traits<char> >) const Unexecuted instantiation: WasmEdge::Runtime::Instance::TableInstance* WasmEdge::Runtime::Instance::ComponentImportManager::findExport<WasmEdge::Runtime::Instance::TableInstance>(std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, WasmEdge::Runtime::Instance::TableInstance*, std::__1::less<void>, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, WasmEdge::Runtime::Instance::TableInstance*> > > const&, std::__1::basic_string_view<char, std::__1::char_traits<char> >) const Unexecuted instantiation: WasmEdge::Runtime::Instance::MemoryInstance* WasmEdge::Runtime::Instance::ComponentImportManager::findExport<WasmEdge::Runtime::Instance::MemoryInstance>(std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, WasmEdge::Runtime::Instance::MemoryInstance*, std::__1::less<void>, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, WasmEdge::Runtime::Instance::MemoryInstance*> > > const&, std::__1::basic_string_view<char, std::__1::char_traits<char> >) const Unexecuted instantiation: WasmEdge::Runtime::Instance::GlobalInstance* WasmEdge::Runtime::Instance::ComponentImportManager::findExport<WasmEdge::Runtime::Instance::GlobalInstance>(std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, WasmEdge::Runtime::Instance::GlobalInstance*, std::__1::less<void>, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, WasmEdge::Runtime::Instance::GlobalInstance*> > > const&, std::__1::basic_string_view<char, std::__1::char_traits<char> >) const Unexecuted instantiation: WasmEdge::Runtime::Instance::ModuleInstance const* WasmEdge::Runtime::Instance::ComponentImportManager::findExport<WasmEdge::Runtime::Instance::ModuleInstance const>(std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, WasmEdge::Runtime::Instance::ModuleInstance const*, std::__1::less<void>, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, WasmEdge::Runtime::Instance::ModuleInstance const*> > > const&, std::__1::basic_string_view<char, std::__1::char_traits<char> >) const |
146 | | |
147 | | // Export with name for the index spaces. |
148 | | std::map<std::string, Component::FunctionInstance *, std::less<>> NamedFunc; |
149 | | // TODO: NamedValue |
150 | | // TODO: NamedType |
151 | | std::map<std::string, const ComponentInstance *, std::less<>> NamedCompInst; |
152 | | // TODO: NamedComp |
153 | | std::map<std::string, FunctionInstance *, std::less<>> NamedCoreFunc; |
154 | | std::map<std::string, TableInstance *, std::less<>> NamedCoreTable; |
155 | | std::map<std::string, MemoryInstance *, std::less<>> NamedCoreMemory; |
156 | | std::map<std::string, GlobalInstance *, std::less<>> NamedCoreGlobal; |
157 | | // TODO: NamedCoreType |
158 | | std::map<std::string, const ModuleInstance *, std::less<>> NamedCoreModInst; |
159 | | // TODO: NamedCoreMod |
160 | | }; |
161 | | |
162 | | class ComponentInstance { |
163 | | // The component instance class is not only for the runtime data structure, |
164 | | // but also for the instantiation context according to the linking isolation |
165 | | // and the module and component type declarations. |
166 | | public: |
167 | 0 | ComponentInstance(std::string_view Name) : CompName(Name) {} |
168 | | |
169 | | // Getter of the component name. |
170 | 0 | std::string_view getComponentName() const noexcept { return CompName; } |
171 | | |
172 | | // Instantiation finalizer. Should clean up all instantiation time data. |
173 | 0 | void finishInstantiation() noexcept { |
174 | 0 | Comps.clear(); |
175 | 0 | CoreMods.clear(); |
176 | 0 | } |
177 | | |
178 | | // values stored in component instance |
179 | 0 | ValInterface getValue(uint32_t Index) const noexcept { |
180 | 0 | if (ValueList.size() > Index) { |
181 | 0 | return ValueList[Index]; |
182 | 0 | } |
183 | 0 | return 0; |
184 | 0 | } |
185 | 0 | void setValue(uint32_t Index, ValInterface V) noexcept { |
186 | 0 | if (ValueList.size() <= Index) { |
187 | 0 | ValueList.resize(Index + 1, 0U); |
188 | 0 | } |
189 | 0 | ValueList[Index] = V; |
190 | 0 | } |
191 | | |
192 | | // Index space: component function instance. |
193 | | void |
194 | 0 | addFunction(std::unique_ptr<Component::FunctionInstance> &&Inst) noexcept { |
195 | 0 | OwnedFuncInsts.push_back(std::move(Inst)); |
196 | 0 | FuncInsts.push_back(OwnedFuncInsts.back().get()); |
197 | 0 | } |
198 | 0 | void addFunction(Component::FunctionInstance *Inst) noexcept { |
199 | 0 | FuncInsts.push_back(Inst); |
200 | 0 | } |
201 | 0 | Component::FunctionInstance *getFunction(uint32_t Index) const noexcept { |
202 | 0 | return FuncInsts[Index]; |
203 | 0 | } |
204 | 0 | void exportFunction(std::string_view Name, uint32_t Idx) noexcept { |
205 | 0 | ExpFuncInsts.insert_or_assign(std::string(Name), FuncInsts[Idx]); |
206 | 0 | } |
207 | | Component::FunctionInstance * |
208 | 0 | findFunction(std::string_view Name) const noexcept { |
209 | 0 | return findExport(ExpFuncInsts, Name); |
210 | 0 | } |
211 | | std::vector<std::pair<std::string, const AST::FunctionType &>> |
212 | 0 | getFuncExports() { |
213 | 0 | std::vector<std::pair<std::string, const AST::FunctionType &>> R; |
214 | 0 | R.reserve(ExpFuncInsts.size()); |
215 | 0 | for (auto &&[Name, Func] : ExpFuncInsts) { |
216 | 0 | const auto &FuncType = Func->getFuncType(); |
217 | 0 | R.emplace_back(Name, FuncType); |
218 | 0 | } |
219 | 0 | return R; |
220 | 0 | } |
221 | | |
222 | | // Index space: type. |
223 | | // TODO: deep copy the type |
224 | 0 | void addType(const AST::Component::DefType &Ty) noexcept { |
225 | 0 | Types.emplace_back(&Ty); |
226 | 0 | } |
227 | 0 | const AST::Component::DefType *getType(uint32_t Index) const noexcept { |
228 | 0 | return Types[Index]; |
229 | 0 | } |
230 | 0 | void exportType(std::string_view Name, uint32_t Idx) noexcept { |
231 | 0 | ExpTypes.insert_or_assign(std::string(Name), Types[Idx]); |
232 | 0 | } |
233 | | const AST::Component::DefType * |
234 | 0 | findType(std::string_view Name) const noexcept { |
235 | 0 | return findExport(ExpTypes, Name); |
236 | 0 | } |
237 | | |
238 | | // Index space: component instance. |
239 | | void |
240 | 0 | addComponentInstance(std::unique_ptr<ComponentInstance> &&Inst) noexcept { |
241 | 0 | OwnedCompInsts.push_back(std::move(Inst)); |
242 | 0 | CompInsts.push_back(OwnedCompInsts.back().get()); |
243 | 0 | } |
244 | 0 | void addComponentInstance(const ComponentInstance *Inst) noexcept { |
245 | 0 | CompInsts.push_back(Inst); |
246 | 0 | } |
247 | 0 | const ComponentInstance *getComponentInstance(uint32_t Index) const noexcept { |
248 | 0 | return CompInsts[Index]; |
249 | 0 | } |
250 | 0 | void exportComponentInstance(std::string_view Name, uint32_t Idx) noexcept { |
251 | 0 | ExpCompInsts.insert_or_assign(std::string(Name), CompInsts[Idx]); |
252 | 0 | } |
253 | | const ComponentInstance * |
254 | 0 | findComponentInstance(std::string_view Name) const noexcept { |
255 | 0 | return findExport(ExpCompInsts, Name); |
256 | 0 | } |
257 | | |
258 | | // Index space: component. (declaration for instantiation phase) |
259 | 0 | void addComponent(const AST::Component::Component &C) noexcept { |
260 | 0 | Comps.emplace_back(&C); |
261 | 0 | } |
262 | 0 | const AST::Component::Component &getComponent(uint32_t Index) const noexcept { |
263 | 0 | return *Comps[Index]; |
264 | 0 | } |
265 | | |
266 | | // Index space: core function. |
267 | 0 | void addCoreFunction(std::unique_ptr<FunctionInstance> &&Inst) noexcept { |
268 | 0 | OwnedCoreFuncInsts.push_back(std::move(Inst)); |
269 | 0 | CoreFuncInsts.push_back(OwnedCoreFuncInsts.back().get()); |
270 | 0 | } |
271 | 0 | void addCoreFunction(FunctionInstance *Inst) noexcept { |
272 | 0 | CoreFuncInsts.push_back(Inst); |
273 | 0 | } |
274 | 0 | FunctionInstance *getCoreFunction(uint32_t Index) const noexcept { |
275 | 0 | return CoreFuncInsts[Index]; |
276 | 0 | } |
277 | 0 | void exportCoreFunction(std::string_view Name, uint32_t Idx) noexcept { |
278 | 0 | ExpCoreFuncInsts.insert_or_assign(std::string(Name), CoreFuncInsts[Idx]); |
279 | 0 | } |
280 | 0 | FunctionInstance *findCoreFunction(std::string_view Name) const noexcept { |
281 | 0 | return findExport(ExpCoreFuncInsts, Name); |
282 | 0 | } |
283 | | |
284 | | // Index space: core table. |
285 | 0 | void addCoreTable(TableInstance *Inst) noexcept { |
286 | 0 | CoreTabInsts.push_back(Inst); |
287 | 0 | } |
288 | 0 | TableInstance *getCoreTable(uint32_t Index) const noexcept { |
289 | 0 | return CoreTabInsts[Index]; |
290 | 0 | } |
291 | 0 | void exportCoreTable(std::string_view Name, uint32_t Idx) noexcept { |
292 | 0 | ExpCoreTabInsts.insert_or_assign(std::string(Name), CoreTabInsts[Idx]); |
293 | 0 | } |
294 | 0 | TableInstance *findCoreTable(std::string_view Name) const noexcept { |
295 | 0 | return findExport(ExpCoreTabInsts, Name); |
296 | 0 | } |
297 | | |
298 | | // Index space: core memory. |
299 | 0 | void addCoreMemory(MemoryInstance *Inst) noexcept { |
300 | 0 | CoreMemInsts.push_back(Inst); |
301 | 0 | } |
302 | 0 | MemoryInstance *getCoreMemory(uint32_t Index) const noexcept { |
303 | 0 | return CoreMemInsts[Index]; |
304 | 0 | } |
305 | 0 | void exportCoreMemory(std::string_view Name, uint32_t Idx) noexcept { |
306 | 0 | ExpCoreMemInsts.insert_or_assign(std::string(Name), CoreMemInsts[Idx]); |
307 | 0 | } |
308 | 0 | MemoryInstance *findCoreMemory(std::string_view Name) const noexcept { |
309 | 0 | return findExport(ExpCoreMemInsts, Name); |
310 | 0 | } |
311 | | |
312 | | // Index space: core glocal. |
313 | 0 | void addCoreGlobal(GlobalInstance *Inst) noexcept { |
314 | 0 | CoreGlobInsts.push_back(Inst); |
315 | 0 | } |
316 | 0 | GlobalInstance *getCoreGlobal(uint32_t Index) const noexcept { |
317 | 0 | return CoreGlobInsts[Index]; |
318 | 0 | } |
319 | 0 | void exportCoreGlobal(std::string_view Name, uint32_t Idx) noexcept { |
320 | 0 | ExpCoreGlobInsts.insert_or_assign(std::string(Name), CoreGlobInsts[Idx]); |
321 | 0 | } |
322 | 0 | GlobalInstance *findCoreGlobal(std::string_view Name) const noexcept { |
323 | 0 | return findExport(ExpCoreGlobInsts, Name); |
324 | 0 | } |
325 | | |
326 | | // Index space: core type. |
327 | | // TODO: deep copy the type |
328 | 0 | void addCoreType(const AST::Component::CoreDefType &Ty) noexcept { |
329 | 0 | CoreTypes.emplace_back(&Ty); |
330 | 0 | } |
331 | | const AST::Component::CoreDefType & |
332 | 0 | getCoreType(uint32_t Index) const noexcept { |
333 | 0 | return *CoreTypes[Index]; |
334 | 0 | } |
335 | | |
336 | | // Index space: core module instance. |
337 | 0 | void addCoreModuleInstance(std::unique_ptr<ModuleInstance> &&Inst) noexcept { |
338 | 0 | OwnedCoreModInsts.push_back(std::move(Inst)); |
339 | 0 | CoreModInsts.push_back(OwnedCoreModInsts.back().get()); |
340 | 0 | } |
341 | 0 | const ModuleInstance *getCoreModuleInstance(uint32_t Index) const noexcept { |
342 | 0 | return CoreModInsts[Index]; |
343 | 0 | } |
344 | 0 | void exportCoreModuleInstance(std::string_view Name, uint32_t Idx) noexcept { |
345 | 0 | ExpCoreModInsts.insert_or_assign(std::string(Name), CoreModInsts[Idx]); |
346 | 0 | } |
347 | | const ModuleInstance * |
348 | 0 | findCoreModuleInstance(std::string_view Name) const noexcept { |
349 | 0 | return findExport(ExpCoreModInsts, Name); |
350 | 0 | } |
351 | | |
352 | | // Index space: module. (declaration for instantiation phase) |
353 | 0 | void addModule(const AST::Module &M) noexcept { CoreMods.emplace_back(&M); } |
354 | 0 | const AST::Module &getModule(uint32_t Index) const noexcept { |
355 | 0 | return *CoreMods[Index]; |
356 | 0 | } |
357 | | |
358 | | private: |
359 | | std::string CompName; |
360 | | |
361 | | // value |
362 | | std::vector<ValInterface> ValueList; |
363 | | |
364 | | // Index spaces. |
365 | | // The index spaces of AST should be cleaned after instantiation. |
366 | | std::vector<Component::FunctionInstance *> FuncInsts; |
367 | | // TODO: values |
368 | | std::vector<const AST::Component::DefType *> Types; |
369 | | std::vector<const ComponentInstance *> CompInsts; |
370 | | std::vector<const AST::Component::Component *> Comps; |
371 | | std::vector<FunctionInstance *> CoreFuncInsts; |
372 | | std::vector<TableInstance *> CoreTabInsts; |
373 | | std::vector<MemoryInstance *> CoreMemInsts; |
374 | | std::vector<GlobalInstance *> CoreGlobInsts; |
375 | | std::vector<const AST::Component::CoreDefType *> CoreTypes; |
376 | | std::vector<const ModuleInstance *> CoreModInsts; |
377 | | std::vector<const AST::Module *> CoreMods; |
378 | | |
379 | | // Storage of index spaces. |
380 | | std::vector<std::unique_ptr<Component::FunctionInstance>> OwnedFuncInsts; |
381 | | // std::vector<std::unique_ptr<AST::Component::DefType>> OwnedTypes; |
382 | | std::vector<std::unique_ptr<ComponentInstance>> OwnedCompInsts; |
383 | | std::vector<std::unique_ptr<FunctionInstance>> OwnedCoreFuncInsts; |
384 | | // std::vector<std::unique_ptr<AST::Component::CoreDefType>> OwnedCoreTypes; |
385 | | std::vector<std::unique_ptr<ModuleInstance>> OwnedCoreModInsts; |
386 | | |
387 | | // Export alias. |
388 | | std::map<std::string, Component::FunctionInstance *, std::less<>> |
389 | | ExpFuncInsts; |
390 | | // TODO: ExpValue |
391 | | std::map<std::string, const AST::Component::DefType *, std::less<>> ExpTypes; |
392 | | std::map<std::string, const ComponentInstance *, std::less<>> ExpCompInsts; |
393 | | // TODO: ExpComps |
394 | | std::map<std::string, FunctionInstance *, std::less<>> ExpCoreFuncInsts; |
395 | | std::map<std::string, TableInstance *, std::less<>> ExpCoreTabInsts; |
396 | | std::map<std::string, MemoryInstance *, std::less<>> ExpCoreMemInsts; |
397 | | std::map<std::string, GlobalInstance *, std::less<>> ExpCoreGlobInsts; |
398 | | // TODO: ExpCoreTypes |
399 | | std::map<std::string, const ModuleInstance *, std::less<>> ExpCoreModInsts; |
400 | | // TODO: ExpCoreMods |
401 | | |
402 | | // Find export template. |
403 | | template <typename T> |
404 | | T *findExport(const std::map<std::string, T *, std::less<>> &Map, |
405 | 0 | std::string_view ExtName) const noexcept { |
406 | 0 | auto Iter = Map.find(ExtName); |
407 | 0 | if (likely(Iter != Map.cend())) { |
408 | 0 | return Iter->second; |
409 | 0 | } |
410 | 0 | return nullptr; |
411 | 0 | } Unexecuted instantiation: WasmEdge::Runtime::Instance::Component::FunctionInstance* WasmEdge::Runtime::Instance::ComponentInstance::findExport<WasmEdge::Runtime::Instance::Component::FunctionInstance>(std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, WasmEdge::Runtime::Instance::Component::FunctionInstance*, std::__1::less<void>, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, WasmEdge::Runtime::Instance::Component::FunctionInstance*> > > const&, std::__1::basic_string_view<char, std::__1::char_traits<char> >) const Unexecuted instantiation: WasmEdge::AST::Component::DefType const* WasmEdge::Runtime::Instance::ComponentInstance::findExport<WasmEdge::AST::Component::DefType const>(std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, WasmEdge::AST::Component::DefType const*, std::__1::less<void>, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, WasmEdge::AST::Component::DefType const*> > > const&, std::__1::basic_string_view<char, std::__1::char_traits<char> >) const Unexecuted instantiation: WasmEdge::Runtime::Instance::ComponentInstance const* WasmEdge::Runtime::Instance::ComponentInstance::findExport<WasmEdge::Runtime::Instance::ComponentInstance const>(std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, WasmEdge::Runtime::Instance::ComponentInstance const*, std::__1::less<void>, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, WasmEdge::Runtime::Instance::ComponentInstance const*> > > const&, std::__1::basic_string_view<char, std::__1::char_traits<char> >) const Unexecuted instantiation: WasmEdge::Runtime::Instance::FunctionInstance* WasmEdge::Runtime::Instance::ComponentInstance::findExport<WasmEdge::Runtime::Instance::FunctionInstance>(std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, WasmEdge::Runtime::Instance::FunctionInstance*, std::__1::less<void>, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, WasmEdge::Runtime::Instance::FunctionInstance*> > > const&, std::__1::basic_string_view<char, std::__1::char_traits<char> >) const Unexecuted instantiation: WasmEdge::Runtime::Instance::TableInstance* WasmEdge::Runtime::Instance::ComponentInstance::findExport<WasmEdge::Runtime::Instance::TableInstance>(std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, WasmEdge::Runtime::Instance::TableInstance*, std::__1::less<void>, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, WasmEdge::Runtime::Instance::TableInstance*> > > const&, std::__1::basic_string_view<char, std::__1::char_traits<char> >) const Unexecuted instantiation: WasmEdge::Runtime::Instance::MemoryInstance* WasmEdge::Runtime::Instance::ComponentInstance::findExport<WasmEdge::Runtime::Instance::MemoryInstance>(std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, WasmEdge::Runtime::Instance::MemoryInstance*, std::__1::less<void>, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, WasmEdge::Runtime::Instance::MemoryInstance*> > > const&, std::__1::basic_string_view<char, std::__1::char_traits<char> >) const Unexecuted instantiation: WasmEdge::Runtime::Instance::GlobalInstance* WasmEdge::Runtime::Instance::ComponentInstance::findExport<WasmEdge::Runtime::Instance::GlobalInstance>(std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, WasmEdge::Runtime::Instance::GlobalInstance*, std::__1::less<void>, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, WasmEdge::Runtime::Instance::GlobalInstance*> > > const&, std::__1::basic_string_view<char, std::__1::char_traits<char> >) const Unexecuted instantiation: WasmEdge::Runtime::Instance::ModuleInstance const* WasmEdge::Runtime::Instance::ComponentInstance::findExport<WasmEdge::Runtime::Instance::ModuleInstance const>(std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, WasmEdge::Runtime::Instance::ModuleInstance const*, std::__1::less<void>, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, WasmEdge::Runtime::Instance::ModuleInstance const*> > > const&, std::__1::basic_string_view<char, std::__1::char_traits<char> >) const |
412 | | }; |
413 | | |
414 | | } // namespace Instance |
415 | | } // namespace Runtime |
416 | | } // namespace WasmEdge |