/src/WasmEdge/include/ast/component/import.h
Line | Count | Source |
1 | | // SPDX-License-Identifier: Apache-2.0 |
2 | | // SPDX-FileCopyrightText: Copyright The WasmEdge Authors |
3 | | |
4 | | //===-- wasmedge/ast/component/import.h - Import class definition ---------===// |
5 | | // |
6 | | // Part of the WasmEdge Project. |
7 | | // |
8 | | //===----------------------------------------------------------------------===// |
9 | | /// |
10 | | /// \file |
11 | | /// This file contains the declaration of the Import node class. |
12 | | /// |
13 | | //===----------------------------------------------------------------------===// |
14 | | #pragma once |
15 | | |
16 | | #include "ast/component/sort.h" |
17 | | #include "ast/component/type.h" |
18 | | #include "common/span.h" |
19 | | |
20 | | #include <optional> |
21 | | #include <string> |
22 | | #include <vector> |
23 | | |
24 | | namespace WasmEdge { |
25 | | namespace AST { |
26 | | namespace Component { |
27 | | |
28 | | // import ::= na:<nameattributes> et:<externtype> |
29 | | // => (import na et) |
30 | | // nameattributes ::= 0x00 len:<u32> en:<externname> => en (if len = |en|) |
31 | | // | 0x01 len:<u32> en:<externname> => en (if len = |en|) |
32 | | // | 0x02 len:<u32> en:<externname> a*:vec(<attribute>) |
33 | | // => en a* (if len = |en|) 🏷️/🔗 |
34 | | // attribute ::= 0x00 len:<u32> in:<interfacename> |
35 | | // => (implements in) (if len = |in|) 🏷️ |
36 | | // | 0x01 len:<u32> vs:<semversuffix> |
37 | | // => (versionsuffix vs) (if len = |vs|) 🔗 |
38 | | // | 0x02 n:<name> => (external-id n) 🏷️ |
39 | | |
40 | | /// AST Component::Import node. |
41 | | class Import { |
42 | | public: |
43 | 7.08k | std::string &getName() noexcept { return Name; } |
44 | 10.0k | std::string_view getName() const noexcept { return Name; } |
45 | 6.95k | ExternDesc &getDesc() noexcept { return Desc; } |
46 | 5.33k | const ExternDesc &getDesc() const noexcept { return Desc; } |
47 | 7.08k | std::vector<std::string> &getImplements() noexcept { return Implements; } |
48 | 5.19k | Span<const std::string> getImplements() const noexcept { return Implements; } |
49 | 7.08k | std::vector<std::string> &getExternalIds() noexcept { return ExternalIds; } |
50 | 5.19k | Span<const std::string> getExternalIds() const noexcept { |
51 | 5.19k | return ExternalIds; |
52 | 5.19k | } |
53 | 7.08k | std::vector<std::string> &getVersionSuffixes() noexcept { |
54 | 7.08k | return VersionSuffixes; |
55 | 7.08k | } |
56 | 5.19k | Span<const std::string> getVersionSuffixes() const noexcept { |
57 | 5.19k | return VersionSuffixes; |
58 | 5.19k | } |
59 | | |
60 | | private: |
61 | | std::string Name; |
62 | | ExternDesc Desc; |
63 | | std::vector<std::string> Implements; |
64 | | std::vector<std::string> ExternalIds; |
65 | | std::vector<std::string> VersionSuffixes; |
66 | | }; |
67 | | |
68 | | } // namespace Component |
69 | | } // namespace AST |
70 | | } // namespace WasmEdge |