Coverage Report

Created: 2026-05-16 07:03

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/serenity/Userland/Libraries/LibJS/Bytecode/Label.h
Line
Count
Source
1
/*
2
 * Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
3
 *
4
 * SPDX-License-Identifier: BSD-2-Clause
5
 */
6
7
#pragma once
8
9
#include <AK/Format.h>
10
11
namespace JS::Bytecode {
12
13
class BasicBlock;
14
15
class Label {
16
public:
17
    explicit Label(BasicBlock const&);
18
19
    explicit Label(u32 basic_block_index)
20
        : m_address_or_basic_block_index(basic_block_index)
21
0
    {
22
0
    }
23
24
    // Used while compiling.
25
1
    size_t basic_block_index() const { return m_address_or_basic_block_index; }
26
27
    // Used after compiling.
28
0
    size_t address() const { return m_address_or_basic_block_index; }
29
30
0
    void set_address(size_t address) { m_address_or_basic_block_index = address; }
31
32
private:
33
    u32 m_address_or_basic_block_index { 0 };
34
};
35
36
}
37
38
template<>
39
struct AK::Formatter<JS::Bytecode::Label> : AK::Formatter<FormatString> {
40
    ErrorOr<void> format(FormatBuilder& builder, JS::Bytecode::Label const& label)
41
0
    {
42
0
        return AK::Formatter<FormatString>::format(builder, "@{:x}"sv, label.address());
43
0
    }
44
};