2021-06-04 12:07:38 +02:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <AK/Format.h>
|
2021-06-09 06:49:58 +04:30
|
|
|
#include <LibJS/Bytecode/BasicBlock.h>
|
2021-06-04 12:07:38 +02:00
|
|
|
|
|
|
|
namespace JS::Bytecode {
|
|
|
|
|
|
|
|
class Label {
|
|
|
|
public:
|
2021-06-09 06:49:58 +04:30
|
|
|
explicit Label(BasicBlock const& block)
|
|
|
|
: m_block(block)
|
2021-06-04 12:07:38 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-06-09 06:49:58 +04:30
|
|
|
auto& block() const { return m_block; }
|
2021-06-04 12:07:38 +02:00
|
|
|
|
|
|
|
private:
|
2021-06-09 06:49:58 +04:30
|
|
|
BasicBlock const& m_block;
|
2021-06-04 12:07:38 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
template<>
|
|
|
|
struct AK::Formatter<JS::Bytecode::Label> : AK::Formatter<FormatString> {
|
|
|
|
void format(FormatBuilder& builder, JS::Bytecode::Label const& value)
|
|
|
|
{
|
2021-06-09 06:49:58 +04:30
|
|
|
return AK::Formatter<FormatString>::format(builder, "@{}", value.block().name());
|
2021-06-04 12:07:38 +02:00
|
|
|
}
|
|
|
|
};
|