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