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)
|
2021-06-13 20:40:20 +04:30
|
|
|
: m_block(&block)
|
2021-06-04 12:07:38 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-06-13 20:40:20 +04:30
|
|
|
auto& block() const { return *m_block; }
|
2021-06-04 12:07:38 +02:00
|
|
|
|
|
|
|
private:
|
2021-06-13 20:40:20 +04:30
|
|
|
BasicBlock const* m_block { nullptr };
|
2021-06-04 12:07:38 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
template<>
|
|
|
|
struct AK::Formatter<JS::Bytecode::Label> : AK::Formatter<FormatString> {
|
2021-11-16 01:15:21 +01:00
|
|
|
ErrorOr<void> format(FormatBuilder& builder, JS::Bytecode::Label const& value)
|
2021-06-04 12:07:38 +02:00
|
|
|
{
|
2022-07-11 17:32:29 +00:00
|
|
|
return AK::Formatter<FormatString>::format(builder, "@{}"sv, value.block().name());
|
2021-06-04 12:07:38 +02:00
|
|
|
}
|
|
|
|
};
|