Coverage Report

Created: 2026-11-12 06:35

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/WasmEdge/include/ast/component/value.h
Line
Count
Source
1
// SPDX-License-Identifier: Apache-2.0
2
// SPDX-FileCopyrightText: 2019-2024 Second State INC
3
4
//===-- wasmedge/ast/component/value.h - Value class definition -----------===//
5
//
6
// Part of the WasmEdge Project.
7
//
8
//===----------------------------------------------------------------------===//
9
///
10
/// \file
11
/// This file contains the declaration of the Value node class.
12
///
13
//===----------------------------------------------------------------------===//
14
#pragma once
15
16
#include "common/component_valtype.h"
17
#include "common/component_variant.h"
18
#include "common/span.h"
19
#include "common/types.h"
20
21
#include <optional>
22
#include <vector>
23
24
namespace WasmEdge {
25
namespace AST {
26
namespace Component {
27
28
// value ::= t:<valtype> len:<core:u32> v:<val(t)> => (value t v)
29
//           (where len = ||v||)
30
31
/// AST Component::Value node.
32
class Value {
33
public:
34
46.4k
  ComponentValType &getType() noexcept { return Type; }
35
57.6k
  const ComponentValType &getType() const noexcept { return Type; }
36
46.2k
  std::vector<Byte> &getData() noexcept { return Data; }
37
14.6k
  Span<const Byte> getData() const noexcept { return Data; }
38
  /// Payload decoded by the validator and consumed at instantiation. It is
39
  /// mutable because validation walks a const AST.
40
0
  const std::optional<ComponentValVariant> &getDecoded() const noexcept {
41
0
    return Decoded;
42
0
  }
43
13.6k
  void setDecoded(ComponentValVariant V) const noexcept {
44
13.6k
    Decoded.emplace(std::move(V));
45
13.6k
  }
46
47
private:
48
  ComponentValType Type;
49
  std::vector<Byte> Data;
50
  mutable std::optional<ComponentValVariant> Decoded;
51
};
52
53
} // namespace Component
54
} // namespace AST
55
} // namespace WasmEdge