Coverage Report

Created: 2026-09-28 06:22

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/span.h"
17
#include "common/types.h"
18
19
#include <optional>
20
#include <vector>
21
22
namespace WasmEdge {
23
namespace AST {
24
namespace Component {
25
26
// value ::= t:<valtype> len:<core:u32> v:<val(t)> => (value t v)
27
//           (where len = ||v||)
28
29
/// AST Component::Value node.
30
class Value {
31
public:
32
16.4k
  ComponentValType &getType() noexcept { return Type; }
33
40.6k
  const ComponentValType &getType() const noexcept { return Type; }
34
16.3k
  std::vector<Byte> &getData() noexcept { return Data; }
35
13.7k
  Span<const Byte> getData() const noexcept { return Data; }
36
  /// Payload decoded by the validator and consumed at instantiation. It is
37
  /// mutable because validation walks a const AST.
38
0
  const std::optional<ComponentValVariant> &getDecoded() const noexcept {
39
0
    return Decoded;
40
0
  }
41
12.9k
  void setDecoded(ComponentValVariant V) const noexcept {
42
12.9k
    Decoded.emplace(std::move(V));
43
12.9k
  }
44
45
private:
46
  ComponentValType Type;
47
  std::vector<Byte> Data;
48
  mutable std::optional<ComponentValVariant> Decoded;
49
};
50
51
} // namespace Component
52
} // namespace AST
53
} // namespace WasmEdge