Coverage Report

Created: 2025-07-01 06:18

/src/WasmEdge/include/runtime/instance/struct.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/struct.h - Struct Instance definition ---===//
5
//
6
// Part of the WasmEdge Project.
7
//
8
//===----------------------------------------------------------------------===//
9
///
10
/// \file
11
/// This file contains the struct instance definition in store manager.
12
///
13
//===----------------------------------------------------------------------===//
14
#pragma once
15
16
#include "ast/type.h"
17
#include "common/span.h"
18
#include "common/types.h"
19
#include "runtime/instance/composite.h"
20
21
#include <vector>
22
23
namespace WasmEdge {
24
namespace Runtime {
25
namespace Instance {
26
27
class StructInstance : public CompositeBase {
28
public:
29
  StructInstance() = delete;
30
  StructInstance(const ModuleInstance *Mod, const uint32_t Idx,
31
                 std::vector<ValVariant> &&Init) noexcept
32
0
      : CompositeBase(Mod, Idx), Data(std::move(Init)) {
33
0
    assuming(ModInst);
34
0
  }
35
36
  /// Get field data in struct instance.
37
0
  ValVariant &getField(uint32_t Idx) noexcept { return Data[Idx]; }
38
0
  const ValVariant &getField(uint32_t Idx) const noexcept { return Data[Idx]; }
39
40
private:
41
  /// \name Data of struct instance.
42
  /// @{
43
  std::vector<ValVariant> Data;
44
  /// @}
45
};
46
47
} // namespace Instance
48
} // namespace Runtime
49
} // namespace WasmEdge