Coverage Report

Created: 2025-07-01 06:18

/src/WasmEdge/include/runtime/instance/elem.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/runtime/instance/elem.h - Element Instance definition ----===//
5
//
6
// Part of the WasmEdge Project.
7
//
8
//===----------------------------------------------------------------------===//
9
///
10
/// \file
11
/// This file contains the element instance definition in store manager.
12
///
13
//===----------------------------------------------------------------------===//
14
#pragma once
15
16
#include "common/span.h"
17
#include "common/types.h"
18
19
#include <vector>
20
21
namespace WasmEdge {
22
namespace Runtime {
23
namespace Instance {
24
25
class ElementInstance {
26
public:
27
  ElementInstance() = delete;
28
  ElementInstance(const uint32_t Offset, const ValType &EType,
29
                  Span<const RefVariant> Init) noexcept
30
0
      : Off(Offset), Type(EType), Refs(Init.begin(), Init.end()) {
31
0
    assuming(Type.isRefType());
32
0
  }
33
34
  /// Get offset in element instance.
35
0
  uint32_t getOffset() const noexcept { return Off; }
36
37
  /// Get reference type of element instance.
38
0
  const ValType &getRefType() const noexcept { return Type; }
39
40
  /// Get reference lists in element instance.
41
0
  Span<const RefVariant> getRefs() const noexcept { return Refs; }
42
43
  /// Clear references in element instance.
44
0
  void clear() { Refs.clear(); }
45
46
private:
47
  /// \name Data of element instance.
48
  /// @{
49
  const uint32_t Off;
50
  const ValType Type;
51
  std::vector<RefVariant> Refs;
52
  /// @}
53
};
54
55
} // namespace Instance
56
} // namespace Runtime
57
} // namespace WasmEdge