/src/WasmEdge/include/ast/module.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/module.h - Module class definition -------------------===// |
5 | | // |
6 | | // Part of the WasmEdge Project. |
7 | | // |
8 | | //===----------------------------------------------------------------------===// |
9 | | /// |
10 | | /// \file |
11 | | /// This file contains the declaration of the Module node class, which is the |
12 | | /// module node in AST. |
13 | | /// |
14 | | //===----------------------------------------------------------------------===// |
15 | | #pragma once |
16 | | |
17 | | #include "ast/section.h" |
18 | | |
19 | | #include <vector> |
20 | | |
21 | | namespace WasmEdge { |
22 | | namespace AST { |
23 | | |
24 | | /// AST Module node. |
25 | | class Module { |
26 | | public: |
27 | | /// Getter of magic vector. |
28 | 0 | const std::vector<Byte> &getMagic() const noexcept { return Magic; } |
29 | 9.18k | std::vector<Byte> &getMagic() noexcept { return Magic; } |
30 | | |
31 | | /// Getter of version vector. |
32 | 0 | const std::vector<Byte> &getVersion() const noexcept { return Version; } |
33 | 9.18k | std::vector<Byte> &getVersion() noexcept { return Version; } |
34 | | |
35 | | /// Getters of references to sections. |
36 | 0 | Span<const CustomSection> getCustomSections() const noexcept { |
37 | 0 | return CustomSecs; |
38 | 0 | } |
39 | 90.1k | std::vector<CustomSection> &getCustomSections() noexcept { |
40 | 90.1k | return CustomSecs; |
41 | 90.1k | } |
42 | 5.94k | const TypeSection &getTypeSection() const { return TypeSec; } |
43 | 8.38k | TypeSection &getTypeSection() { return TypeSec; } |
44 | 5.94k | const ImportSection &getImportSection() const { return ImportSec; } |
45 | 4.10k | ImportSection &getImportSection() { return ImportSec; } |
46 | 5.93k | const FunctionSection &getFunctionSection() const { return FunctionSec; } |
47 | 8.18k | FunctionSection &getFunctionSection() { return FunctionSec; } |
48 | 5.93k | const TableSection &getTableSection() const { return TableSec; } |
49 | 443 | TableSection &getTableSection() { return TableSec; } |
50 | 5.92k | const MemorySection &getMemorySection() const { return MemorySec; } |
51 | 1.53k | MemorySection &getMemorySection() { return MemorySec; } |
52 | 5.89k | const GlobalSection &getGlobalSection() const { return GlobalSec; } |
53 | 683 | GlobalSection &getGlobalSection() { return GlobalSec; } |
54 | 5.83k | const ExportSection &getExportSection() const { return ExportSec; } |
55 | 1.25k | ExportSection &getExportSection() { return ExportSec; } |
56 | 3.63k | const StartSection &getStartSection() const { return StartSec; } |
57 | 46 | StartSection &getStartSection() { return StartSec; } |
58 | 5.76k | const ElementSection &getElementSection() const { return ElementSec; } |
59 | 1.43k | ElementSection &getElementSection() { return ElementSec; } |
60 | 5.68k | const CodeSection &getCodeSection() const { return CodeSec; } |
61 | 8.41k | CodeSection &getCodeSection() { return CodeSec; } |
62 | 5.71k | const DataSection &getDataSection() const { return DataSec; } |
63 | 1.63k | DataSection &getDataSection() { return DataSec; } |
64 | 0 | const DataCountSection &getDataCountSection() const { return DataCountSec; } |
65 | 3.95k | DataCountSection &getDataCountSection() { return DataCountSec; } |
66 | 3.69k | const TagSection &getTagSection() const { return TagSec; } |
67 | 3.82k | TagSection &getTagSection() { return TagSec; } |
68 | 0 | const AOTSection &getAOTSection() const { return AOTSec; } |
69 | 0 | AOTSection &getAOTSection() { return AOTSec; } |
70 | | |
71 | | /// Getter and setter of compiled symbol. |
72 | 0 | const auto &getSymbol() const noexcept { return IntrSymbol; } |
73 | 0 | void setSymbol(Symbol<const Executable::IntrinsicsTable *> S) noexcept { |
74 | 0 | IntrSymbol = std::move(S); |
75 | 0 | } |
76 | | |
77 | | /// Getter and setter of validated flag. |
78 | 2.14k | bool getIsValidated() const noexcept { return IsValidated; } |
79 | 2.14k | void setIsValidated(bool V = true) noexcept { IsValidated = V; } |
80 | | |
81 | | private: |
82 | | /// \name Data of Module node. |
83 | | /// @{ |
84 | | std::vector<Byte> Magic; |
85 | | std::vector<Byte> Version; |
86 | | /// @} |
87 | | |
88 | | /// \name Section nodes of Module node. |
89 | | /// @{ |
90 | | std::vector<CustomSection> CustomSecs; |
91 | | TypeSection TypeSec; |
92 | | ImportSection ImportSec; |
93 | | FunctionSection FunctionSec; |
94 | | TableSection TableSec; |
95 | | MemorySection MemorySec; |
96 | | GlobalSection GlobalSec; |
97 | | ExportSection ExportSec; |
98 | | StartSection StartSec; |
99 | | ElementSection ElementSec; |
100 | | CodeSection CodeSec; |
101 | | DataSection DataSec; |
102 | | DataCountSection DataCountSec; |
103 | | TagSection TagSec; |
104 | | /// @} |
105 | | |
106 | | /// \name Data of AOT. |
107 | | /// @{ |
108 | | AOTSection AOTSec; |
109 | | Symbol<const Executable::IntrinsicsTable *> IntrSymbol; |
110 | | /// @} |
111 | | |
112 | | /// \name Validated flag. |
113 | | /// @{ |
114 | | bool IsValidated = false; |
115 | | /// @} |
116 | | }; |
117 | | |
118 | | } // namespace AST |
119 | | } // namespace WasmEdge |