Coverage Report

Created: 2026-11-12 06:35

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/WasmEdge/include/runtime/instance/elem.h
Line
Count
Source
1
// SPDX-License-Identifier: Apache-2.0
2
// SPDX-FileCopyrightText: Copyright The WasmEdge Authors
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 uint64_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
  uint64_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() noexcept {
45
0
    Refs.clear();
46
0
    Dropped = true;
47
0
  }
48
49
0
  bool isDropped() const noexcept { return Dropped; }
50
51
private:
52
  /// \name Data of element instance.
53
  /// @{
54
  const uint64_t Off;
55
  const ValType Type;
56
  std::vector<RefVariant> Refs;
57
  bool Dropped = false;
58
  /// @}
59
};
60
61
} // namespace Instance
62
} // namespace Runtime
63
} // namespace WasmEdge