/src/WasmEdge/include/ast/component/section.h
Line | Count | Source |
1 | | // SPDX-License-Identifier: Apache-2.0 |
2 | | // SPDX-FileCopyrightText: Copyright The WasmEdge Authors |
3 | | |
4 | | //===-- wasmedge/ast/component/section.h - Section class definitions ------===// |
5 | | // |
6 | | // Part of the WasmEdge Project. |
7 | | // |
8 | | //===----------------------------------------------------------------------===// |
9 | | /// |
10 | | /// \file |
11 | | /// This file contains the declaration of the Component Section node classes. |
12 | | /// |
13 | | //===----------------------------------------------------------------------===// |
14 | | #pragma once |
15 | | |
16 | | #include "ast/component/alias.h" |
17 | | #include "ast/component/canonical.h" |
18 | | #include "ast/component/export.h" |
19 | | #include "ast/component/import.h" |
20 | | #include "ast/component/instance.h" |
21 | | #include "ast/component/start.h" |
22 | | #include "ast/component/type.h" |
23 | | #include "ast/component/value.h" |
24 | | #include "ast/module.h" |
25 | | #include "ast/section.h" |
26 | | |
27 | | namespace WasmEdge { |
28 | | namespace AST { |
29 | | namespace Component { |
30 | | |
31 | | /// AST Component::CoreModuleSection node. |
32 | | class CoreModuleSection : public Section { |
33 | | public: |
34 | | /// Getter for content. |
35 | 3.86k | const Module &getContent() const noexcept { return Content; } |
36 | 8.13k | Module &getContent() noexcept { return Content; } |
37 | | |
38 | | private: |
39 | | /// \name Data of CoreModuleSection. |
40 | | /// @{ |
41 | | Module Content; |
42 | | /// @} |
43 | | }; |
44 | | |
45 | | /// AST Component::CoreInstanceSection node. |
46 | | class CoreInstanceSection : public Section { |
47 | | public: |
48 | | /// Getter for content module. |
49 | 82.8k | Span<const CoreInstance> getContent() const noexcept { return Content; } |
50 | 89.4k | std::vector<CoreInstance> &getContent() noexcept { return Content; } |
51 | | |
52 | | private: |
53 | | /// \name Data of CoreInstanceSection. |
54 | | /// @{ |
55 | | std::vector<CoreInstance> Content; |
56 | | /// @} |
57 | | }; |
58 | | |
59 | | /// AST Component::CoreTypeSection node. |
60 | | class CoreTypeSection : public Section { |
61 | | public: |
62 | | /// Getter for content module. |
63 | 170k | Span<const CoreDefType> getContent() const noexcept { return Content; } |
64 | 180k | std::vector<CoreDefType> &getContent() noexcept { return Content; } |
65 | | |
66 | | private: |
67 | | /// \name Data of CoreTypeSection. |
68 | | /// @{ |
69 | | std::vector<CoreDefType> Content; |
70 | | /// @} |
71 | | }; |
72 | | |
73 | | class Component; |
74 | | |
75 | | /// AST Component::ComponentSection node. |
76 | | class ComponentSection : public Section { |
77 | | public: |
78 | | /// Getter for content. |
79 | 93.4k | const Component &getContent() const noexcept { return *Content; } |
80 | 100k | std::unique_ptr<Component> &getContent() noexcept { return Content; } |
81 | | |
82 | | private: |
83 | | /// \name Data of ComponentSection. |
84 | | /// @{ |
85 | | std::unique_ptr<Component> Content; |
86 | | /// @} |
87 | | }; |
88 | | |
89 | | /// AST Component::InstanceSection node. |
90 | | class InstanceSection : public Section { |
91 | | public: |
92 | | /// Getter for content module. |
93 | 1.41M | Span<const Instance> getContent() const noexcept { return Content; } |
94 | 1.50M | std::vector<Instance> &getContent() noexcept { return Content; } |
95 | | |
96 | | private: |
97 | | /// \name Data of InstanceSection. |
98 | | /// @{ |
99 | | std::vector<Instance> Content; |
100 | | /// @} |
101 | | }; |
102 | | |
103 | | /// AST Component::AliasSection node. |
104 | | class AliasSection : public Section { |
105 | | public: |
106 | | /// Getter for content module. |
107 | 5.41k | Span<const Alias> getContent() const noexcept { return Content; } |
108 | 6.32k | std::vector<Alias> &getContent() noexcept { return Content; } |
109 | | |
110 | | private: |
111 | | /// \name Data of AliasSection. |
112 | | /// @{ |
113 | | std::vector<Alias> Content; |
114 | | /// @} |
115 | | }; |
116 | | |
117 | | /// AST Component::TypeSection node. |
118 | | class TypeSection : public Section { |
119 | | public: |
120 | | /// Getter for content module. |
121 | 2.53M | Span<const DefType> getContent() const noexcept { return Content; } |
122 | 2.62M | std::vector<DefType> &getContent() noexcept { return Content; } |
123 | | |
124 | | private: |
125 | | /// \name Data of TypeSection. |
126 | | /// @{ |
127 | | std::vector<DefType> Content; |
128 | | /// @} |
129 | | }; |
130 | | |
131 | | /// AST Component::CanonSection node. |
132 | | class CanonSection : public Section { |
133 | | public: |
134 | | /// Getter for content module. |
135 | 45.1k | Span<const Canonical> getContent() const noexcept { return Content; } |
136 | 56.5k | std::vector<Canonical> &getContent() noexcept { return Content; } |
137 | | |
138 | | private: |
139 | | /// \name Data of CanonicalSection. |
140 | | /// @{ |
141 | | std::vector<Canonical> Content; |
142 | | /// @} |
143 | | }; |
144 | | |
145 | | /// AST Component::StartSection node. |
146 | | class StartSection : public Section { |
147 | | public: |
148 | | /// Getter for content module. |
149 | 530 | const Start &getContent() const noexcept { return Content; } |
150 | 981 | Start &getContent() noexcept { return Content; } |
151 | | |
152 | | private: |
153 | | /// \name Data of StartSection. |
154 | | /// @{ |
155 | | Start Content; |
156 | | /// @} |
157 | | }; |
158 | | |
159 | | /// AST Component::ImportSection node. |
160 | | class ImportSection : public Section { |
161 | | public: |
162 | | /// Getter for content module. |
163 | 73.0k | Span<const Import> getContent() const noexcept { return Content; } |
164 | 78.8k | std::vector<Import> &getContent() noexcept { return Content; } |
165 | | |
166 | | private: |
167 | | /// \name Data of ImportSection. |
168 | | /// @{ |
169 | | std::vector<Import> Content; |
170 | | /// @} |
171 | | }; |
172 | | |
173 | | /// AST Component::ExportSection node. |
174 | | class ExportSection : public Section { |
175 | | public: |
176 | | /// Getter for content module. |
177 | 3.47k | Span<const Export> getContent() const noexcept { return Content; } |
178 | 6.53k | std::vector<Export> &getContent() noexcept { return Content; } |
179 | | |
180 | | private: |
181 | | /// \name Data of ExportSection. |
182 | | /// @{ |
183 | | std::vector<Export> Content; |
184 | | /// @} |
185 | | }; |
186 | | |
187 | | /// AST Component::ValueSection node. |
188 | | class ValueSection : public Section { |
189 | | public: |
190 | | /// Getter for content module. |
191 | 13.2k | Span<const Value> getContent() const noexcept { return Content; } |
192 | 14.4k | std::vector<Value> &getContent() noexcept { return Content; } |
193 | | |
194 | | private: |
195 | | /// \name Data of ValueSection. |
196 | | /// @{ |
197 | | std::vector<Value> Content; |
198 | | /// @} |
199 | | }; |
200 | | |
201 | | } // namespace Component |
202 | | } // namespace AST |
203 | | } // namespace WasmEdge |