Label.h 689 B

1234567891011121314151617181920212223242526272829303132333435
  1. /*
  2. * Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/Format.h>
  8. #include <LibJS/Bytecode/BasicBlock.h>
  9. namespace JS::Bytecode {
  10. class Label {
  11. public:
  12. explicit Label(BasicBlock const& block)
  13. : m_block(&block)
  14. {
  15. }
  16. auto& block() const { return *m_block; }
  17. private:
  18. BasicBlock const* m_block { nullptr };
  19. };
  20. }
  21. template<>
  22. struct AK::Formatter<JS::Bytecode::Label> : AK::Formatter<FormatString> {
  23. void format(FormatBuilder& builder, JS::Bytecode::Label const& value)
  24. {
  25. return AK::Formatter<FormatString>::format(builder, "@{}", value.block().name());
  26. }
  27. };