Label.h 630 B

12345678910111213141516171819202122232425262728293031323334
  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. namespace JS::Bytecode {
  9. class Label {
  10. public:
  11. explicit Label(size_t address)
  12. : m_address(address)
  13. {
  14. }
  15. size_t address() const { return m_address; }
  16. private:
  17. size_t m_address { 0 };
  18. };
  19. }
  20. template<>
  21. struct AK::Formatter<JS::Bytecode::Label> : AK::Formatter<FormatString> {
  22. void format(FormatBuilder& builder, JS::Bytecode::Label const& value)
  23. {
  24. return AK::Formatter<FormatString>::format(builder, "@{:x}", value.address());
  25. }
  26. };