summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS/Bytecode/Label.h
blob: 44698f6704ac9703c1f08680a1253cfeb3d341d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/*
 * Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include <AK/Format.h>
#include <LibJS/Bytecode/BasicBlock.h>

namespace JS::Bytecode {

class Label {
public:
    explicit Label(BasicBlock const& block)
        : m_block(&block)
    {
    }

    auto& block() const { return *m_block; }

private:
    BasicBlock const* m_block { nullptr };
};

}

template<>
struct AK::Formatter<JS::Bytecode::Label> : AK::Formatter<FormatString> {
    ErrorOr<void> format(FormatBuilder& builder, JS::Bytecode::Label const& value)
    {
        return AK::Formatter<FormatString>::format(builder, "@{}"sv, value.block().name());
    }
};