Coverage Report

Created: 2025-07-01 06:18

/src/WasmEdge/include/ast/component/section.h
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
//===-- 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/module.h"
24
#include "ast/section.h"
25
26
namespace WasmEdge {
27
namespace AST {
28
namespace Component {
29
30
/// AST Component::CoreModuleSection node.
31
class CoreModuleSection : public Section {
32
public:
33
  /// Getter of content.
34
0
  const Module &getContent() const noexcept { return Content; }
35
0
  Module &getContent() noexcept { return Content; }
36
37
private:
38
  /// \name Data of CoreModuleSection.
39
  /// @{
40
  Module Content;
41
  /// @}
42
};
43
44
/// AST Component::CoreInstanceSection node.
45
class CoreInstanceSection : public Section {
46
public:
47
  /// Getter of content module.
48
0
  Span<const CoreInstanceExpr> getContent() const noexcept { return Content; }
49
0
  std::vector<CoreInstanceExpr> &getContent() noexcept { return Content; }
50
51
private:
52
  /// \name Data of CoreInstanceSection.
53
  /// @{
54
  std::vector<CoreInstanceExpr> Content;
55
  /// @}
56
};
57
58
/// AST Component::CoreTypeSection node.
59
class CoreTypeSection : public Section {
60
public:
61
  /// Getter of content module.
62
0
  Span<const CoreDefType> getContent() const noexcept { return Content; }
63
0
  std::vector<CoreDefType> &getContent() noexcept { return Content; }
64
65
private:
66
  /// \name Data of CoreTypeSection.
67
  /// @{
68
  std::vector<CoreDefType> Content;
69
  /// @}
70
};
71
72
class Component;
73
74
/// AST Component::ComponentSection node.
75
class ComponentSection : public Section {
76
public:
77
  /// Getter of content.
78
0
  const Component &getContent() const noexcept { return *Content; }
79
0
  std::shared_ptr<Component> &getContent() noexcept { return Content; }
80
81
private:
82
  /// \name Data of ComponentSection.
83
  /// @{
84
  std::shared_ptr<Component> Content;
85
  /// @}
86
};
87
88
/// AST Component::InstanceSection node.
89
class InstanceSection : public Section {
90
public:
91
  /// Getter of content module.
92
0
  Span<const InstanceExpr> getContent() const noexcept { return Content; }
93
0
  std::vector<InstanceExpr> &getContent() noexcept { return Content; }
94
95
private:
96
  /// \name Data of InstanceSection.
97
  /// @{
98
  std::vector<InstanceExpr> Content;
99
  /// @}
100
};
101
102
/// AST Component::AliasSection node.
103
class AliasSection : public Section {
104
public:
105
  /// Getter of content module.
106
0
  Span<const Alias> getContent() const noexcept { return Content; }
107
0
  std::vector<Alias> &getContent() noexcept { return Content; }
108
109
private:
110
  /// \name Data of AliasSection.
111
  /// @{
112
  std::vector<Alias> Content;
113
  /// @}
114
};
115
116
/// AST Component::TypeSection node.
117
class TypeSection : public Section {
118
public:
119
  /// Getter of content module.
120
0
  Span<const DefType> getContent() const noexcept { return Content; }
121
0
  std::vector<DefType> &getContent() noexcept { return Content; }
122
123
private:
124
  /// \name Data of TypeSection.
125
  /// @{
126
  std::vector<DefType> Content;
127
  /// @}
128
};
129
130
/// AST Component::CanonSection node.
131
class CanonSection : public Section {
132
public:
133
  /// Getter of content module.
134
0
  Span<const Canon> getContent() const noexcept { return Content; }
135
0
  std::vector<Canon> &getContent() noexcept { return Content; }
136
137
private:
138
  /// \name Data of CanonicalSection.
139
  /// @{
140
  std::vector<Canon> Content;
141
  /// @}
142
};
143
144
/// AST Component::StartSection node.
145
class StartSection : public Section {
146
public:
147
  /// Getter of content module.
148
0
  const Start &getContent() const noexcept { return Content; }
149
0
  Start &getContent() noexcept { return Content; }
150
151
private:
152
  /// \name Data of StartSection.
153
  /// @{
154
  Start Content;
155
  /// @}
156
};
157
158
/// AST Component::ImportSection node.
159
class ImportSection : public Section {
160
public:
161
  /// Getter of content module.
162
0
  Span<const Import> getContent() const noexcept { return Content; }
163
0
  std::vector<Import> &getContent() noexcept { return Content; }
164
165
private:
166
  /// \name Data of ImportSection.
167
  /// @{
168
  std::vector<Import> Content;
169
  /// @}
170
};
171
172
/// AST Component::ExportSection node.
173
class ExportSection : public Section {
174
public:
175
  /// Getter of content module.
176
0
  Span<const Export> getContent() const noexcept { return Content; }
177
0
  std::vector<Export> &getContent() noexcept { return Content; }
178
179
private:
180
  /// \name Data of ExportSection.
181
  /// @{
182
  std::vector<Export> Content;
183
  /// @}
184
};
185
186
// TODO: COMPONENT - AST Component::ValueSection node.
187
188
} // namespace Component
189
} // namespace AST
190
} // namespace WasmEdge