/src/WasmEdge/lib/executor/instantiate/component/component.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | // SPDX-License-Identifier: Apache-2.0 |
2 | | // SPDX-FileCopyrightText: 2019-2024 Second State INC |
3 | | |
4 | | #include "executor/executor.h" |
5 | | |
6 | | namespace WasmEdge { |
7 | | namespace Executor { |
8 | | |
9 | | // Instantiate module instance. See "include/executor/Executor.h". |
10 | | Expect<std::unique_ptr<Runtime::Instance::ComponentInstance>> |
11 | | Executor::instantiate(Runtime::StoreManager &StoreMgr, |
12 | | const AST::Component::Component &Comp, |
13 | 0 | std::optional<std::string_view> Name) { |
14 | 0 | auto CompInst = |
15 | 0 | std::make_unique<Runtime::Instance::ComponentInstance>(Name.value_or("")); |
16 | |
|
17 | 0 | for (const auto &Section : Comp.getSections()) { |
18 | 0 | auto Func = [&](auto &&Sec) -> Expect<void> { |
19 | 0 | using T = std::decay_t<decltype(Sec)>; |
20 | 0 | if constexpr (std::is_same_v<T, AST::Component::CoreModuleSection>) { |
21 | | // TODO: not to copy the module AST |
22 | 0 | CompInst->addModule(Sec.getContent()); |
23 | | } else if constexpr (std::is_same_v<T, |
24 | 0 | AST::Component::ComponentSection>) { |
25 | | // TODO: not to copy the component AST |
26 | 0 | CompInst->addComponent(Sec.getContent()); |
27 | 0 | } else if constexpr (std::is_same_v<T, AST::CustomSection>) { |
28 | | // Do nothing to custom section. |
29 | 0 | } else { |
30 | 0 | EXPECTED_TRY(instantiate(StoreMgr, *CompInst, Sec)); |
31 | 0 | } |
32 | 0 | return {}; |
33 | 0 | }; Unexecuted instantiation: component.cpp:cxx20::expected<void, WasmEdge::ErrCode> WasmEdge::Executor::Executor::instantiate(WasmEdge::Runtime::StoreManager&, WasmEdge::AST::Component::Component const&, std::__1::optional<std::__1::basic_string_view<char, std::__1::char_traits<char> > >)::$_0::operator()<WasmEdge::AST::CustomSection const&>(WasmEdge::AST::CustomSection const&) const Unexecuted instantiation: component.cpp:cxx20::expected<void, WasmEdge::ErrCode> WasmEdge::Executor::Executor::instantiate(WasmEdge::Runtime::StoreManager&, WasmEdge::AST::Component::Component const&, std::__1::optional<std::__1::basic_string_view<char, std::__1::char_traits<char> > >)::$_0::operator()<WasmEdge::AST::Component::CoreModuleSection const&>(WasmEdge::AST::Component::CoreModuleSection const&) const Unexecuted instantiation: component.cpp:cxx20::expected<void, WasmEdge::ErrCode> WasmEdge::Executor::Executor::instantiate(WasmEdge::Runtime::StoreManager&, WasmEdge::AST::Component::Component const&, std::__1::optional<std::__1::basic_string_view<char, std::__1::char_traits<char> > >)::$_0::operator()<WasmEdge::AST::Component::CoreInstanceSection const&>(WasmEdge::AST::Component::CoreInstanceSection const&) const Unexecuted instantiation: component.cpp:cxx20::expected<void, WasmEdge::ErrCode> WasmEdge::Executor::Executor::instantiate(WasmEdge::Runtime::StoreManager&, WasmEdge::AST::Component::Component const&, std::__1::optional<std::__1::basic_string_view<char, std::__1::char_traits<char> > >)::$_0::operator()<WasmEdge::AST::Component::CoreTypeSection const&>(WasmEdge::AST::Component::CoreTypeSection const&) const Unexecuted instantiation: component.cpp:cxx20::expected<void, WasmEdge::ErrCode> WasmEdge::Executor::Executor::instantiate(WasmEdge::Runtime::StoreManager&, WasmEdge::AST::Component::Component const&, std::__1::optional<std::__1::basic_string_view<char, std::__1::char_traits<char> > >)::$_0::operator()<WasmEdge::AST::Component::ComponentSection const&>(WasmEdge::AST::Component::ComponentSection const&) const Unexecuted instantiation: component.cpp:cxx20::expected<void, WasmEdge::ErrCode> WasmEdge::Executor::Executor::instantiate(WasmEdge::Runtime::StoreManager&, WasmEdge::AST::Component::Component const&, std::__1::optional<std::__1::basic_string_view<char, std::__1::char_traits<char> > >)::$_0::operator()<WasmEdge::AST::Component::InstanceSection const&>(WasmEdge::AST::Component::InstanceSection const&) const Unexecuted instantiation: component.cpp:cxx20::expected<void, WasmEdge::ErrCode> WasmEdge::Executor::Executor::instantiate(WasmEdge::Runtime::StoreManager&, WasmEdge::AST::Component::Component const&, std::__1::optional<std::__1::basic_string_view<char, std::__1::char_traits<char> > >)::$_0::operator()<WasmEdge::AST::Component::AliasSection const&>(WasmEdge::AST::Component::AliasSection const&) const Unexecuted instantiation: component.cpp:cxx20::expected<void, WasmEdge::ErrCode> WasmEdge::Executor::Executor::instantiate(WasmEdge::Runtime::StoreManager&, WasmEdge::AST::Component::Component const&, std::__1::optional<std::__1::basic_string_view<char, std::__1::char_traits<char> > >)::$_0::operator()<WasmEdge::AST::Component::TypeSection const&>(WasmEdge::AST::Component::TypeSection const&) const Unexecuted instantiation: component.cpp:cxx20::expected<void, WasmEdge::ErrCode> WasmEdge::Executor::Executor::instantiate(WasmEdge::Runtime::StoreManager&, WasmEdge::AST::Component::Component const&, std::__1::optional<std::__1::basic_string_view<char, std::__1::char_traits<char> > >)::$_0::operator()<WasmEdge::AST::Component::CanonSection const&>(WasmEdge::AST::Component::CanonSection const&) const Unexecuted instantiation: component.cpp:cxx20::expected<void, WasmEdge::ErrCode> WasmEdge::Executor::Executor::instantiate(WasmEdge::Runtime::StoreManager&, WasmEdge::AST::Component::Component const&, std::__1::optional<std::__1::basic_string_view<char, std::__1::char_traits<char> > >)::$_0::operator()<WasmEdge::AST::Component::StartSection const&>(WasmEdge::AST::Component::StartSection const&) const Unexecuted instantiation: component.cpp:cxx20::expected<void, WasmEdge::ErrCode> WasmEdge::Executor::Executor::instantiate(WasmEdge::Runtime::StoreManager&, WasmEdge::AST::Component::Component const&, std::__1::optional<std::__1::basic_string_view<char, std::__1::char_traits<char> > >)::$_0::operator()<WasmEdge::AST::Component::ImportSection const&>(WasmEdge::AST::Component::ImportSection const&) const Unexecuted instantiation: component.cpp:cxx20::expected<void, WasmEdge::ErrCode> WasmEdge::Executor::Executor::instantiate(WasmEdge::Runtime::StoreManager&, WasmEdge::AST::Component::Component const&, std::__1::optional<std::__1::basic_string_view<char, std::__1::char_traits<char> > >)::$_0::operator()<WasmEdge::AST::Component::ExportSection const&>(WasmEdge::AST::Component::ExportSection const&) const |
34 | 0 | EXPECTED_TRY(std::visit(Func, Section)); |
35 | 0 | } |
36 | | |
37 | 0 | if (Name.has_value()) { |
38 | 0 | StoreMgr.registerComponent(CompInst.get()); |
39 | 0 | } |
40 | 0 | return CompInst; |
41 | 0 | } |
42 | | |
43 | | } // namespace Executor |
44 | | } // namespace WasmEdge |