Coverage Report

Created: 2025-07-01 06:18

/src/WasmEdge/include/runtime/instance/global.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/global.h - Global Instance definition ---===//
5
//
6
// Part of the WasmEdge Project.
7
//
8
//===----------------------------------------------------------------------===//
9
///
10
/// \file
11
/// This file contains the global instance definition in store manager.
12
///
13
//===----------------------------------------------------------------------===//
14
#pragma once
15
16
#include "ast/type.h"
17
18
namespace WasmEdge {
19
namespace Runtime {
20
namespace Instance {
21
22
class GlobalInstance {
23
public:
24
  GlobalInstance() = delete;
25
  GlobalInstance(const AST::GlobalType &GType,
26
                 ValVariant Val = uint128_t(0U)) noexcept
27
0
      : GlobType(GType), Value(Val) {
28
0
    assuming(GType.getValType().isNumType() ||
29
0
             GType.getValType().isNullableRefType() ||
30
0
             !Val.get<RefVariant>().isNull());
31
0
  }
32
33
  /// Getter of global type.
34
0
  const AST::GlobalType &getGlobalType() const noexcept { return GlobType; }
35
36
  /// Getter of value.
37
0
  const ValVariant &getValue() const noexcept { return Value; }
38
0
  ValVariant &getValue() noexcept { return Value; }
39
40
  /// Setter of value.
41
0
  void setValue(const ValVariant &Val) noexcept { Value = Val; }
42
43
private:
44
  /// \name Data of global instance.
45
  /// @{
46
  AST::GlobalType GlobType;
47
  alignas(16) ValVariant Value;
48
  /// @}
49
};
50
51
} // namespace Instance
52
} // namespace Runtime
53
} // namespace WasmEdge